Skip to content

Commit 6d6de60

Browse files
authored
Add PROFILE bundles for www+DOM and fbsource+RN/RF (facebook#13112)
1 parent 71a60dd commit 6d6de60

File tree

9 files changed

+87
-10
lines changed

9 files changed

+87
-10
lines changed

packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const enableSuspense = false;
2020
export const warnAboutDeprecatedLifecycles = false;
2121
export const warnAboutLegacyContextAPI = __DEV__;
2222
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23-
export const enableProfilerTimer = __DEV__;
23+
export const enableProfilerTimer = __PROFILE__;
2424

2525
// Only used in www builds.
2626
export function addUserTimingListener() {

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export const {
2020
debugRenderPhaseSideEffectsForStrictMode,
2121
warnAboutDeprecatedLifecycles,
2222
replayFailedUnitOfWorkWithInvokeGuardedCallback,
23-
enableProfilerTimer,
2423
} = require('ReactFeatureFlags');
2524

2625
// The rest of the flags are static for better dead code elimination.
2726
export const enableUserTimingAPI = __DEV__;
2827
export const warnAboutLegacyContextAPI = __DEV__;
28+
export const enableProfilerTimer = __PROFILE__;
2929

3030
// Only used in www builds.
3131
export function addUserTimingListener() {

packages/shared/forks/ReactFeatureFlags.persistent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const enableSuspense = false;
2020
export const warnAboutDeprecatedLifecycles = false;
2121
export const warnAboutLegacyContextAPI = false;
2222
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23-
export const enableProfilerTimer = false;
23+
export const enableProfilerTimer = __PROFILE__;
2424

2525
// Only used in www builds.
2626
export function addUserTimingListener() {

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const {
1818
enableGetDerivedStateFromCatch,
1919
replayFailedUnitOfWorkWithInvokeGuardedCallback,
2020
warnAboutDeprecatedLifecycles,
21-
enableProfilerTimer,
2221
} = require('ReactFeatureFlags');
2322

2423
// The rest of the flags are static for better dead code elimination.
@@ -32,6 +31,8 @@ export const warnAboutLegacyContextAPI = __DEV__;
3231
// as long as there is more than a single listener.
3332
export let enableUserTimingAPI = __DEV__;
3433

34+
export const enableProfilerTimer = __PROFILE__;
35+
3536
let refCount = 0;
3637
export function addUserTimingListener() {
3738
if (__DEV__) {

scripts/rollup/build.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ const {
4242
NODE_PROFILING,
4343
FB_WWW_DEV,
4444
FB_WWW_PROD,
45+
FB_WWW_PROFILING,
4546
RN_OSS_DEV,
4647
RN_OSS_PROD,
4748
RN_OSS_PROFILING,
4849
RN_FB_DEV,
4950
RN_FB_PROD,
51+
RN_FB_PROFILING,
5052
} = Bundles.bundleTypes;
5153

5254
const requestedBundleTypes = (argv.type || '')
@@ -87,6 +89,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
8789
switch (bundleType) {
8890
case FB_WWW_DEV:
8991
case FB_WWW_PROD:
92+
case FB_WWW_PROFILING:
9093
return Object.assign({}, options, {
9194
plugins: options.plugins.concat([
9295
// Minify invariant messages
@@ -100,6 +103,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
100103
case RN_OSS_PROFILING:
101104
case RN_FB_DEV:
102105
case RN_FB_PROD:
106+
case RN_FB_PROFILING:
103107
return Object.assign({}, options, {
104108
plugins: options.plugins.concat([
105109
// Wrap warning() calls in a __DEV__ check so they are stripped from production.
@@ -159,11 +163,13 @@ function getFormat(bundleType) {
159163
case NODE_PROFILING:
160164
case FB_WWW_DEV:
161165
case FB_WWW_PROD:
166+
case FB_WWW_PROFILING:
162167
case RN_OSS_DEV:
163168
case RN_OSS_PROD:
164169
case RN_OSS_PROFILING:
165170
case RN_FB_DEV:
166171
case RN_FB_PROD:
172+
case RN_FB_PROFILING:
167173
return `cjs`;
168174
}
169175
}
@@ -190,6 +196,8 @@ function getFilename(name, globalName, bundleType) {
190196
case RN_OSS_PROD:
191197
case RN_FB_PROD:
192198
return `${globalName}-prod.js`;
199+
case FB_WWW_PROFILING:
200+
case RN_FB_PROFILING:
193201
case RN_OSS_PROFILING:
194202
return `${globalName}-profiling.js`;
195203
}
@@ -207,9 +215,11 @@ function isProductionBundleType(bundleType) {
207215
case NODE_PROD:
208216
case NODE_PROFILING:
209217
case FB_WWW_PROD:
218+
case FB_WWW_PROFILING:
210219
case RN_OSS_PROD:
211220
case RN_OSS_PROFILING:
212221
case RN_FB_PROD:
222+
case RN_FB_PROFILING:
213223
return true;
214224
default:
215225
throw new Error(`Unknown type: ${bundleType}`);
@@ -229,7 +239,9 @@ function isProfilingBundleType(bundleType) {
229239
case UMD_DEV:
230240
case UMD_PROD:
231241
return false;
242+
case FB_WWW_PROFILING:
232243
case NODE_PROFILING:
244+
case RN_FB_PROFILING:
233245
case RN_OSS_PROFILING:
234246
return true;
235247
default:
@@ -267,13 +279,17 @@ function getPlugins(
267279
const isProduction = isProductionBundleType(bundleType);
268280
const isProfiling = isProfilingBundleType(bundleType);
269281
const isUMDBundle = bundleType === UMD_DEV || bundleType === UMD_PROD;
270-
const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD;
282+
const isFBBundle =
283+
bundleType === FB_WWW_DEV ||
284+
bundleType === FB_WWW_PROD ||
285+
bundleType === FB_WWW_PROFILING;
271286
const isRNBundle =
272287
bundleType === RN_OSS_DEV ||
273288
bundleType === RN_OSS_PROD ||
274289
bundleType === RN_OSS_PROFILING ||
275290
bundleType === RN_FB_DEV ||
276-
bundleType === RN_FB_PROD;
291+
bundleType === RN_FB_PROD ||
292+
bundleType === RN_FB_PROFILING;
277293
const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput;
278294
return [
279295
// Extract error codes from invariant() messages into a file.
@@ -404,7 +420,11 @@ async function createBundle(bundle, bundleType) {
404420
const packageName = Packaging.getPackageName(bundle.entry);
405421

406422
let resolvedEntry = require.resolve(bundle.entry);
407-
if (bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD) {
423+
if (
424+
bundleType === FB_WWW_DEV ||
425+
bundleType === FB_WWW_PROD ||
426+
bundleType === FB_WWW_PROFILING
427+
) {
408428
const resolvedFBEntry = resolvedEntry.replace('.js', '.fb.js');
409429
if (fs.existsSync(resolvedFBEntry)) {
410430
resolvedEntry = resolvedFBEntry;
@@ -451,7 +471,10 @@ async function createBundle(bundle, bundleType) {
451471
bundle.modulesToStub
452472
),
453473
// We can't use getters in www.
454-
legacy: bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD,
474+
legacy:
475+
bundleType === FB_WWW_DEV ||
476+
bundleType === FB_WWW_PROD ||
477+
bundleType === FB_WWW_PROFILING,
455478
};
456479
const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths(
457480
bundleType,
@@ -563,11 +586,13 @@ async function buildEverything() {
563586
await createBundle(bundle, NODE_PROFILING);
564587
await createBundle(bundle, FB_WWW_DEV);
565588
await createBundle(bundle, FB_WWW_PROD);
589+
await createBundle(bundle, FB_WWW_PROFILING);
566590
await createBundle(bundle, RN_OSS_DEV);
567591
await createBundle(bundle, RN_OSS_PROD);
568592
await createBundle(bundle, RN_OSS_PROFILING);
569593
await createBundle(bundle, RN_FB_DEV);
570594
await createBundle(bundle, RN_FB_PROD);
595+
await createBundle(bundle, RN_FB_PROFILING);
571596
}
572597

573598
await Packaging.copyAllShims();

scripts/rollup/bundles.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const bundleTypes = {
88
NODE_PROFILING: 'NODE_PROFILING',
99
FB_WWW_DEV: 'FB_WWW_DEV',
1010
FB_WWW_PROD: 'FB_WWW_PROD',
11+
FB_WWW_PROFILING: 'FB_WWW_PROFILING',
1112
RN_OSS_DEV: 'RN_OSS_DEV',
1213
RN_OSS_PROD: 'RN_OSS_PROD',
1314
RN_OSS_PROFILING: 'RN_OSS_PROFILING',
1415
RN_FB_DEV: 'RN_FB_DEV',
1516
RN_FB_PROD: 'RN_FB_PROD',
17+
RN_FB_PROFILING: 'RN_FB_PROFILING',
1618
};
1719

1820
const UMD_DEV = bundleTypes.UMD_DEV;
@@ -22,11 +24,13 @@ const NODE_PROD = bundleTypes.NODE_PROD;
2224
const NODE_PROFILING = bundleTypes.NODE_PROFILING;
2325
const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
2426
const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
27+
const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
2528
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
2629
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
2730
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
2831
const RN_FB_DEV = bundleTypes.RN_FB_DEV;
2932
const RN_FB_PROD = bundleTypes.RN_FB_PROD;
33+
const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
3034

3135
const moduleTypes = {
3236
ISOMORPHIC: 'ISOMORPHIC',
@@ -76,6 +80,7 @@ const bundles = [
7680
NODE_PROFILING,
7781
FB_WWW_DEV,
7882
FB_WWW_PROD,
83+
FB_WWW_PROFILING,
7984
],
8085
moduleType: RENDERER,
8186
entry: 'react-dom',
@@ -160,7 +165,7 @@ const bundles = [
160165
/******* React Native *******/
161166
{
162167
label: 'native-fb',
163-
bundleTypes: [RN_FB_DEV, RN_FB_PROD],
168+
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
164169
moduleType: RENDERER,
165170
entry: 'react-native-renderer',
166171
global: 'ReactNativeRenderer',
@@ -201,7 +206,7 @@ const bundles = [
201206
/******* React Native Fabric *******/
202207
{
203208
label: 'native-fabric-fb',
204-
bundleTypes: [RN_FB_DEV, RN_FB_PROD],
209+
bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
205210
moduleType: RENDERER,
206211
entry: 'react-native-renderer/fabric',
207212
global: 'ReactFabric',

scripts/rollup/forks.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const UMD_DEV = bundleTypes.UMD_DEV;
88
const UMD_PROD = bundleTypes.UMD_PROD;
99
const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
1010
const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
11+
const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
1112
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
1213
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
1314
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
1415
const RN_FB_DEV = bundleTypes.RN_FB_DEV;
1516
const RN_FB_PROD = bundleTypes.RN_FB_PROD;
17+
const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
1618
const RENDERER = moduleTypes.RENDERER;
1719
const RECONCILER = moduleTypes.RECONCILER;
1820

@@ -43,6 +45,7 @@ const forks = Object.freeze({
4345
switch (bundleType) {
4446
case RN_FB_DEV:
4547
case RN_FB_PROD:
48+
case RN_FB_PROFILING:
4649
return 'shared/forks/ReactFeatureFlags.native-fb.js';
4750
case RN_OSS_DEV:
4851
case RN_OSS_PROD:
@@ -57,6 +60,7 @@ const forks = Object.freeze({
5760
switch (bundleType) {
5861
case RN_FB_DEV:
5962
case RN_FB_PROD:
63+
case RN_FB_PROFILING:
6064
return 'shared/forks/ReactFeatureFlags.native-fabric-fb.js';
6165
case RN_OSS_DEV:
6266
case RN_OSS_PROD:
@@ -75,6 +79,7 @@ const forks = Object.freeze({
7579
switch (bundleType) {
7680
case FB_WWW_DEV:
7781
case FB_WWW_PROD:
82+
case FB_WWW_PROFILING:
7883
return 'shared/forks/ReactFeatureFlags.www.js';
7984
}
8085
}
@@ -85,6 +90,7 @@ const forks = Object.freeze({
8590
switch (bundleType) {
8691
case FB_WWW_DEV:
8792
case FB_WWW_PROD:
93+
case FB_WWW_PROFILING:
8894
return 'shared/forks/ReactScheduler.www.js';
8995
default:
9096
return null;
@@ -96,6 +102,7 @@ const forks = Object.freeze({
96102
switch (bundleType) {
97103
case FB_WWW_DEV:
98104
case FB_WWW_PROD:
105+
case FB_WWW_PROFILING:
99106
return 'shared/forks/invariant.www.js';
100107
default:
101108
return null;
@@ -107,6 +114,7 @@ const forks = Object.freeze({
107114
switch (bundleType) {
108115
case FB_WWW_DEV:
109116
case FB_WWW_PROD:
117+
case FB_WWW_PROFILING:
110118
return 'shared/forks/lowPriorityWarning.www.js';
111119
default:
112120
return null;
@@ -118,6 +126,7 @@ const forks = Object.freeze({
118126
switch (bundleType) {
119127
case FB_WWW_DEV:
120128
case FB_WWW_PROD:
129+
case FB_WWW_PROFILING:
121130
return 'shared/forks/warning.www.js';
122131
default:
123132
return null;
@@ -130,6 +139,7 @@ const forks = Object.freeze({
130139
switch (bundleType) {
131140
case FB_WWW_DEV:
132141
case FB_WWW_PROD:
142+
case FB_WWW_PROFILING:
133143
return 'react/src/forks/ReactCurrentOwner.www.js';
134144
default:
135145
return null;
@@ -141,6 +151,7 @@ const forks = Object.freeze({
141151
switch (bundleType) {
142152
case FB_WWW_DEV:
143153
case FB_WWW_PROD:
154+
case FB_WWW_PROFILING:
144155
return 'shared/forks/invokeGuardedCallback.www.js';
145156
default:
146157
return null;
@@ -152,13 +163,15 @@ const forks = Object.freeze({
152163
switch (bundleType) {
153164
case FB_WWW_DEV:
154165
case FB_WWW_PROD:
166+
case FB_WWW_PROFILING:
155167
// Use the www fork which shows an error dialog.
156168
return 'react-reconciler/src/forks/ReactFiberErrorDialog.www.js';
157169
case RN_OSS_DEV:
158170
case RN_OSS_PROD:
159171
case RN_OSS_PROFILING:
160172
case RN_FB_DEV:
161173
case RN_FB_PROD:
174+
case RN_FB_PROFILING:
162175
switch (entry) {
163176
case 'react-native-renderer':
164177
case 'react-native-renderer/fabric':
@@ -204,6 +217,7 @@ const forks = Object.freeze({
204217
switch (bundleType) {
205218
case FB_WWW_DEV:
206219
case FB_WWW_PROD:
220+
case FB_WWW_PROFILING:
207221
// Use the www fork which is integrated with TimeSlice profiling.
208222
return 'react-dom/src/events/forks/EventListener-www.js';
209223
default:

scripts/rollup/packaging.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ const {
1717
NODE_PROFILING,
1818
FB_WWW_DEV,
1919
FB_WWW_PROD,
20+
FB_WWW_PROFILING,
2021
RN_OSS_DEV,
2122
RN_OSS_PROD,
2223
RN_OSS_PROFILING,
2324
RN_FB_DEV,
2425
RN_FB_PROD,
26+
RN_FB_PROFILING,
2527
} = Bundles.bundleTypes;
2628

2729
function getPackageName(name) {
@@ -45,6 +47,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
4547
];
4648
case FB_WWW_DEV:
4749
case FB_WWW_PROD:
50+
case FB_WWW_PROFILING:
4851
return [`build/facebook-www/${filename}`];
4952
case RN_OSS_DEV:
5053
case RN_OSS_PROD:
@@ -57,6 +60,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
5760
}
5861
case RN_FB_DEV:
5962
case RN_FB_PROD:
63+
case RN_FB_PROFILING:
6064
switch (packageName) {
6165
case 'react-native-renderer':
6266
return [`build/react-native/fb/${filename}`];

0 commit comments

Comments
 (0)