Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let UIManager;
let FabricUIManager;

jest.mock('shared/ReactFeatureFlags', () =>
require('shared/forks/ReactFeatureFlags.native-fabric'),
require('shared/forks/ReactFeatureFlags.native-fabric-oss'),
);

describe('ReactFabric', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ReactFabric', () => {
ReactNative = require('react-native-renderer');
jest.resetModules();
jest.mock('shared/ReactFeatureFlags', () =>
require('shared/forks/ReactFeatureFlags.native-fabric'),
require('shared/forks/ReactFeatureFlags.native-fabric-oss'),
);

React = require('react');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import invariant from 'fbjs/lib/invariant';

import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric';
import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric-fb';

export const debugRenderPhaseSideEffects = false;
export const debugRenderPhaseSideEffectsForStrictMode = false;
Expand Down
37 changes: 37 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js
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>);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import invariant from 'fbjs/lib/invariant';

import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native';
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-fb';

// Re-export dynamic flags from the fbsource version.
export const {
Expand Down
35 changes: 35 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
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';

Copy link
Contributor Author

@bvaughn bvaughn Apr 18, 2018

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.

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;
Copy link
Contributor Author

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.


// 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>);
76 changes: 45 additions & 31 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '')
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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`;
}
}
Expand All @@ -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`;
}
}
Expand All @@ -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}`);
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Copy link
Contributor Author

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.

await Sync.syncReactNative(syncFBSourcePath);
} else if (syncWWWPath) {
await Sync.syncReactDom('build/facebook-www', syncWWWPath);
}
Expand Down
Loading