@samitouri / QOS-React / commits / 0887c7d56c

Fork React Native renderer into FB and OSS bundles (#12625)

* 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).

Brian Vaughn committed Apr 18, 2018 at 13:16 UTC 0887c7d56cb9b83f36dcb490b4245d7bc33bda1f
14 files changed +349 -99
packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js
+1 -1
@@ -17,7 +17,7 @@ let UIManager;
17 let FabricUIManager;
18
19 jest.mock('shared/ReactFeatureFlags', () =>
20 - require('shared/forks/ReactFeatureFlags.native-fabric'),
20 + require('shared/forks/ReactFeatureFlags.native-fabric-oss'),
21 );
22
23 describe('ReactFabric', () => {
packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js
+1 -1
@@ -21,7 +21,7 @@ describe('ReactFabric', () => {
21 ReactNative = require('react-native-renderer');
22 jest.resetModules();
23 jest.mock('shared/ReactFeatureFlags', () =>
24 - require('shared/forks/ReactFeatureFlags.native-fabric'),
24 + require('shared/forks/ReactFeatureFlags.native-fabric-oss'),
25 );
26
27 React = require('react');
packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js renamed
+1 -1
@@ -10,7 +10,7 @@
10 import invariant from 'fbjs/lib/invariant';
11
12 import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
13 -import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric';
13 +import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric-fb';
14
15 export const debugRenderPhaseSideEffects = false;
16 export const debugRenderPhaseSideEffectsForStrictMode = false;
packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js new
+37
@@ -0,0 +1,37 @@
1 +/**
2 + * Copyright (c) 2013-present, Facebook, Inc.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import invariant from 'fbjs/lib/invariant';
11 +
12 +import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
13 +import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric-oss';
14 +
15 +export const debugRenderPhaseSideEffects = false;
16 +export const debugRenderPhaseSideEffectsForStrictMode = false;
17 +export const enableUserTimingAPI = __DEV__;
18 +export const enableGetDerivedStateFromCatch = false;
19 +export const warnAboutDeprecatedLifecycles = false;
20 +export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
21 +
22 +// React Fabric uses persistent reconciler.
23 +export const enableMutatingReconciler = false;
24 +export const enableNoopReconciler = false;
25 +export const enablePersistentReconciler = true;
26 +export const alwaysUseRequestIdleCallbackPolyfill = false;
27 +
28 +// Only used in www builds.
29 +export function addUserTimingListener() {
30 + invariant(false, 'Not implemented.');
31 +}
32 +
33 +// Flow magic to verify the exports of this file match the original version.
34 +// eslint-disable-next-line no-unused-vars
35 +type Check<_X, Y: _X, X: Y = _X> = null;
36 +// eslint-disable-next-line no-unused-expressions
37 +(null: Check<FabricFeatureFlagsType, FeatureFlagsType>);
packages/shared/forks/ReactFeatureFlags.native-fb.js renamed
+1 -1
@@ -10,7 +10,7 @@
10 import invariant from 'fbjs/lib/invariant';
11
12 import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
13 -import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native';
13 +import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-fb';
14
15 // Re-export dynamic flags from the fbsource version.
16 export const {
packages/shared/forks/ReactFeatureFlags.native-oss.js new
+35
@@ -0,0 +1,35 @@
1 +/**
2 + * Copyright (c) 2013-present, Facebook, Inc.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import invariant from 'fbjs/lib/invariant';
11 +
12 +import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
13 +import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-oss';
14 +
15 +export const alwaysUseRequestIdleCallbackPolyfill = false;
16 +export const debugRenderPhaseSideEffects = false;
17 +export const debugRenderPhaseSideEffectsForStrictMode = false;
18 +export const enableGetDerivedStateFromCatch = false;
19 +export const enableMutatingReconciler = true;
20 +export const enableNoopReconciler = false;
21 +export const enablePersistentReconciler = false;
22 +export const enableUserTimingAPI = __DEV__;
23 +export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
24 +export const warnAboutDeprecatedLifecycles = false;
25 +
26 +// Only used in www builds.
27 +export function addUserTimingListener() {
28 + invariant(false, 'Not implemented.');
29 +}
30 +
31 +// Flow magic to verify the exports of this file match the original version.
32 +// eslint-disable-next-line no-unused-vars
33 +type Check<_X, Y: _X, X: Y = _X> = null;
34 +// eslint-disable-next-line no-unused-expressions
35 +(null: Check<FeatureFlagsShimType, FeatureFlagsType>);
scripts/rollup/build.js
+45 -31
@@ -39,10 +39,12 @@ const {
39 UMD_PROD,
40 NODE_DEV,
41 NODE_PROD,
42 - FB_DEV,
43 - FB_PROD,
44 - RN_DEV,
45 - RN_PROD,
42 + FB_WWW_DEV,
43 + FB_WWW_PROD,
44 + RN_OSS_DEV,
45 + RN_OSS_PROD,
46 + RN_FB_DEV,
47 + RN_FB_PROD,
48 } = Bundles.bundleTypes;
49
50 const requestedBundleTypes = (argv.type || '')
@@ -81,8 +83,8 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
83 options = updateBabelOptions(options);
84 }
85 switch (bundleType) {
84 - case FB_DEV:
85 - case FB_PROD:
86 + case FB_WWW_DEV:
87 + case FB_WWW_PROD:
88 return Object.assign({}, options, {
89 plugins: options.plugins.concat([
90 // Minify invariant messages
@@ -91,8 +93,10 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
93 require('../babel/wrap-warning-with-env-check'),
94 ]),
95 });
94 - case RN_DEV:
95 - case RN_PROD:
96 + case RN_OSS_DEV:
97 + case RN_OSS_PROD:
98 + case RN_FB_DEV:
99 + case RN_FB_PROD:
100 return Object.assign({}, options, {
101 plugins: options.plugins.concat([
102 // Wrap warning() calls in a __DEV__ check so they are stripped from production.
@@ -139,10 +143,12 @@ function getFormat(bundleType) {
143 return `umd`;
144 case NODE_DEV:
145 case NODE_PROD:
142 - case FB_DEV:
143 - case FB_PROD:
144 - case RN_DEV:
145 - case RN_PROD:
146 + case FB_WWW_DEV:
147 + case FB_WWW_PROD:
148 + case RN_OSS_DEV:
149 + case RN_OSS_PROD:
150 + case RN_FB_DEV:
151 + case RN_FB_PROD:
152 return `cjs`;
153 }
154 }
@@ -159,11 +165,13 @@ function getFilename(name, globalName, bundleType) {
165 return `${name}.development.js`;
166 case NODE_PROD:
167 return `${name}.production.min.js`;
162 - case FB_DEV:
163 - case RN_DEV:
168 + case FB_WWW_DEV:
169 + case RN_OSS_DEV:
170 + case RN_FB_DEV:
171 return `${globalName}-dev.js`;
165 - case FB_PROD:
166 - case RN_PROD:
172 + case FB_WWW_PROD:
173 + case RN_OSS_PROD:
174 + case RN_FB_PROD:
175 return `${globalName}-prod.js`;
176 }
177 }
@@ -172,13 +180,15 @@ function isProductionBundleType(bundleType) {
180 switch (bundleType) {
181 case UMD_DEV:
182 case NODE_DEV:
175 - case FB_DEV:
176 - case RN_DEV:
183 + case FB_WWW_DEV:
184 + case RN_OSS_DEV:
185 + case RN_FB_DEV:
186 return false;
187 case UMD_PROD:
188 case NODE_PROD:
180 - case FB_PROD:
181 - case RN_PROD:
189 + case FB_WWW_PROD:
190 + case RN_OSS_PROD:
191 + case RN_FB_PROD:
192 return true;
193 default:
194 throw new Error(`Unknown type: ${bundleType}`);
@@ -200,8 +210,12 @@ function getPlugins(
210 const forks = Modules.getForks(bundleType, entry);
211 const isProduction = isProductionBundleType(bundleType);
212 const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD;
203 - const isFBBundle = bundleType === FB_DEV || bundleType === FB_PROD;
204 - const isRNBundle = bundleType === RN_DEV || bundleType === RN_PROD;
213 + const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD;
214 + const isRNBundle =
215 + bundleType === RN_OSS_DEV ||
216 + bundleType === RN_OSS_PROD ||
217 + bundleType === RN_FB_DEV ||
218 + bundleType === RN_FB_PROD;
219 const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput;
220 return [
221 // Extract error codes from invariant() messages into a file.
@@ -329,7 +343,7 @@ async function createBundle(bundle, bundleType) {
343 const packageName = Packaging.getPackageName(bundle.entry);
344
345 let resolvedEntry = require.resolve(bundle.entry);
332 - if (bundleType === FB_DEV || bundleType === FB_PROD) {
346 + if (bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD) {
347 const resolvedFBEntry = resolvedEntry.replace('.js', '.fb.js');
348 if (fs.existsSync(resolvedFBEntry)) {
349 resolvedEntry = resolvedFBEntry;
@@ -379,7 +393,7 @@ async function createBundle(bundle, bundleType) {
393 bundle.modulesToStub
394 ),
395 // We can't use getters in www.
382 - legacy: bundleType === FB_DEV || bundleType === FB_PROD,
396 + legacy: bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD,
397 };
398 const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths(
399 bundleType,
@@ -478,19 +492,19 @@ async function buildEverything() {
492 await createBundle(bundle, UMD_PROD);
493 await createBundle(bundle, NODE_DEV);
494 await createBundle(bundle, NODE_PROD);
481 - await createBundle(bundle, FB_DEV);
482 - await createBundle(bundle, FB_PROD);
483 - await createBundle(bundle, RN_DEV);
484 - await createBundle(bundle, RN_PROD);
495 + await createBundle(bundle, FB_WWW_DEV);
496 + await createBundle(bundle, FB_WWW_PROD);
497 + await createBundle(bundle, RN_OSS_DEV);
498 + await createBundle(bundle, RN_OSS_PROD);
499 + await createBundle(bundle, RN_FB_DEV);
500 + await createBundle(bundle, RN_FB_PROD);
501 }
502
503 await Packaging.copyAllShims();
504 await Packaging.prepareNpmPackages();
505
506 if (syncFBSourcePath) {
491 - await Sync.syncReactNative('build/react-native', syncFBSourcePath);
492 - await Sync.syncReactNativeRT('build/react-rt', syncFBSourcePath);
493 - await Sync.syncReactNativeCS('build/react-cs', syncFBSourcePath);
507 + await Sync.syncReactNative(syncFBSourcePath);
508 } else if (syncWWWPath) {
509 await Sync.syncReactDom('build/facebook-www', syncWWWPath);
510 }
scripts/rollup/bundles.js
+106 -19
@@ -5,20 +5,24 @@ const bundleTypes = {
5 UMD_PROD: 'UMD_PROD',
6 NODE_DEV: 'NODE_DEV',
7 NODE_PROD: 'NODE_PROD',
8 - FB_DEV: 'FB_DEV',
9 - FB_PROD: 'FB_PROD',
10 - RN_DEV: 'RN_DEV',
11 - RN_PROD: 'RN_PROD',
8 + FB_WWW_DEV: 'FB_WWW_DEV',
9 + FB_WWW_PROD: 'FB_WWW_PROD',
10 + RN_OSS_DEV: 'RN_OSS_DEV',
11 + RN_OSS_PROD: 'RN_OSS_PROD',
12 + RN_FB_DEV: 'RN_FB_DEV',
13 + RN_FB_PROD: 'RN_FB_PROD',
14 };
15
16 const UMD_DEV = bundleTypes.UMD_DEV;
17 const UMD_PROD = bundleTypes.UMD_PROD;
18 const NODE_DEV = bundleTypes.NODE_DEV;
19 const NODE_PROD = bundleTypes.NODE_PROD;
18 -const FB_DEV = bundleTypes.FB_DEV;
19 -const FB_PROD = bundleTypes.FB_PROD;
20 -const RN_DEV = bundleTypes.RN_DEV;
21 -const RN_PROD = bundleTypes.RN_PROD;
20 +const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
21 +const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
22 +const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
23 +const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
24 +const RN_FB_DEV = bundleTypes.RN_FB_DEV;
25 +const RN_FB_PROD = bundleTypes.RN_FB_PROD;
26
27 const moduleTypes = {
28 ISOMORPHIC: 'ISOMORPHIC',
@@ -40,7 +44,14 @@ const bundles = [
44 /******* Isomorphic *******/
45 {
46 label: 'core',
43 - bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
47 + bundleTypes: [
48 + UMD_DEV,
49 + UMD_PROD,
50 + NODE_DEV,
51 + NODE_PROD,
52 + FB_WWW_DEV,
53 + FB_WWW_PROD,
54 + ],
55 moduleType: ISOMORPHIC,
56 entry: 'react',
57 global: 'React',
@@ -50,7 +61,14 @@ const bundles = [
61 /******* React DOM *******/
62 {
63 label: 'dom-client',
53 - bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
64 + bundleTypes: [
65 + UMD_DEV,
66 + UMD_PROD,
67 + NODE_DEV,
68 + NODE_PROD,
69 + FB_WWW_DEV,
70 + FB_WWW_PROD,
71 + ],
72 moduleType: RENDERER,
73 entry: 'react-dom',
74 global: 'ReactDOM',
@@ -61,7 +79,7 @@ const bundles = [
79 {
80 label: 'dom-test-utils',
81 moduleType: RENDERER_UTILS,
64 - bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
82 + bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
83 entry: 'react-dom/test-utils',
84 global: 'ReactTestUtils',
85 externals: ['react', 'react-dom'],
@@ -70,7 +88,14 @@ const bundles = [
88 /* React DOM internals required for react-native-web (e.g., to shim native events from react-dom) */
89 {
90 label: 'dom-unstable-native-dependencies',
73 - bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
91 + bundleTypes: [
92 + UMD_DEV,
93 + UMD_PROD,
94 + NODE_DEV,
95 + NODE_PROD,
96 + FB_WWW_DEV,
97 + FB_WWW_PROD,
98 + ],
99 moduleType: RENDERER_UTILS,
100 entry: 'react-dom/unstable-native-dependencies',
101 global: 'ReactDOMUnstableNativeDependencies',
@@ -80,7 +105,14 @@ const bundles = [
105 /******* React DOM Server *******/
106 {
107 label: 'dom-server-browser',
83 - bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
108 + bundleTypes: [
109 + UMD_DEV,
110 + UMD_PROD,
111 + NODE_DEV,
112 + NODE_PROD,
113 + FB_WWW_DEV,
114 + FB_WWW_PROD,
115 + ],
116 moduleType: RENDERER,
117 entry: 'react-dom/server.browser',
118 global: 'ReactDOMServer',
@@ -98,7 +130,14 @@ const bundles = [
130 /******* React ART *******/
131 {
132 label: 'art',
101 - bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD],
133 + bundleTypes: [
134 + UMD_DEV,
135 + UMD_PROD,
136 + NODE_DEV,
137 + NODE_PROD,
138 + FB_WWW_DEV,
139 + FB_WWW_PROD,
140 + ],
141 moduleType: RENDERER,
142 entry: 'react-art',
143 global: 'ReactART',
@@ -111,9 +150,29 @@ const bundles = [
150 },
151
152 /******* React Native *******/
153 + {
154 + label: 'native-fb',
155 + bundleTypes: [RN_FB_DEV, RN_FB_PROD],
156 + moduleType: RENDERER,
157 + entry: 'react-native-renderer',
158 + global: 'ReactNativeRenderer',
159 + externals: [
160 + 'ExceptionsManager',
161 + 'InitializeCore',
162 + 'Platform',
163 + 'RCTEventEmitter',
164 + 'TextInputState',
165 + 'UIManager',
166 + 'deepDiffer',
167 + 'deepFreezeAndThrowOnMutationInDev',
168 + 'flattenStyle',
169 + 'ReactNativeViewConfigRegistry',
170 + ],
171 + },
172 +
173 {
174 label: 'native',
116 - bundleTypes: [RN_DEV, RN_PROD],
175 + bundleTypes: [RN_OSS_DEV, RN_OSS_PROD],
176 moduleType: RENDERER,
177 entry: 'react-native-renderer',
178 global: 'ReactNativeRenderer',
@@ -132,9 +191,30 @@ const bundles = [
191 },
192
193 /******* React Native Fabric *******/
194 + {
195 + label: 'native-fabric-fb',
196 + bundleTypes: [RN_FB_DEV, RN_FB_PROD],
197 + moduleType: RENDERER,
198 + entry: 'react-native-renderer/fabric',
199 + global: 'ReactFabric',
200 + externals: [
201 + 'ExceptionsManager',
202 + 'InitializeCore',
203 + 'Platform',
204 + 'RCTEventEmitter',
205 + 'TextInputState',
206 + 'UIManager',
207 + 'FabricUIManager',
208 + 'deepDiffer',
209 + 'deepFreezeAndThrowOnMutationInDev',
210 + 'flattenStyle',
211 + 'ReactNativeViewConfigRegistry',
212 + ],
213 + },
214 +
215 {
216 label: 'native-fabric',
137 - bundleTypes: [RN_DEV, RN_PROD],
217 + bundleTypes: [RN_OSS_DEV, RN_OSS_PROD],
218 moduleType: RENDERER,
219 entry: 'react-native-renderer/fabric',
220 global: 'ReactFabric',
@@ -156,7 +236,7 @@ const bundles = [
236 /******* React Test Renderer *******/
237 {
238 label: 'test',
159 - bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
239 + bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
240 moduleType: RENDERER,
241 entry: 'react-test-renderer',
242 global: 'ReactTestRenderer',
@@ -165,7 +245,7 @@ const bundles = [
245
246 {
247 label: 'test-shallow',
168 - bundleTypes: [FB_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
248 + bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
249 moduleType: RENDERER,
250 entry: 'react-test-renderer/shallow',
251 global: 'ReactShallowRenderer',
@@ -238,7 +318,14 @@ const bundles = [
318 /******* React Is *******/
319 {
320 label: 'react-is',
241 - bundleTypes: [NODE_DEV, NODE_PROD, FB_DEV, FB_PROD, UMD_DEV, UMD_PROD],
321 + bundleTypes: [
322 + NODE_DEV,
323 + NODE_PROD,
324 + FB_WWW_DEV,
325 + FB_WWW_PROD,
326 + UMD_DEV,
327 + UMD_PROD,
328 + ],
329 moduleType: ISOMORPHIC,
330 entry: 'react-is',
331 global: 'ReactIs',
scripts/rollup/forks.js
+46 -20
@@ -4,10 +4,12 @@ const bundleTypes = require('./bundles').bundleTypes;
4
5 const UMD_DEV = bundleTypes.UMD_DEV;
6 const UMD_PROD = bundleTypes.UMD_PROD;
7 -const FB_DEV = bundleTypes.FB_DEV;
8 -const FB_PROD = bundleTypes.FB_PROD;
9 -const RN_DEV = bundleTypes.RN_DEV;
10 -const RN_PROD = bundleTypes.RN_PROD;
7 +const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
8 +const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
9 +const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
10 +const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
11 +const RN_FB_DEV = bundleTypes.RN_FB_DEV;
12 +const RN_FB_PROD = bundleTypes.RN_FB_PROD;
13
14 // If you need to replace a file with another file for a specific environment,
15 // add it to this list with the logic for choosing the right replacement.
@@ -33,17 +35,39 @@ const forks = Object.freeze({
35 'shared/ReactFeatureFlags': (bundleType, entry) => {
36 switch (entry) {
37 case 'react-native-renderer':
36 - return 'shared/forks/ReactFeatureFlags.native.js';
38 + switch (bundleType) {
39 + case RN_FB_DEV:
40 + case RN_FB_PROD:
41 + return 'shared/forks/ReactFeatureFlags.native-fb.js';
42 + case RN_OSS_DEV:
43 + case RN_OSS_PROD:
44 + return 'shared/forks/ReactFeatureFlags.native-oss.js';
45 + default:
46 + throw Error(
47 + `Unexpected entry (${entry}) and bundleType (${bundleType})`
48 + );
49 + }
50 case 'react-native-renderer/fabric':
38 - return 'shared/forks/ReactFeatureFlags.native-fabric.js';
51 + switch (bundleType) {
52 + case RN_FB_DEV:
53 + case RN_FB_PROD:
54 + return 'shared/forks/ReactFeatureFlags.native-fabric-fb.js';
55 + case RN_OSS_DEV:
56 + case RN_OSS_PROD:
57 + return 'shared/forks/ReactFeatureFlags.native-fabric-oss.js';
58 + default:
59 + throw Error(
60 + `Unexpected entry (${entry}) and bundleType (${bundleType})`
61 + );
62 + }
63 case 'react-reconciler/persistent':
64 return 'shared/forks/ReactFeatureFlags.persistent.js';
65 case 'react-test-renderer':
66 return 'shared/forks/ReactFeatureFlags.test-renderer.js';
67 default:
68 switch (bundleType) {
45 - case FB_DEV:
46 - case FB_PROD:
69 + case FB_WWW_DEV:
70 + case FB_WWW_PROD:
71 return 'shared/forks/ReactFeatureFlags.www.js';
72 }
73 }
@@ -53,8 +77,8 @@ const forks = Object.freeze({
77 // This logic is forked on www to blacklist warnings.
78 'shared/lowPriorityWarning': (bundleType, entry) => {
79 switch (bundleType) {
56 - case FB_DEV:
57 - case FB_PROD:
80 + case FB_WWW_DEV:
81 + case FB_WWW_PROD:
82 return 'shared/forks/lowPriorityWarning.www.js';
83 default:
84 return null;
@@ -65,8 +89,8 @@ const forks = Object.freeze({
89 // See the explanation in FB version of ReactCurrentOwner in www:
90 'react/src/ReactCurrentOwner': (bundleType, entry) => {
91 switch (bundleType) {
68 - case FB_DEV:
69 - case FB_PROD:
92 + case FB_WWW_DEV:
93 + case FB_WWW_PROD:
94 return 'react/src/forks/ReactCurrentOwner.www.js';
95 default:
96 return null;
@@ -76,8 +100,8 @@ const forks = Object.freeze({
100 // Different wrapping/reporting for caught errors.
101 'shared/invokeGuardedCallback': (bundleType, entry) => {
102 switch (bundleType) {
79 - case FB_DEV:
80 - case FB_PROD:
103 + case FB_WWW_DEV:
104 + case FB_WWW_PROD:
105 return 'shared/forks/invokeGuardedCallback.www.js';
106 default:
107 return null;
@@ -87,12 +111,14 @@ const forks = Object.freeze({
111 // Different dialogs for caught errors.
112 'react-reconciler/src/ReactFiberErrorDialog': (bundleType, entry) => {
113 switch (bundleType) {
90 - case FB_DEV:
91 - case FB_PROD:
114 + case FB_WWW_DEV:
115 + case FB_WWW_PROD:
116 // Use the www fork which shows an error dialog.
117 return 'react-reconciler/src/forks/ReactFiberErrorDialog.www.js';
94 - case RN_DEV:
95 - case RN_PROD:
118 + case RN_OSS_DEV:
119 + case RN_OSS_PROD:
120 + case RN_FB_DEV:
121 + case RN_FB_PROD:
122 switch (entry) {
123 case 'react-native-renderer':
124 // Use the RN fork which plays well with redbox.
@@ -108,8 +134,8 @@ const forks = Object.freeze({
134 // We wrap top-level listeners into guards on www.
135 'react-dom/src/events/EventListener': (bundleType, entry) => {
136 switch (bundleType) {
111 - case FB_DEV:
112 - case FB_PROD:
137 + case FB_WWW_DEV:
138 + case FB_WWW_PROD:
139 // Use the www fork which is integrated with TimeSlice profiling.
140 return 'react-dom/src/events/forks/EventListener-www.js';
141 default:
scripts/rollup/packaging.js
+20 -9
@@ -14,10 +14,12 @@ const {
14 UMD_PROD,
15 NODE_DEV,
16 NODE_PROD,
17 - FB_DEV,
18 - FB_PROD,
19 - RN_DEV,
20 - RN_PROD,
17 + FB_WWW_DEV,
18 + FB_WWW_PROD,
19 + RN_OSS_DEV,
20 + RN_OSS_PROD,
21 + RN_FB_DEV,
22 + RN_FB_PROD,
23 } = Bundles.bundleTypes;
24
25 function getPackageName(name) {
@@ -38,14 +40,22 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
40 `build/node_modules/${packageName}/umd/${filename}`,
41 `build/dist/${filename}`,
42 ];
41 - case FB_DEV:
42 - case FB_PROD:
43 + case FB_WWW_DEV:
44 + case FB_WWW_PROD:
45 return [`build/facebook-www/${filename}`];
44 - case RN_DEV:
45 - case RN_PROD:
46 + case RN_OSS_DEV:
47 + case RN_OSS_PROD:
48 switch (packageName) {
49 case 'react-native-renderer':
48 - return [`build/react-native/${filename}`];
50 + return [`build/react-native/oss/${filename}`];
51 + default:
52 + throw new Error('Unknown RN package.');
53 + }
54 + case RN_FB_DEV:
55 + case RN_FB_PROD:
56 + switch (packageName) {
57 + case 'react-native-renderer':
58 + return [`build/react-native/fb/${filename}`];
59 default:
60 throw new Error('Unknown RN package.');
61 }
@@ -73,6 +83,7 @@ async function copyRNShims() {
83 require.resolve('react-native-renderer/src/ReactNativeTypes.js'),
84 'build/react-native/shims/ReactNativeTypes.js'
85 ),
86 + asyncCopyTo(`${__dirname}/shims/react-native-fb`, 'build/react-native/fb'),
87 ]);
88 }
89
scripts/rollup/shims/react-native-fb/ReactFeatureFlags.js renamed
scripts/rollup/sync.js
+7 -3
@@ -6,7 +6,7 @@ const resolvePath = require('./utils').resolvePath;
6
7 const DEFAULT_FB_SOURCE_PATH = '~/fbsource/';
8 const DEFAULT_WWW_PATH = '~/www/';
9 -const RELATIVE_RN_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
9 +const RELATIVE_RN_OSS_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
10 const RELATIVE_WWW_PATH = 'html/shared/react/';
11
12 async function doSync(buildPath, destPath) {
@@ -43,8 +43,12 @@ async function syncReactNativeHelper(
43 await doSync(buildPath, destPath);
44 }
45
46 -async function syncReactNative(buildPath, fbSourcePath) {
47 - await syncReactNativeHelper(buildPath, fbSourcePath, RELATIVE_RN_PATH);
46 +async function syncReactNative(fbSourcePath) {
47 + await syncReactNativeHelper(
48 + 'build/react-native',
49 + fbSourcePath,
50 + RELATIVE_RN_OSS_PATH
51 + );
52 }
53
54 module.exports = {
scripts/rollup/validate/index.js
+5 -1
@@ -60,7 +60,11 @@ const bundles = [
60 },
61 {
62 format: 'rn',
63 - filePatterns: [`./build/{react-cs,react-native,react-rt}/*.js`],
63 + filePatterns: [
64 + `./build/react-native/oss/*.js`,
65 + `./build/react-native/fb/ReactFabric-*.js`,
66 + `./build/react-native/fb/ReactNativeRenderer-*.js`,
67 + ],
68 },
69 {
70 format: 'umd',
scripts/rollup/wrappers.js
+44 -12
@@ -7,10 +7,12 @@ const UMD_DEV = Bundles.bundleTypes.UMD_DEV;
7 const UMD_PROD = Bundles.bundleTypes.UMD_PROD;
8 const NODE_DEV = Bundles.bundleTypes.NODE_DEV;
9 const NODE_PROD = Bundles.bundleTypes.NODE_PROD;
10 -const FB_DEV = Bundles.bundleTypes.FB_DEV;
11 -const FB_PROD = Bundles.bundleTypes.FB_PROD;
12 -const RN_DEV = Bundles.bundleTypes.RN_DEV;
13 -const RN_PROD = Bundles.bundleTypes.RN_PROD;
10 +const FB_WWW_DEV = Bundles.bundleTypes.FB_WWW_DEV;
11 +const FB_WWW_PROD = Bundles.bundleTypes.FB_WWW_PROD;
12 +const RN_OSS_DEV = Bundles.bundleTypes.RN_OSS_DEV;
13 +const RN_OSS_PROD = Bundles.bundleTypes.RN_OSS_PROD;
14 +const RN_FB_DEV = Bundles.bundleTypes.RN_FB_DEV;
15 +const RN_FB_PROD = Bundles.bundleTypes.RN_FB_PROD;
16
17 const RECONCILER = Bundles.moduleTypes.RECONCILER;
18
@@ -87,8 +89,8 @@ ${
89 ${source}`;
90 },
91
90 - /****************** FB_DEV ******************/
91 - [FB_DEV](source, globalName, filename, moduleType) {
92 + /****************** FB_WWW_DEV ******************/
93 + [FB_WWW_DEV](source, globalName, filename, moduleType) {
94 return `/**
95 ${license}
96 *
@@ -106,8 +108,8 @@ ${source}
108 }`;
109 },
110
109 - /****************** FB_PROD ******************/
110 - [FB_PROD](source, globalName, filename, moduleType) {
111 + /****************** FB_WWW_PROD ******************/
112 + [FB_WWW_PROD](source, globalName, filename, moduleType) {
113 return `/**
114 ${license}
115 *
@@ -119,8 +121,8 @@ ${license}
121 ${source}`;
122 },
123
122 - /****************** RN_DEV ******************/
123 - [RN_DEV](source, globalName, filename, moduleType) {
124 + /****************** RN_OSS_DEV ******************/
125 + [RN_OSS_DEV](source, globalName, filename, moduleType) {
126 return `/**
127 ${license}
128 *
@@ -138,8 +140,8 @@ ${source}
140 }`;
141 },
142
141 - /****************** RN_DEV ******************/
142 - [RN_PROD](source, globalName, filename, moduleType) {
143 + /****************** RN_OSS_PROD ******************/
144 + [RN_OSS_PROD](source, globalName, filename, moduleType) {
145 return `/**
146 ${license}
147 *
@@ -148,6 +150,36 @@ ${license}
150 * @preventMunge
151 */
152
153 +${source}`;
154 + },
155 +
156 + /****************** RN_FB_DEV ******************/
157 + [RN_FB_DEV](source, globalName, filename, moduleType) {
158 + return `/**
159 +${license}
160 + *
161 + * @noflow
162 + * @preventMunge
163 + */
164 +
165 +'use strict';
166 +
167 +if (__DEV__) {
168 + (function() {
169 +${source}
170 + })();
171 +}`;
172 + },
173 +
174 + /****************** RN_FB_PROD ******************/
175 + [RN_FB_PROD](source, globalName, filename, moduleType) {
176 + return `/**
177 +${license}
178 + *
179 + * @noflow
180 + * @preventMunge
181 + */
182 +
183 ${source}`;
184 },
185 };