webpack-dev-server: HookWebpackError: Cannot read property 'updatedChunkIds' of undefined
- Operating System: Windows
- Node Version: 14.15.1
- NPM Version: 6.14.10
- webpack Version: 5.11.1
- webpack-dev-server Version: 3.11.1
- Browser: Chrome 87.0.4280.141
- This is a bug
- This is a modification request
Code
Gist with config and package.json
Expected Behavior
Live server compiles with hot: true and recompiles after editing code
Actual Behavior
If I run webpack via npm start it compiles, but if I change any piece of code (pug or scss or js) it fails with HookWebpackError: Cannot read property 'updatedChunkIds' of undefined
- if I remove
hot: trueit works as expected; - if I remove target or pass
browserlistinstead ofweb- it still fails; - if I try to remove
hot: trueand init HMR vianew webpack.HotModuleReplacementPlugin()- it fails in the same manner;
For Bugs; How can we reproduce the behavior?
My full build is on github (dev branch) - you can run it and check the bug;
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 45 (18 by maintainers)
@alexander-akait it’s the same repo from the start post. I’ve pushed package.json with updated dependencies (including webpack -> 5.17.0) to it.
I tried today the build with updated webpack, still have this issue from the start post
Well, that’s the problem: I can’t find any pattern as to when this triggers, and I’ve never seen this trigger for small examples.
But: Given that this seems related to chunking, and inspired by the details given by @siilike, I read around in the docs:
I do not use
SplitChunksPlugin, but I do use lazy loading. Wanna guess where the code I change to trigger this bug is located? Yep, it’s lazy-loaded, like so:Thinking about it, I cannot recall fighting with this when changing code that is in the main, non-lazy-loaded part.
Does that help? I might try to create a minimal example again using lazy loading, but I’m not sure whether that’ll work.
Started working after deleting records and making a clean build.
It was complex bug and fixed here
https://github.com/webpack/webpack/releases
Let’s close, anyway if somebody faced with the problem, please update webpack to v5.27.2, if it is not help, please open an issue with reproducible test repo
Indeed 🙈 (I just wanted to link this up two-way, in case more relevant info appears on SO.)
I’m getting a similar issue running Webpack 5.12.3
@alexander-akait I’ve added reproducible test repo in the start post, it is here - dev branch. Hope it’ll help.
I don’t know why the error exists, but everything fails only on HMR init =(