question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack 5.beta.11: HMR error Cannot read property 'getModuleIndex2' of undefined

See original GitHub issue
  • 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

  1. Run webpack in watchmode with HMR
  2. compile css, no issue
  3. rerun, no issue 😃

Actual Behavior

  1. Run webpack in watchmode with HMR
  2. compile css, no issue
  3. 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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:39 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
slightlyfaultycommented, Aug 27, 2020

I tried out the update, but seeing a different error now. Hope it helps.

TypeError: Cannot read property 'getModulePostOrderIndex' of undefined
    at MiniCssExtractPlugin.renderContentAsset (/node_modules/mini-css-extract-plugin/dist/index.js:384:26)
    at Object.render (/node_modules/mini-css-extract-plugin/dist/index.js:225:34)
    at /node_modules/webpack/lib/HotModuleReplacementPlugin.js:488:32
    at Hook.eval [as callAsync] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/node_modules/tapable/lib/Hook.js:18:14)
    at cont (/node_modules/webpack/lib/Compilation.js:1975:33)
    at /node_modules/webpack/lib/Compilation.js:2013:9
    at /node_modules/neo-async/async.js:2830:7
    at Object.each (/node_modules/neo-async/async.js:2850:39)
    at Compilation.createChunkAssets (/node_modules/webpack/lib/Compilation.js:2969:12)

Using the latest webpack@5.0.0-beta.28

6reactions
slightlyfaultycommented, Jun 22, 2020

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 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack 5 HMR issue - Cannot read property ...
First time it compiles properly, but when it comes to recompiling after code changes - it breaks with HookWebpackError: Cannot read property ' ......
Read more >
Webpack Error: Cannot read property .toWebpackConfig of ...
I added a new dependency, pdf-lib, and now webpack/webpacker is blowing up. ... TypeError: Cannot read property 'toWebpackConfig' of undefined at Object.
Read more >
Webpack 5: Why Minicssextractplugin.Loader Doesn't Let Hmr ...
Extract CSS from chunks into multiple stylesheets + HMR TypeError: Cannot read property 'getModuleIndex2' of undefined at ExtractCssChunksPlugin.
Read more >
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >
webpack/types.d.ts - UNPKG
Error, stats?: T): void;. 659, }. 660, type Cell<T> = undefined | T;. 661, declare class Chunk {. 662, constructor(name?: string);.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found