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.

HMR not working with multiple entries

See original GitHub issue
  • Operating System: Linux
  • Node Version: 14.14.0
  • NPM Version: 6.14.7
  • webpack Version: 5.2.0
  • webpack-dev-server Version: 3.11.0
  • Browser: Google Chrome
  • This is a bug
  • This is a modification request

Code

https://github.com/slightlyfaulty/webpack-hmr-multi-entry-repro

// webpack.config.js
...
entry: {
  first: ['./src/first.js', './src/first.css'],
  second: ['./src/second.js', './src/second.css'],
},
...

Expected Behavior

After starting the dev server, hot module replacement should work for all JS and CSS files from all webpack entries.

Actual Behavior

Hot module replacement doesn’t work for all entries. Only files from the second entry are hot reloaded when changed. Files from the first entry do not get hot reloaded when changed.

For Bugs; How can we reproduce the behavior?

  1. Clone repro then yarn && yarn start
  2. Open http://localhost:8080/
  3. Change src/first.js and src/first.css - notice they are not hot reloaded
  4. Change src/second.js and src/second.css - notice they are hot reloaded

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:39
  • Comments:56 (16 by maintainers)

github_iconTop GitHub Comments

8reactions
MohsenElgendycommented, Nov 9, 2020

@slightlyfaulty setting optimization.runtimeChunk: "single" fixed the problem for me.

6reactions
slightlyfaultycommented, Mar 4, 2022

@khelkun I recently discovered that if you use the dependOn option for an entry, then it will use the runtime that’s embedded in the entry it depends on.

In this case you don’t need to use runtimeChunk: 'single' anymore, as long as the dependOn entry is always loaded first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack-dev-server HMR not working with multiple entry points
It seems like HMR has stopped working in my browser. Webpack is running and bundling it correctly! Any ideas? Thanks so far and...
Read more >
Developers - HMR not working with multiple entries - - Bountysource
After starting the dev server, hot module replacement should work for all JS and CSS files from all webpack entries. Actual Behavior. Hot...
Read more >
MiniCssExtractPlugin - webpack
Below is an example configuration of mini-css for HMR use with CSS modules. You should not use HotModuleReplacementPlugin plugin if you are using...
Read more >
Hot Module Replacement - SurviveJS
Doing this pushes the problem to the application side. Enabling HMR#. The following steps need to be enabled for HMR to work: The...
Read more >
Webpack's Hot Module Replacement Feature Explained
Even a small change in the CSS code will refresh the browser. The Hot Module Replacement (HMR) feature was created to solve the...
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