webpacker: Regression: Webpacker HMR causes SSR to fail in Webpacker 4+
https://github.com/reactjs/react-rails/issues/985
In webpacker 3 with HMR server side rendering worked for components marked “hot” In webpacker 4+
ExecJS::ProgramError in Adviser::AmlChecks#new
Showing app/views/welcome/index.html.erb where line #1 raised:
ReferenceError: window is not defined
(execjs):35:1
(execjs):24679:14
global ((execjs):1:102)
Object.<anonymous> ((execjs):1:120)
Module._compile (module.js:653:30)
Object.Module._extensions..js (module.js:664:10)
Module.load (module.js:566:32)
tryModuleLoad (module.js:506:12)
Function.Module._load (module.js:498:3)
Function.Module.runMain (module.js:694:10)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (13 by maintainers)
I’m having the same issue. I just update from webpacker 3.5 to 4 and having issue with window - ReferenceError: window is not defined
I’m going to be making a bunch of updates to react_on_rails very soon. We’ve got things working great with:
I’m not clear on why there’s a connection with SSR and HMR.
With React on Rails, SSR is done by either
I’ve never seen number 2, using the same bundle, in real production system as you can’t have animations, window, etc. used when rendering.
@jakeNiemiec I’m still running into this issue. I think either:
Starting in webpacker 4, something is referencing
window
without checking if it’s defined. I don’t have any idea where to look for that though.Webpack sense. Didn’t know about the other one, or always assumed they were the same.