Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HMR not working #85

Closed
antonybudianto opened this issue May 15, 2018 · 16 comments
Closed

HMR not working #85

antonybudianto opened this issue May 15, 2018 · 16 comments
Labels

Comments

@antonybudianto
Copy link

antonybudianto commented May 15, 2018

Hi,

I'm doing SSR with HMR, when trying to change lazy loaded component, the HMR works on client side, but when I tried to refresh the page, the console is showing these errors:

loadable-components.es.js:93 Uncaught Error: loadable-components: module "./NotFoundPage-1" is not found, client and server modules are not sync. You are probably not using the same resolver on server and client.
    at loadable-components.es.js:93
    at Array.map (<anonymous>)
    at loadState (loadable-components.es.js:87)
    at loadComponents (loadable-components.es.js:118)
    at Object.<anonymous> (client.js:25)
    at Object../src/renderer/client.js (app.js:1413)
    at __webpack_require__ (bootstrap:772)
    at fn (bootstrap:141)
    at Object.0 (app.js:1982)
    at __webpack_require__ (bootstrap:772)

screen shot 2018-05-15 at 5 49 20 pm

How to Reproduce:

  1. Clone https://github.com/antonybudianto/react-ssr-starter
  2. npm i
  3. npm start
  4. Visit random 404 route (e.g http://localhost:3000/asdasd)
  5. Change src/routes/NotFoundPage/NotFoundPage.js
    • This route is lazy loaded
  6. Notice the hot reload should work
  7. Refresh the page
  8. Error shown

Any pointers will be helpful, thank you!

@olehreznichenko
Copy link

Have the same issue :(

@antonybudianto
Copy link
Author

antonybudianto commented May 16, 2018

My current workaround is:

// on server
loadableState.getScriptTag().replace(/-\d+(?=")/g, '')

The idea is to remove the ending dash with index ("./NotFoundPage-1" -> "./NotFoundPage"), and error is gone 😄

@gregberge
Copy link
Owner

Oh.. I know what is the problem, this is actually a real bug! Can you try to fix it?

@gregberge gregberge added the bug label May 17, 2018
@antonybudianto
Copy link
Author

Honestly I don't know where to start. Is it related to this file?
https://github.com/smooth-code/loadable-components/blob/master/src/componentTracker.js

@gregberge
Copy link
Owner

Yeah it could be pretty complicated, just let go for now. I will create an issue to describe the exact problem.

gregberge added a commit that referenced this issue May 23, 2018
gregberge added a commit that referenced this issue May 23, 2018
@antonybudianto
Copy link
Author

antonybudianto commented May 23, 2018

Hi,

I can confirm the latest release (2.2.1) fixed the issue, thanks @neoziro !

@ion-willo
Copy link

Sorry to add on an old issue but we're getting this again on 2.2.2. The problem is that happens randomly so it's very hard to reproduce. Once it happens, it keeps happening until the the server is restarted.

@antonybudianto
Copy link
Author

Just updated to 2.2.2 and it's happening again. Can you help? @neoziro

@antonybudianto antonybudianto reopened this Aug 2, 2018
@ahungrynoob
Copy link

ahungrynoob commented Sep 3, 2018

Have the same issue :(
When I import the same component in different routes, and try to reload from the server, it will appear.

loadable-components.es.js:105 Uncaught (in promise) Error: loadable-components: module "../../components/admin/publish-1" is not found, client and server modules are not sync. You are probably not using the same resolver on server and client.
    at eval (loadable-components.es.js:105)
    at Array.map (<anonymous>)
    at loadState (loadable-components.es.js:96)
    at loadComponents (loadable-components.es.js:130)
    at eval (index.jsx:427)
    at Object../client/pages/admin/index.jsx (admin.js:60)
    at __webpack_require__ (manifest.js:713)
    at fn (manifest.js:118)
    at eval (client:3)
    at Object.3 (admin.js:4283)

and the warning

loadable-components.es.js:101 loadable-component client modules: {../../components/admin/publish: ƒ, ../../components/admin/list: ƒ, ../../components/admin/publish2: ƒ, ../../components/admin/list2: ƒ}../../components/admin/list: ƒ LoadableComponent(props)../../components/admin/list2: ƒ LoadableComponent(props)../../components/admin/publish: ƒ LoadableComponent(props)../../components/admin/publish2: ƒ LoadableComponent(props)__proto__: Object
(anonymous) @ loadable-components.es.js:101
loadState @ loadable-components.es.js:96
loadComponents @ loadable-components.es.js:130
(anonymous) @ index.jsx:427
./client/pages/admin/index.jsx @ admin.js:60
__webpack_require__ @ manifest.js:713
fn @ manifest.js:118
(anonymous) @ client:3
3 @ admin.js:4283
__webpack_require__ @ manifest.js:713
webpackJsonpCallback @ manifest.js:26
(anonymous) @ admin.js:1
loadable-components.es.js:103 loadable-component server modules: {children: Array(1)}children: Array(1)0: {id: "../../components/admin/publish-1"}length: 1__proto__: Array(0)__proto__: Object

@jsauca
Copy link

jsauca commented Oct 26, 2018

I have the same issue and errors as above with version Loadable Components 2.2.3 and Webpack HMR.
I have used the temporary solution of @antonybudianto and it is seems to be working.

@gregberge
Copy link
Owner

HMR is not supported in the new version (I think @theKashey could have an idea to support it). I close it because it concerns loadable v2, feel free to reopen a new issue.

@mbrochh
Copy link

mbrochh commented Nov 1, 2018

@neoziro do I understand correctly that this problem will be solved in loadable v3, or even v4 (it seems you are working on v4 already?)

also, @antonybudianto 's solution doesn't seem to work for me. With this workaround, the issue seems to happen less frequently, but it still happens.

@gregberge
Copy link
Owner

HMR is supported in v4, but React Hot Loader is not supported.

@theKashey
Copy link
Collaborator

Not yet supported?

@gregberge
Copy link
Owner

React Hot Loader is maybe supported 😅

@gregberge gregberge reopened this Nov 10, 2018
@gregberge gregberge added bug and removed bug labels Nov 13, 2018
@gregberge
Copy link
Owner

I made a test using razzle. Everything is working as expected. If you experience any problem with Hot Reloading, please open a new issue.

This one was about v2.x, today v5 has been rewritten from scratch and has nothing in common with this issue.

Repository owner locked as off-topic and limited conversation to collaborators Nov 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants