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
Fork React Native renderer into FB and OSS bundles #12625
Conversation
Details of bundled changes.Comparing: 039695c...d4baace react
react-dom
react-art
react-native-renderer
react-test-renderer
react-is
Generated by 🚫 dangerJS |
export const enablePersistentReconciler = false; | ||
export const enableUserTimingAPI = __DEV__; | ||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; | ||
export const warnAboutDeprecatedLifecycles = false; |
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.
Note this is turned off for open source builds.
scripts/rollup/packaging.js
Outdated
@@ -45,7 +47,15 @@ function getBundleOutputPaths(bundleType, filename, packageName) { | |||
case RN_PROD: | |||
switch (packageName) { | |||
case 'react-native-renderer': | |||
return [`build/react-native/${filename}`]; | |||
return [`build/react-native/oss/${filename}`]; |
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.
Things in the "oss" sub directory are blacklisted from FB configs in order to prevent Haste module conflicts. This added subdirectory should not impact open source builds though.
|
||
import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; | ||
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-oss'; | ||
|
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.
Note open source builds no longer depend on dynamic flags.
} | ||
|
||
await Packaging.copyAllShims(); | ||
await Packaging.prepareNpmPackages(); | ||
|
||
if (syncFBSourcePath) { | ||
await Sync.syncReactNative('build/react-native', syncFBSourcePath); | ||
await Sync.syncReactNativeRT('build/react-rt', syncFBSourcePath); | ||
await Sync.syncReactNativeCS('build/react-cs', syncFBSourcePath); |
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.
The react-rt/react-cs commands were no longer being used.
We should rename it to |
scripts/rollup/forks.js
Outdated
case RN_FB_PROD: | ||
return 'shared/forks/ReactFeatureFlags.native-fb.js'; | ||
default: | ||
return 'shared/forks/ReactFeatureFlags.native-oss.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.
Let's use specific cases and throw for default?
scripts/rollup/forks.js
Outdated
case RN_FB_PROD: | ||
return 'shared/forks/ReactFeatureFlags.native-fabric-fb.js'; | ||
default: | ||
return 'shared/forks/ReactFeatureFlags.native-fabric-oss.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.
Same
Yeah, good call. I almost did that earlier but was reluctant to introduce more churn. Done! |
* Added new "native-fb" and "native-fabric-fb" bundles. * Split RN_DEV and RN_PROD bundle types into RN_OSS_DEV, RN_OSS_PROD, RN_FB_DEV, and RN_FB_PROD. (This is a bit redundant but it seemed the least intrusive way of supporting a forked feature flags file for these bundles.) * Renamed FB_DEV and FB_PROD bundle types to be more explicitly for www (FB_WWW_DEV and FB_WWW_PROD) * Removed Haste @providesModule headers from the RB-specific RN renderer bundles to avoid a duplicate name conflicts. * Remove dynamic values from OSS RN feature flags. (Leave them in FB RN feature flags.) * Updated the sync script(s) to account for new renderer type. * Move ReactFeatureFlags.js shim to FB bundle only (since OSS bundle no longer needs dynamic values).
Fork React Native renderer bundle into separate OSS and FB builds. This is being done in order to minimize unintentional open source impact (e.g. facebook/react-native/issues/18175) and to provide a way for Facebook to test features in RN early, as we do for React DOM.
High level changes
RN_DEV
andRN_PROD
bundle types intoRN_OSS_DEV
,RN_OSS_PROD
,RN_FB_DEV
, andRN_FB_PROD
. (This is a bit redundant but it seemed the least intrusive way of supporting a forked feature flags file for these bundles.)FB_DEV
andFB_PROD
bundle types to be more explicitly for www (FB_WWW_DEV
andFB_WWW_PROD
)@providesModule
headers from the RB-specific RN renderer bundles to avoid a duplicate name conflicts.ReactFeatureFlags.js
shim to FB bundle only (since OSS bundle no longer needs dynamic values).This is the new structure of the built RN bundles:
Alternatives considered
FB_DEV
/FB_PROD
types to the "react-native" bundle, but this bundle type seems to have some www-specific assumptions built in. It seemed safer to add a new type ("XPLAT_*") that could more closely resemble the current RN bundle while still giving us the ability to fork the feature flags file.Testing
I build RN locally and synced to fbsource by running:
I compared the diff of the resulting bundles and verified they have only the changes I would expect:
require("ReactFeatureFlags")
)TODO
@providesModule
within fbsource so Facebook is not using that build.