-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
createReactContext breaks with Webpack 5 & relay-hooks 5.x (ESM) #194
Comments
Hi @cedrickring, Thanks |
I've got this too. just blew up my site in prod |
@cedrickring rolling back to 4.2.0 fixed it for me. |
The problem is caused by the version 5.x of webpack (not in version 4), in practice for this type of import webpack enter here https://github.com/webpack/webpack/blob/main/lib/RuntimeTemplate.js#L775-L788 and the react variable is saved in another variable managed by webpack. I tried replacing that piece of code with return I'd like to hear from a Webpack maintainer (@sokra) and / or open an issue in their repository.
This problem is present in relay-hooks version 5.x as ESM support has been added |
Version 5.0.1 released which resolves this issue. @stan-sack @cedrickring let me know if there are other problems or if it works so I proceed to close the issue 👍 |
Works great! I'll close this issue as #195 fixed this issue 👍🏽 |
The fake namespace object is needed for CommonJs-ESM-interop. React is a commonjs module, but But you are right webpack doesn't behaves fully spec-complient here. Calling Fixing that in webpack would be a bit more involved, since we probably have to cache the namespace object somewhere globally (probably in the module object)... |
Hi @sokra,
I understand you, thinking about everything is almost impossible, luckily some problems have simple solutions :) |
For some reason, webpack introduced a "fake namespace object" which is provided first to
createReactContext
. When the actual module is loaded, the real react object will be passed tocreateReactContext
resulting in the invariant failing here.I don't really know how to provide a workaround for that.
The text was updated successfully, but these errors were encountered: