-
Notifications
You must be signed in to change notification settings - Fork 49.7k
Fork React Native renderer into FB and OSS bundles #12625
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
eb3e93f
Added FB RN bundle and feature flags
bvaughn 578af0e
Build FB RN renderer via a new XPLAT_* bundle type
bvaughn 843f3b9
Tweaked packaging and shims structure
bvaughn 21ecd31
Moved ReactFeatureFlags file to xplat shims
bvaughn a9e83f1
Moved shims around
bvaughn 01c4e0e
Moved internal dir to a whitelisted dir
bvaughn 4b75f3b
Fixed validation script
bvaughn 4864d1d
Prettier, damnit
bvaughn 588fa9b
Reorganized things to address a circular dependency within fbsource
bvaughn ab87a29
Removed redundant shims
bvaughn e6e1929
Updated validation script
bvaughn ac0265b
Reverted unnecessary Flow config entry
bvaughn 0784990
Fixed validation script to ignore shims
bvaughn 0169538
Removed @providesModule headers from FB RN bundle
bvaughn 6dfc6ae
Merge branch 'master' into fb-rn-bundle
bvaughn 2022ee9
Re-added Haste headers for now
bvaughn d147233
Renamed FB_* bundle types to FB_WWW_*
bvaughn d4baace
Removed Haste headers from FB renderer
bvaughn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * Copyright (c) 2013-present, Facebook, Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @flow | ||
| */ | ||
|
|
||
| import invariant from 'fbjs/lib/invariant'; | ||
|
|
||
| import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; | ||
| import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric-oss'; | ||
|
|
||
| export const debugRenderPhaseSideEffects = false; | ||
| export const debugRenderPhaseSideEffectsForStrictMode = false; | ||
| export const enableUserTimingAPI = __DEV__; | ||
| export const enableGetDerivedStateFromCatch = false; | ||
| export const warnAboutDeprecatedLifecycles = false; | ||
| export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; | ||
|
|
||
| // React Fabric uses persistent reconciler. | ||
| export const enableMutatingReconciler = false; | ||
| export const enableNoopReconciler = false; | ||
| export const enablePersistentReconciler = true; | ||
| export const alwaysUseRequestIdleCallbackPolyfill = false; | ||
|
|
||
| // Only used in www builds. | ||
| export function addUserTimingListener() { | ||
| invariant(false, 'Not implemented.'); | ||
| } | ||
|
|
||
| // Flow magic to verify the exports of this file match the original version. | ||
| // eslint-disable-next-line no-unused-vars | ||
| type Check<_X, Y: _X, X: Y = _X> = null; | ||
| // eslint-disable-next-line no-unused-expressions | ||
| (null: Check<FabricFeatureFlagsType, FeatureFlagsType>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /** | ||
| * Copyright (c) 2013-present, Facebook, Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @flow | ||
| */ | ||
|
|
||
| import invariant from 'fbjs/lib/invariant'; | ||
|
|
||
| import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; | ||
| import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-oss'; | ||
|
|
||
| export const alwaysUseRequestIdleCallbackPolyfill = false; | ||
| export const debugRenderPhaseSideEffects = false; | ||
| export const debugRenderPhaseSideEffectsForStrictMode = false; | ||
| export const enableGetDerivedStateFromCatch = false; | ||
| export const enableMutatingReconciler = true; | ||
| export const enableNoopReconciler = false; | ||
| 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 commentThe reason will be displayed to describe this comment to others. Learn more. Note this is turned off for open source builds. |
||
|
|
||
| // Only used in www builds. | ||
| export function addUserTimingListener() { | ||
| invariant(false, 'Not implemented.'); | ||
| } | ||
|
|
||
| // Flow magic to verify the exports of this file match the original version. | ||
| // eslint-disable-next-line no-unused-vars | ||
| type Check<_X, Y: _X, X: Y = _X> = null; | ||
| // eslint-disable-next-line no-unused-expressions | ||
| (null: Check<FeatureFlagsShimType, FeatureFlagsType>); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,10 +39,12 @@ const { | |
| UMD_PROD, | ||
| NODE_DEV, | ||
| NODE_PROD, | ||
| FB_DEV, | ||
| FB_PROD, | ||
| RN_DEV, | ||
| RN_PROD, | ||
| FB_WWW_DEV, | ||
| FB_WWW_PROD, | ||
| RN_OSS_DEV, | ||
| RN_OSS_PROD, | ||
| RN_FB_DEV, | ||
| RN_FB_PROD, | ||
| } = Bundles.bundleTypes; | ||
|
|
||
| const requestedBundleTypes = (argv.type || '') | ||
|
|
@@ -81,8 +83,8 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) { | |
| options = updateBabelOptions(options); | ||
| } | ||
| switch (bundleType) { | ||
| case FB_DEV: | ||
| case FB_PROD: | ||
| case FB_WWW_DEV: | ||
| case FB_WWW_PROD: | ||
| return Object.assign({}, options, { | ||
| plugins: options.plugins.concat([ | ||
| // Minify invariant messages | ||
|
|
@@ -91,8 +93,10 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) { | |
| require('../babel/wrap-warning-with-env-check'), | ||
| ]), | ||
| }); | ||
| case RN_DEV: | ||
| case RN_PROD: | ||
| case RN_OSS_DEV: | ||
| case RN_OSS_PROD: | ||
| case RN_FB_DEV: | ||
| case RN_FB_PROD: | ||
| return Object.assign({}, options, { | ||
| plugins: options.plugins.concat([ | ||
| // Wrap warning() calls in a __DEV__ check so they are stripped from production. | ||
|
|
@@ -139,10 +143,12 @@ function getFormat(bundleType) { | |
| return `umd`; | ||
| case NODE_DEV: | ||
| case NODE_PROD: | ||
| case FB_DEV: | ||
| case FB_PROD: | ||
| case RN_DEV: | ||
| case RN_PROD: | ||
| case FB_WWW_DEV: | ||
| case FB_WWW_PROD: | ||
| case RN_OSS_DEV: | ||
| case RN_OSS_PROD: | ||
| case RN_FB_DEV: | ||
| case RN_FB_PROD: | ||
| return `cjs`; | ||
| } | ||
| } | ||
|
|
@@ -159,11 +165,13 @@ function getFilename(name, globalName, bundleType) { | |
| return `${name}.development.js`; | ||
| case NODE_PROD: | ||
| return `${name}.production.min.js`; | ||
| case FB_DEV: | ||
| case RN_DEV: | ||
| case FB_WWW_DEV: | ||
| case RN_OSS_DEV: | ||
| case RN_FB_DEV: | ||
| return `${globalName}-dev.js`; | ||
| case FB_PROD: | ||
| case RN_PROD: | ||
| case FB_WWW_PROD: | ||
| case RN_OSS_PROD: | ||
| case RN_FB_PROD: | ||
| return `${globalName}-prod.js`; | ||
| } | ||
| } | ||
|
|
@@ -172,13 +180,15 @@ function isProductionBundleType(bundleType) { | |
| switch (bundleType) { | ||
| case UMD_DEV: | ||
| case NODE_DEV: | ||
| case FB_DEV: | ||
| case RN_DEV: | ||
| case FB_WWW_DEV: | ||
| case RN_OSS_DEV: | ||
| case RN_FB_DEV: | ||
| return false; | ||
| case UMD_PROD: | ||
| case NODE_PROD: | ||
| case FB_PROD: | ||
| case RN_PROD: | ||
| case FB_WWW_PROD: | ||
| case RN_OSS_PROD: | ||
| case RN_FB_PROD: | ||
| return true; | ||
| default: | ||
| throw new Error(`Unknown type: ${bundleType}`); | ||
|
|
@@ -200,8 +210,12 @@ function getPlugins( | |
| const forks = Modules.getForks(bundleType, entry); | ||
| const isProduction = isProductionBundleType(bundleType); | ||
| const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD; | ||
| const isFBBundle = bundleType === FB_DEV || bundleType === FB_PROD; | ||
| const isRNBundle = bundleType === RN_DEV || bundleType === RN_PROD; | ||
| const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD; | ||
| const isRNBundle = | ||
| bundleType === RN_OSS_DEV || | ||
| bundleType === RN_OSS_PROD || | ||
| bundleType === RN_FB_DEV || | ||
| bundleType === RN_FB_PROD; | ||
| const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput; | ||
| return [ | ||
| // Extract error codes from invariant() messages into a file. | ||
|
|
@@ -329,7 +343,7 @@ async function createBundle(bundle, bundleType) { | |
| const packageName = Packaging.getPackageName(bundle.entry); | ||
|
|
||
| let resolvedEntry = require.resolve(bundle.entry); | ||
| if (bundleType === FB_DEV || bundleType === FB_PROD) { | ||
| if (bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD) { | ||
| const resolvedFBEntry = resolvedEntry.replace('.js', '.fb.js'); | ||
| if (fs.existsSync(resolvedFBEntry)) { | ||
| resolvedEntry = resolvedFBEntry; | ||
|
|
@@ -379,7 +393,7 @@ async function createBundle(bundle, bundleType) { | |
| bundle.modulesToStub | ||
| ), | ||
| // We can't use getters in www. | ||
| legacy: bundleType === FB_DEV || bundleType === FB_PROD, | ||
| legacy: bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD, | ||
| }; | ||
| const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths( | ||
| bundleType, | ||
|
|
@@ -478,19 +492,19 @@ async function buildEverything() { | |
| await createBundle(bundle, UMD_PROD); | ||
| await createBundle(bundle, NODE_DEV); | ||
| await createBundle(bundle, NODE_PROD); | ||
| await createBundle(bundle, FB_DEV); | ||
| await createBundle(bundle, FB_PROD); | ||
| await createBundle(bundle, RN_DEV); | ||
| await createBundle(bundle, RN_PROD); | ||
| await createBundle(bundle, FB_WWW_DEV); | ||
| await createBundle(bundle, FB_WWW_PROD); | ||
| await createBundle(bundle, RN_OSS_DEV); | ||
| await createBundle(bundle, RN_OSS_PROD); | ||
| await createBundle(bundle, RN_FB_DEV); | ||
| await createBundle(bundle, RN_FB_PROD); | ||
| } | ||
|
|
||
| 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 commentThe reason will be displayed to describe this comment to others. Learn more. The react-rt/react-cs commands were no longer being used. |
||
| await Sync.syncReactNative(syncFBSourcePath); | ||
| } else if (syncWWWPath) { | ||
| await Sync.syncReactDom('build/facebook-www', syncWWWPath); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.