-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
Export React as Named Exports instead of CommonJS #18106
Commits on Feb 25, 2020
-
Add options for forked entry points
We currently fork .fb.js entry points. This adds a few more options. .modern.fb.js - experimental FB builds .classic.fb.js - stable FB builds .fb.js - if no other FB build, use this for FB builds .experimental.js - experimental builds .stable.js - stable builds .js - used if no other override exists This will be used to have different ES exports for different builds.
Configuration menu - View commit details
-
Copy full SHA for ed3d4c9 - Browse repository at this point
Copy the full SHA ed3d4c9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1355fc1 - Browse repository at this point
Copy the full SHA 1355fc1View commit details -
Export named exports from the export point itself
We need to re-export the Flow exported types so we can use them in our code. We don't want to use the Flow types from upstream since it doesn't have the non-public APIs that we have. This should be able to use export * but I don't know why it doesn't work. This actually enables Flow typing of React which was just "any" before. This exposed some Flow errors that needs fixing.
Configuration menu - View commit details
-
Copy full SHA for 6358b63 - Browse repository at this point
Copy the full SHA 6358b63View commit details -
Create forks for the react entrypoint
None of our builds expose all exports and they all differ in at least one way, so we need four forks.
Configuration menu - View commit details
-
Copy full SHA for c8bacfc - Browse repository at this point
Copy the full SHA c8bacfcView commit details -
We don't want to emit the esModule compatibility flag on our CommonJS output. For now we treat our named exports as if they're CommonJS. This is a potentially breaking change for scheduler (but all those apis are unstable), react-is and use-subscription. However, it seems unlikely that anyone would rely on this since these only have named exports.
Configuration menu - View commit details
-
Copy full SHA for 1f742ca - Browse repository at this point
Copy the full SHA 1f742caView commit details -
Configuration menu - View commit details
-
Copy full SHA for 981459e - Browse repository at this point
Copy the full SHA 981459eView commit details -
Let jest observe the stable fork for stable tests
This lets it do the negative test by ensuring that the right tests fail. However, this in turn will make other tests that are not behind __EXPERIMENTAL__ fail. So I need to do that next.
Configuration menu - View commit details
-
Copy full SHA for f2a2d11 - Browse repository at this point
Copy the full SHA f2a2d11View commit details -
Put all tests that depend on exports behind __EXPERIMENTAL__
Since there's no way to override the exports using feature flags in .intern.js anymore we can't use these APIs in stable. The tradeoff here is that we can either enable the negative tests on "stable" that means experimental are expected to fail, or we can disable tests on stable. This is unfortunate since some of these APIs now run on a "stable" config at FB instead of the experimental.
Configuration menu - View commit details
-
Copy full SHA for 77a16f2 - Browse repository at this point
Copy the full SHA 77a16f2View commit details -
Switch ReactDOM to named exports
Same strategy as React. I moved the ReactDOMFB runtime injection to classic.fb.js Since we only fork the entrypoint, the `/testing` entrypoint needs to be forked too to re-export the same things plus `act`. This is a bit unfortunate. If it becomes a pattern we can consider forking in the module resolution deeply. fix flow
Configuration menu - View commit details
-
Copy full SHA for a96f367 - Browse repository at this point
Copy the full SHA a96f367View commit details -
Now that ReactDOM is Flow type checked we need to fix up its types.
Configuration menu - View commit details
-
Copy full SHA for 90da135 - Browse repository at this point
Copy the full SHA 90da135View commit details -
Configuration menu - View commit details
-
Copy full SHA for 76b7e97 - Browse repository at this point
Copy the full SHA 76b7e97View commit details -
Remove additional FeatureFlags that are no longer needed
These are only flagging the exports and no implementation details so we can control them fully through the export overrides.
Configuration menu - View commit details
-
Copy full SHA for cb4ff7b - Browse repository at this point
Copy the full SHA cb4ff7bView commit details