mini-css-extract-plugin: Webpack 5.beta.11: HMR error Cannot read property 'getModuleIndex2' of undefined
- Operating System:
- Node Version: 13.3
- NPM Version: 6.13.1
- webpack Version: 5.0.0-beta.11
- mini-css-extract-plugin Version: 0.9
HMR code
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../',
sourceMap: CreateSourceMap,
hmr: watchMode,
reloadAll: true,
},
},
Expected Behavior
- Run webpack in watchmode with HMR
- compile css, no issue
- rerun, no issue 😃
Actual Behavior
- Run webpack in watchmode with HMR
- compile css, no issue
- rerun, issue 😦
TypeError: Cannot read property 'getModuleIndex2' of undefined at MiniCssExtractPlugin.renderContentAsset ([...]/node_modules/mini-css-extract-plugin/dist/index.js:301:27)
It seems that getModuleIndex2 is deprecated in webpack 5. I don’t know if this plugin is already compatible. If needed I can create a repo with minimal code.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 39 (10 by maintainers)
I tried out the update, but seeing a different error now. Hope it helps.
Using the latest
webpack@5.0.0-beta.28
Still same issue in
webpack@5.0.0-beta.18
.This is a show-stopper bug completely preventing HMR with MiniCssExtractPlugin in Webpack 5. Please give this some attention 🙏
I have the same problem with Webpack
5-beta.22
, probably you guys already know this but look like the problem, is related the HMR for (CSS|SCSS) files using themini-css-extract-plugin
, if I use the following configuration for CSS filesI get the following error.
But if I replace in the Webpack configuration the
mini-css-extract-plugin
forstyle-loader
everything works fine again.Now when I run the application for the first time everything loads properly, no errors, and the styles file loads ok, but as soon I make the minimum change in the CSS files after reloads is when I get the error message.
I don’t know exactly what changes in
Webpack 5
and themini-css-extract-plugin
, but looks like using this plugin causes the problem.NOTE: As I saw in this thread I tried disabling the
new webpack.HotModuleReplacementPlugin()
as someone mentioned this could fixed the problem, however in my case removing this plugin didn’t affect at all the result, I still got the error.still same issues in
webpack@5.0.0-beta.15
@evilebottnawi slightlyfaulty/webpack-mcep-repro-487
yarn start
src/index.css
Please try https://github.com/webpack-contrib/mini-css-extract-plugin/releases/tag/v0.11.3, if you faced with issue(s)/problems, please open new issue with simple reproducible test repo, thanks for using webpack