loadable-components breaks Hot Module Replacement (HMR)
See original GitHub issue🐛 Bug Report
HMR updates are not applied if components are imported with @loadable/component
. By not applied, I mean that in Chrome console panel:
and network panel
you can see the update is there, but it’s not reflected in the DOM.
To Reproduce
In the linked repo, make sure the first line is commented, and change the text in ./LoadableComponents
// import LoadableComponents from './LoadableComponents'
import loadable from '@loadable/component'
const LoadableComponents = loadable(() => import('./LoadableComponents'))
If you change the code like this:
import LoadableComponents from './LoadableComponents'
// import loadable from '@loadable/component'
// const LoadableComponents = loadable(() => import('./LoadableComponents'))
Everything works as expected.
Expected behavior
Code splitting should work with loadable-components.
Link repo
Run npx envinfo --system --binaries --npmPackages @loadable/component,@loadable/server,@loadable/webpack-plugin,@loadable/babel-plugin --markdown --clipboard
Paste the results here:
## System:
- OS: macOS High Sierra 10.13.6
- CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
- Memory: 2.71 GB / 16.00 GB
- Shell: 5.3 - /bin/zsh
## Binaries:
- Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
- Yarn: 1.13.0 - /usr/local/bin/yarn
- npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
- Watchman: 4.9.0 - /usr/local/bin/watchman
## npmPackages:
- @loadable/component: ^5.6.0 => 5.6.0
Nota bene
I’m happy to help.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:10 (2 by maintainers)
Top Results From Across the Web
loadable-components breaks Hot Module Replacement (HMR)
Loadable is yet class based and it's internal state would be lost on HMR, casing old tree to be remounted, new component be...
Read more >Hot Module Replacement - webpack
Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. It allows all kinds of modules to be...
Read more >Webpack's Hot Module Replacement Feature Explained
Hot Module Replacement is a feature that enables you to see code changes in the browser without having to refresh it, allowing you...
Read more >Hot Module Replacement (HMR) for a React App - Medium
First, we will see how it's incorporated into an app with some code, then I will explain how it works. Webpack HMR seems...
Read more >Hot Module Replacement - SurviveJS
Hot Module Replacement (HMR) builds on top of the WDS. It enables an interface that makes it possible to swap modules live. For...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can try to turn off code splitting in a local environment.
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
Thank you both for your help. I didn’t know adding multiple
hot
was an option, fixed my problem. I will update the link repo with the recommended solution.