Macil / browserify-hmr

Hot Module Replacement plugin for Browserify
MIT License
373 stars 26 forks source link

Error messages from react-hot-loader #47

Open jeremija opened 4 years ago

jeremija commented 4 years ago

The current example/ uses an old version of react-hot-loader which silently swallows require errors:

https://github.com/gaearon/react-hot-loader/blob/62f9ccdd076b26302dae077c23de3dd6812ebd97/src/hot.dev.js#L27-L31

The latest version of react-hot-loader always logs require errors:

https://github.com/gaearon/react-hot-loader/blob/3fadc05783f2aa534372dbe6846b1a379ed76ebd/src/hot.dev.js#L86-L93

Steps to reproduce:

https://github.com/Macil/browserify-hmr
cd browserify-hmr/example
npm install
npm install react-hot-loader@latest
npm start

After modifying Label.jsx, the component refreshes in the browser, but an error is present in browser console:

[HMR] Websocket connection successful. index.js:424
interval step 3 interval.js:8:10
[HMR] Updated modules 
Array [ "Label.jsx" ]
index.js:512
React-Hot-Loader: error detected while loading Label.jsx backend.js:6:2315
Error: "Cannot find module 'Label.jsx'"
    o _prelude.js:1
    o _prelude.js:1
    updateInstances react-hot-loader.development.js:3096
    runAll react-hot-loader.development.js:2998
    runAll react-hot-loader.development.js:2997
    runner react-hot-loader.development.js:2989
    promise react-hot-loader.development.js:3006
backend.js:6:2315
interval step 2 interval.js:8:10

It looks like the problem is the fact that browserify is converting module ids to numerical indexes, so the require('Label.jsx') call fails. I've also tried using --fullPaths, but that also fails because it would expect an absolute path to Label.jsx, not just Label.jsx.

The hot reload still seems to work, but I wonder if there's anything that could be done to fix this?