You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using module-federation on localhost, this is not an issue as react is usually in dev. mode (both in the MFE and the host application)
However, when using module federation runtime where the host application is using react prod and the MFE is built on local, I have seen issues where React will crash.
For example, you might get:
Cannot read properties of undefined (reading 'getCurrentStack')
or
TypeError: Cannot read properties of undefined (reading 'getStackAddendum')
Ideally, I think react should allow for a different variable to switch between development and production? (e.g., checking for REACT_PROD === 'true' or NODE_ENV === 'production' - see also https://www.youtube.com/watch?v=HMM7GJC5E2o). I am not sure if such a change would be accepted though
Inject env. variables just for specific modules with rsbuild/rspack. Is this even possible, though?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For context, I am using https://rsbuild.dev/ with https://rsbuild.dev/config/module-federation/options and React plugin.
React is checking for
NODE_ENV === 'production'
use the dev or production version.https://github.com/search?q=repo%3Afacebook%2Freact+%22NODE_ENV+%3D%3D%3D+%27production%27%22&type=code
When using module-federation on localhost, this is not an issue as react is usually in dev. mode (both in the MFE and the host application)
However, when using module federation runtime where the host application is using react prod and the MFE is built on local, I have seen issues where React will crash.
For example, you might get:
or
(here is a similar example I found online: https://juejin.cn/post/7185140351303483450)
A workaround locally is to use
but this increases the build time.
Here are two ways to address this, I believe:
react
should allow for a different variable to switch between development and production? (e.g., checking forREACT_PROD === 'true'
orNODE_ENV === 'production'
- see also https://www.youtube.com/watch?v=HMM7GJC5E2o). I am not sure if such a change would be accepted thoughBeta Was this translation helpful? Give feedback.
All reactions