-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Standardize condition order so that edge-lite preferred over browser #29877
Conversation
The export maps for react packages have to choose an order of preference. Many runtimes use multiple conditions, for instance when building for edge webpack also uses the browser condition which makes sense given most edge runtimes have a web-standards based set of APIs. However React is building the browser builds primarily for actual browsers and sometimes have builds intended for servers that might be browser compat. This change updates the order of conditions to preference specific named runtimes > node > generic edge runtimes > browser > default
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
"node": "./server.node.js", | ||
"edge-light": "./server.edge.js", | ||
"browser": "./server.browser.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to add one concern: this makes it very hard to use the actual browser build in tests when e.g. running the node test runner - node
always runs with the node
condition, and there can only be additional ones added, but node
itself cannot be removed.
So previously it was possible to run the browser build of React in a node testing environment with --condition=browser
, and after this it will be impossible.
I'm gonna say: I'm not sure if it's relevant, but I wanted to add the thought to the conversation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the solution is to use mocking like
jest.mock('react-dom/server', () => require('react-dom/server.browser'))
Comparing: f3e09d6...d220f69 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
The export maps for react packages have to choose an order of preference. Many runtimes use multiple conditions, for instance when building for edge webpack also uses the browser condition which makes sense given most edge runtimes have a web-standards based set of APIs. However React is building the browser builds primarily for actual browsers and sometimes have builds intended for servers that might be browser compat. This change updates the order of conditions to preference specific named runtimes > node > generic edge runtimes > browser > default