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.

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:

image

and network panel

screen shot 2019-02-18 at 15 48 53

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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
yasin749commented, May 27, 2021

You can try to turn off code splitting in a local environment. new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),

2reactions
mathieux51commented, Feb 19, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

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