Add PROFILE bundles for www+DOM and fbsource+RN/RF (#13112)
This commit is contained in:
parent
71a60ddb16
commit
6d6de6011c
|
@ -20,7 +20,7 @@ export const enableSuspense = false;
|
|||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const warnAboutLegacyContextAPI = __DEV__;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const enableProfilerTimer = __DEV__;
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
// Only used in www builds.
|
||||
export function addUserTimingListener() {
|
||||
|
|
|
@ -20,12 +20,12 @@ export const {
|
|||
debugRenderPhaseSideEffectsForStrictMode,
|
||||
warnAboutDeprecatedLifecycles,
|
||||
replayFailedUnitOfWorkWithInvokeGuardedCallback,
|
||||
enableProfilerTimer,
|
||||
} = require('ReactFeatureFlags');
|
||||
|
||||
// The rest of the flags are static for better dead code elimination.
|
||||
export const enableUserTimingAPI = __DEV__;
|
||||
export const warnAboutLegacyContextAPI = __DEV__;
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
// Only used in www builds.
|
||||
export function addUserTimingListener() {
|
||||
|
|
|
@ -20,7 +20,7 @@ export const enableSuspense = false;
|
|||
export const warnAboutDeprecatedLifecycles = false;
|
||||
export const warnAboutLegacyContextAPI = false;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const enableProfilerTimer = false;
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
// Only used in www builds.
|
||||
export function addUserTimingListener() {
|
||||
|
|
|
@ -18,7 +18,6 @@ export const {
|
|||
enableGetDerivedStateFromCatch,
|
||||
replayFailedUnitOfWorkWithInvokeGuardedCallback,
|
||||
warnAboutDeprecatedLifecycles,
|
||||
enableProfilerTimer,
|
||||
} = require('ReactFeatureFlags');
|
||||
|
||||
// The rest of the flags are static for better dead code elimination.
|
||||
|
@ -32,6 +31,8 @@ export const warnAboutLegacyContextAPI = __DEV__;
|
|||
// as long as there is more than a single listener.
|
||||
export let enableUserTimingAPI = __DEV__;
|
||||
|
||||
export const enableProfilerTimer = __PROFILE__;
|
||||
|
||||
let refCount = 0;
|
||||
export function addUserTimingListener() {
|
||||
if (__DEV__) {
|
||||
|
|
|
@ -42,11 +42,13 @@ const {
|
|||
NODE_PROFILING,
|
||||
FB_WWW_DEV,
|
||||
FB_WWW_PROD,
|
||||
FB_WWW_PROFILING,
|
||||
RN_OSS_DEV,
|
||||
RN_OSS_PROD,
|
||||
RN_OSS_PROFILING,
|
||||
RN_FB_DEV,
|
||||
RN_FB_PROD,
|
||||
RN_FB_PROFILING,
|
||||
} = Bundles.bundleTypes;
|
||||
|
||||
const requestedBundleTypes = (argv.type || '')
|
||||
|
@ -87,6 +89,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return Object.assign({}, options, {
|
||||
plugins: options.plugins.concat([
|
||||
// Minify invariant messages
|
||||
|
@ -100,6 +103,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
|
|||
case RN_OSS_PROFILING:
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
return Object.assign({}, options, {
|
||||
plugins: options.plugins.concat([
|
||||
// Wrap warning() calls in a __DEV__ check so they are stripped from production.
|
||||
|
@ -159,11 +163,13 @@ function getFormat(bundleType) {
|
|||
case NODE_PROFILING:
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
case RN_OSS_DEV:
|
||||
case RN_OSS_PROD:
|
||||
case RN_OSS_PROFILING:
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
return `cjs`;
|
||||
}
|
||||
}
|
||||
|
@ -190,6 +196,8 @@ function getFilename(name, globalName, bundleType) {
|
|||
case RN_OSS_PROD:
|
||||
case RN_FB_PROD:
|
||||
return `${globalName}-prod.js`;
|
||||
case FB_WWW_PROFILING:
|
||||
case RN_FB_PROFILING:
|
||||
case RN_OSS_PROFILING:
|
||||
return `${globalName}-profiling.js`;
|
||||
}
|
||||
|
@ -207,9 +215,11 @@ function isProductionBundleType(bundleType) {
|
|||
case NODE_PROD:
|
||||
case NODE_PROFILING:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
case RN_OSS_PROD:
|
||||
case RN_OSS_PROFILING:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
return true;
|
||||
default:
|
||||
throw new Error(`Unknown type: ${bundleType}`);
|
||||
|
@ -229,7 +239,9 @@ function isProfilingBundleType(bundleType) {
|
|||
case UMD_DEV:
|
||||
case UMD_PROD:
|
||||
return false;
|
||||
case FB_WWW_PROFILING:
|
||||
case NODE_PROFILING:
|
||||
case RN_FB_PROFILING:
|
||||
case RN_OSS_PROFILING:
|
||||
return true;
|
||||
default:
|
||||
|
@ -267,13 +279,17 @@ function getPlugins(
|
|||
const isProduction = isProductionBundleType(bundleType);
|
||||
const isProfiling = isProfilingBundleType(bundleType);
|
||||
const isUMDBundle = bundleType === UMD_DEV || bundleType === UMD_PROD;
|
||||
const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD;
|
||||
const isFBBundle =
|
||||
bundleType === FB_WWW_DEV ||
|
||||
bundleType === FB_WWW_PROD ||
|
||||
bundleType === FB_WWW_PROFILING;
|
||||
const isRNBundle =
|
||||
bundleType === RN_OSS_DEV ||
|
||||
bundleType === RN_OSS_PROD ||
|
||||
bundleType === RN_OSS_PROFILING ||
|
||||
bundleType === RN_FB_DEV ||
|
||||
bundleType === RN_FB_PROD;
|
||||
bundleType === RN_FB_PROD ||
|
||||
bundleType === RN_FB_PROFILING;
|
||||
const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput;
|
||||
return [
|
||||
// Extract error codes from invariant() messages into a file.
|
||||
|
@ -404,7 +420,11 @@ async function createBundle(bundle, bundleType) {
|
|||
const packageName = Packaging.getPackageName(bundle.entry);
|
||||
|
||||
let resolvedEntry = require.resolve(bundle.entry);
|
||||
if (bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD) {
|
||||
if (
|
||||
bundleType === FB_WWW_DEV ||
|
||||
bundleType === FB_WWW_PROD ||
|
||||
bundleType === FB_WWW_PROFILING
|
||||
) {
|
||||
const resolvedFBEntry = resolvedEntry.replace('.js', '.fb.js');
|
||||
if (fs.existsSync(resolvedFBEntry)) {
|
||||
resolvedEntry = resolvedFBEntry;
|
||||
|
@ -451,7 +471,10 @@ async function createBundle(bundle, bundleType) {
|
|||
bundle.modulesToStub
|
||||
),
|
||||
// We can't use getters in www.
|
||||
legacy: bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD,
|
||||
legacy:
|
||||
bundleType === FB_WWW_DEV ||
|
||||
bundleType === FB_WWW_PROD ||
|
||||
bundleType === FB_WWW_PROFILING,
|
||||
};
|
||||
const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths(
|
||||
bundleType,
|
||||
|
@ -563,11 +586,13 @@ async function buildEverything() {
|
|||
await createBundle(bundle, NODE_PROFILING);
|
||||
await createBundle(bundle, FB_WWW_DEV);
|
||||
await createBundle(bundle, FB_WWW_PROD);
|
||||
await createBundle(bundle, FB_WWW_PROFILING);
|
||||
await createBundle(bundle, RN_OSS_DEV);
|
||||
await createBundle(bundle, RN_OSS_PROD);
|
||||
await createBundle(bundle, RN_OSS_PROFILING);
|
||||
await createBundle(bundle, RN_FB_DEV);
|
||||
await createBundle(bundle, RN_FB_PROD);
|
||||
await createBundle(bundle, RN_FB_PROFILING);
|
||||
}
|
||||
|
||||
await Packaging.copyAllShims();
|
||||
|
|
|
@ -8,11 +8,13 @@ const bundleTypes = {
|
|||
NODE_PROFILING: 'NODE_PROFILING',
|
||||
FB_WWW_DEV: 'FB_WWW_DEV',
|
||||
FB_WWW_PROD: 'FB_WWW_PROD',
|
||||
FB_WWW_PROFILING: 'FB_WWW_PROFILING',
|
||||
RN_OSS_DEV: 'RN_OSS_DEV',
|
||||
RN_OSS_PROD: 'RN_OSS_PROD',
|
||||
RN_OSS_PROFILING: 'RN_OSS_PROFILING',
|
||||
RN_FB_DEV: 'RN_FB_DEV',
|
||||
RN_FB_PROD: 'RN_FB_PROD',
|
||||
RN_FB_PROFILING: 'RN_FB_PROFILING',
|
||||
};
|
||||
|
||||
const UMD_DEV = bundleTypes.UMD_DEV;
|
||||
|
@ -22,11 +24,13 @@ const NODE_PROD = bundleTypes.NODE_PROD;
|
|||
const NODE_PROFILING = bundleTypes.NODE_PROFILING;
|
||||
const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
|
||||
const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
|
||||
const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
|
||||
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
|
||||
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
|
||||
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
|
||||
const RN_FB_DEV = bundleTypes.RN_FB_DEV;
|
||||
const RN_FB_PROD = bundleTypes.RN_FB_PROD;
|
||||
const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
|
||||
|
||||
const moduleTypes = {
|
||||
ISOMORPHIC: 'ISOMORPHIC',
|
||||
|
@ -76,6 +80,7 @@ const bundles = [
|
|||
NODE_PROFILING,
|
||||
FB_WWW_DEV,
|
||||
FB_WWW_PROD,
|
||||
FB_WWW_PROFILING,
|
||||
],
|
||||
moduleType: RENDERER,
|
||||
entry: 'react-dom',
|
||||
|
@ -160,7 +165,7 @@ const bundles = [
|
|||
/******* React Native *******/
|
||||
{
|
||||
label: 'native-fb',
|
||||
bundleTypes: [RN_FB_DEV, RN_FB_PROD],
|
||||
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
||||
moduleType: RENDERER,
|
||||
entry: 'react-native-renderer',
|
||||
global: 'ReactNativeRenderer',
|
||||
|
@ -201,7 +206,7 @@ const bundles = [
|
|||
/******* React Native Fabric *******/
|
||||
{
|
||||
label: 'native-fabric-fb',
|
||||
bundleTypes: [RN_FB_DEV, RN_FB_PROD],
|
||||
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
|
||||
moduleType: RENDERER,
|
||||
entry: 'react-native-renderer/fabric',
|
||||
global: 'ReactFabric',
|
||||
|
|
|
@ -8,11 +8,13 @@ const UMD_DEV = bundleTypes.UMD_DEV;
|
|||
const UMD_PROD = bundleTypes.UMD_PROD;
|
||||
const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
|
||||
const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
|
||||
const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
|
||||
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
|
||||
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
|
||||
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
|
||||
const RN_FB_DEV = bundleTypes.RN_FB_DEV;
|
||||
const RN_FB_PROD = bundleTypes.RN_FB_PROD;
|
||||
const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
|
||||
const RENDERER = moduleTypes.RENDERER;
|
||||
const RECONCILER = moduleTypes.RECONCILER;
|
||||
|
||||
|
@ -43,6 +45,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
return 'shared/forks/ReactFeatureFlags.native-fb.js';
|
||||
case RN_OSS_DEV:
|
||||
case RN_OSS_PROD:
|
||||
|
@ -57,6 +60,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
return 'shared/forks/ReactFeatureFlags.native-fabric-fb.js';
|
||||
case RN_OSS_DEV:
|
||||
case RN_OSS_PROD:
|
||||
|
@ -75,6 +79,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'shared/forks/ReactFeatureFlags.www.js';
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +90,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'shared/forks/ReactScheduler.www.js';
|
||||
default:
|
||||
return null;
|
||||
|
@ -96,6 +102,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'shared/forks/invariant.www.js';
|
||||
default:
|
||||
return null;
|
||||
|
@ -107,6 +114,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'shared/forks/lowPriorityWarning.www.js';
|
||||
default:
|
||||
return null;
|
||||
|
@ -118,6 +126,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'shared/forks/warning.www.js';
|
||||
default:
|
||||
return null;
|
||||
|
@ -130,6 +139,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'react/src/forks/ReactCurrentOwner.www.js';
|
||||
default:
|
||||
return null;
|
||||
|
@ -141,6 +151,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return 'shared/forks/invokeGuardedCallback.www.js';
|
||||
default:
|
||||
return null;
|
||||
|
@ -152,6 +163,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
// Use the www fork which shows an error dialog.
|
||||
return 'react-reconciler/src/forks/ReactFiberErrorDialog.www.js';
|
||||
case RN_OSS_DEV:
|
||||
|
@ -159,6 +171,7 @@ const forks = Object.freeze({
|
|||
case RN_OSS_PROFILING:
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
switch (entry) {
|
||||
case 'react-native-renderer':
|
||||
case 'react-native-renderer/fabric':
|
||||
|
@ -204,6 +217,7 @@ const forks = Object.freeze({
|
|||
switch (bundleType) {
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
// Use the www fork which is integrated with TimeSlice profiling.
|
||||
return 'react-dom/src/events/forks/EventListener-www.js';
|
||||
default:
|
||||
|
|
|
@ -17,11 +17,13 @@ const {
|
|||
NODE_PROFILING,
|
||||
FB_WWW_DEV,
|
||||
FB_WWW_PROD,
|
||||
FB_WWW_PROFILING,
|
||||
RN_OSS_DEV,
|
||||
RN_OSS_PROD,
|
||||
RN_OSS_PROFILING,
|
||||
RN_FB_DEV,
|
||||
RN_FB_PROD,
|
||||
RN_FB_PROFILING,
|
||||
} = Bundles.bundleTypes;
|
||||
|
||||
function getPackageName(name) {
|
||||
|
@ -45,6 +47,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
|
|||
];
|
||||
case FB_WWW_DEV:
|
||||
case FB_WWW_PROD:
|
||||
case FB_WWW_PROFILING:
|
||||
return [`build/facebook-www/${filename}`];
|
||||
case RN_OSS_DEV:
|
||||
case RN_OSS_PROD:
|
||||
|
@ -57,6 +60,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
|
|||
}
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROD:
|
||||
case RN_FB_PROFILING:
|
||||
switch (packageName) {
|
||||
case 'react-native-renderer':
|
||||
return [`build/react-native/fb/${filename}`];
|
||||
|
|
|
@ -10,11 +10,13 @@ const NODE_PROD = Bundles.bundleTypes.NODE_PROD;
|
|||
const NODE_PROFILING = Bundles.bundleTypes.NODE_PROFILING;
|
||||
const FB_WWW_DEV = Bundles.bundleTypes.FB_WWW_DEV;
|
||||
const FB_WWW_PROD = Bundles.bundleTypes.FB_WWW_PROD;
|
||||
const FB_WWW_PROFILING = Bundles.bundleTypes.FB_WWW_PROFILING;
|
||||
const RN_OSS_DEV = Bundles.bundleTypes.RN_OSS_DEV;
|
||||
const RN_OSS_PROD = Bundles.bundleTypes.RN_OSS_PROD;
|
||||
const RN_OSS_PROFILING = Bundles.bundleTypes.RN_OSS_PROFILING;
|
||||
const RN_FB_DEV = Bundles.bundleTypes.RN_FB_DEV;
|
||||
const RN_FB_PROD = Bundles.bundleTypes.RN_FB_PROD;
|
||||
const RN_FB_PROFILING = Bundles.bundleTypes.RN_FB_PROFILING;
|
||||
|
||||
const RECONCILER = Bundles.moduleTypes.RECONCILER;
|
||||
|
||||
|
@ -141,6 +143,19 @@ ${license}
|
|||
* @preserve-invariant-messages
|
||||
*/
|
||||
|
||||
${source}`;
|
||||
},
|
||||
|
||||
/****************** FB_WWW_PROFILING ******************/
|
||||
[FB_WWW_PROFILING](source, globalName, filename, moduleType) {
|
||||
return `/**
|
||||
${license}
|
||||
*
|
||||
* @noflow
|
||||
* @preventMunge
|
||||
* @preserve-invariant-messages
|
||||
*/
|
||||
|
||||
${source}`;
|
||||
},
|
||||
|
||||
|
@ -221,6 +236,19 @@ ${license}
|
|||
* ${'@gen' + 'erated'}
|
||||
*/
|
||||
|
||||
${source}`;
|
||||
},
|
||||
|
||||
/****************** RN_FB_PROFILING ******************/
|
||||
[RN_FB_PROFILING](source, globalName, filename, moduleType) {
|
||||
return `/**
|
||||
${license}
|
||||
*
|
||||
* @noflow
|
||||
* @preventMunge
|
||||
* ${'@gen' + 'erated'}
|
||||
*/
|
||||
|
||||
${source}`;
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue