mini-css-extract-plugin: "installedCssChunks is not defined" after 2.9.0 update

After upgrading from 2.8.1 to 2.9.0 (and then 2.9.1), we’re seeing this error repeatedly in the Chrome dev console. We didn’t change any aspect of our config or css loading set-up.

image

I believe this is related to this change: https://github.com/webpack-contrib/mini-css-extract-plugin/pull/1043

Plugin config

...
  {
        test: /\.less$/,
        include: [path.join(appDirectory, 'stylesheets')],
        exclude: [],
        use: [
          MiniCssExtractPlugin.loader,
          {
            loader: 'css-loader',
            options: {
              sourceMap: DEV,
            },
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                plugins: [require('autoprefixer')],
              },
              sourceMap: DEV,
            },
          },

          {
            loader: 'less-loader',
            options: {
              lessOptions: {
                math: 'always',
              },
              sourceMap: DEV,
            },
          },
        ],
      },
...
plugins: [
   ...
  new MiniCssExtractPlugin({
      experimentalUseImportModule: true,
      filename: '[name].[contenthash:20].css',
    }),
  ...
]

Please paste the results of npx webpack-cli info here, and mention other relevant information

System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 1.10 GB / 36.00 GB
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.12.2/bin/npm
  Browsers:
    Chrome: 127.0.6533.120
    Safari: 17.6
  Packages:
    babel-loader: ^9.1.3 => 9.1.3 
    css-loader: ^6.11.0 => 6.11.0 
    expose-loader: ^5.0.0 => 5.0.0 
    json-loader: ~0.5.7 => 0.5.7 
    less-loader: ^12.2.0 => 12.2.0 
    postcss-loader: ^8.1.1 => 8.1.1 
    source-map-loader: ^5.0.0 => 5.0.0 
    style-loader: ^4.0.0 => 4.0.0 
    webpack: ^5.93.0 => 5.93.0 
    webpack-cli: ^5.1.4 => 5.1.4 

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 21 (11 by maintainers)

Most upvoted comments

I was able to reproduce

I am running into this issue as well, in an Angular 18 app. mini-css version is 2.9.0. If I change all three instances of the /* webpackPrefetch: true */ magic comment to /* webpackPrefetch: false */ (EDIT: false is not actually a valid value, but it has the same effect as removing the comment entirely) then the error goes away. EDIT because it seems to be one error per instance of this magic comment.

I’ll try to provide a minimal repro if I can. EDIT: no luck with a fresh webpack-based Angular 18 app.

We aren’t doing any prefetching ourselves, but from what I can tell, this seems to always be breaking on a chunk that’s coming from a library we’re using that’s calling import with webpackPrefetch: true. That chunkId seems to always be the one that’s going through this mini-css code where installedCssChunks is undefined:

image

The library in question is just passing the import function into React.lazy. We’re not preloading / prefetching our css chunks at all.

For sure, I can debug it locally. I’ll have to set that branch back up, but that won’t take a long.

We are also seeing the issue, in watch mode only and only on certain usage patterns of split bundles. We will try and help with more info by debugging within a few weeks unless someone beats us to it.