Add PROFILE bundles for www+DOM and fbsource+RN/RF (#13112)
Brian Vaughn committed
Jun 26, 2018 at 13:28 UTC
6d6de6011cf329fabe057186e9a65fc8eb4e175c
9 files changed
+87
-10
packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js
+1
-1
@@ -20,7 +20,7 @@ export const enableSuspense = false;
20
export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = __DEV__;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23
-export const enableProfilerTimer = __DEV__;
23
+export const enableProfilerTimer = __PROFILE__;
24
25
// Only used in www builds.
26
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
-1
@@ -20,12 +20,12 @@ export const {
20
debugRenderPhaseSideEffectsForStrictMode,
21
warnAboutDeprecatedLifecycles,
22
replayFailedUnitOfWorkWithInvokeGuardedCallback,
23
- enableProfilerTimer,
23
} = require('ReactFeatureFlags');
24
25
// The rest of the flags are static for better dead code elimination.
26
export const enableUserTimingAPI = __DEV__;
27
export const warnAboutLegacyContextAPI = __DEV__;
28
+export const enableProfilerTimer = __PROFILE__;
29
30
// Only used in www builds.
31
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.persistent.js
+1
-1
@@ -20,7 +20,7 @@ export const enableSuspense = false;
20
export const warnAboutDeprecatedLifecycles = false;
21
export const warnAboutLegacyContextAPI = false;
22
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
23
-export const enableProfilerTimer = false;
23
+export const enableProfilerTimer = __PROFILE__;
24
25
// Only used in www builds.
26
export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.www.js
+2
-1
@@ -18,7 +18,6 @@ export const {
18
enableGetDerivedStateFromCatch,
19
replayFailedUnitOfWorkWithInvokeGuardedCallback,
20
warnAboutDeprecatedLifecycles,
21
- enableProfilerTimer,
21
} = require('ReactFeatureFlags');
22
23
// The rest of the flags are static for better dead code elimination.
@@ -32,6 +31,8 @@ export const warnAboutLegacyContextAPI = __DEV__;
31
// as long as there is more than a single listener.
32
export let enableUserTimingAPI = __DEV__;
33
34
+export const enableProfilerTimer = __PROFILE__;
35
+
36
let refCount = 0;
37
export function addUserTimingListener() {
38
if (__DEV__) {
scripts/rollup/build.js
+29
-4
@@ -42,11 +42,13 @@ const {
42
NODE_PROFILING,
43
FB_WWW_DEV,
44
FB_WWW_PROD,
45
+ FB_WWW_PROFILING,
46
RN_OSS_DEV,
47
RN_OSS_PROD,
48
RN_OSS_PROFILING,
49
RN_FB_DEV,
50
RN_FB_PROD,
51
+ RN_FB_PROFILING,
52
} = Bundles.bundleTypes;
53
54
const requestedBundleTypes = (argv.type || '')
@@ -87,6 +89,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
89
switch (bundleType) {
90
case FB_WWW_DEV:
91
case FB_WWW_PROD:
92
+ case FB_WWW_PROFILING:
93
return Object.assign({}, options, {
94
plugins: options.plugins.concat([
95
// Minify invariant messages
@@ -100,6 +103,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
103
case RN_OSS_PROFILING:
104
case RN_FB_DEV:
105
case RN_FB_PROD:
106
+ case RN_FB_PROFILING:
107
return Object.assign({}, options, {
108
plugins: options.plugins.concat([
109
// Wrap warning() calls in a __DEV__ check so they are stripped from production.
@@ -159,11 +163,13 @@ function getFormat(bundleType) {
163
case NODE_PROFILING:
164
case FB_WWW_DEV:
165
case FB_WWW_PROD:
166
+ case FB_WWW_PROFILING:
167
case RN_OSS_DEV:
168
case RN_OSS_PROD:
169
case RN_OSS_PROFILING:
170
case RN_FB_DEV:
171
case RN_FB_PROD:
172
+ case RN_FB_PROFILING:
173
return `cjs`;
174
}
175
}
@@ -190,6 +196,8 @@ function getFilename(name, globalName, bundleType) {
196
case RN_OSS_PROD:
197
case RN_FB_PROD:
198
return `${globalName}-prod.js`;
199
+ case FB_WWW_PROFILING:
200
+ case RN_FB_PROFILING:
201
case RN_OSS_PROFILING:
202
return `${globalName}-profiling.js`;
203
}
@@ -207,9 +215,11 @@ function isProductionBundleType(bundleType) {
215
case NODE_PROD:
216
case NODE_PROFILING:
217
case FB_WWW_PROD:
218
+ case FB_WWW_PROFILING:
219
case RN_OSS_PROD:
220
case RN_OSS_PROFILING:
221
case RN_FB_PROD:
222
+ case RN_FB_PROFILING:
223
return true;
224
default:
225
throw new Error(`Unknown type: ${bundleType}`);
@@ -229,7 +239,9 @@ function isProfilingBundleType(bundleType) {
239
case UMD_DEV:
240
case UMD_PROD:
241
return false;
242
+ case FB_WWW_PROFILING:
243
case NODE_PROFILING:
244
+ case RN_FB_PROFILING:
245
case RN_OSS_PROFILING:
246
return true;
247
default:
@@ -267,13 +279,17 @@ function getPlugins(
279
const isProduction = isProductionBundleType(bundleType);
280
const isProfiling = isProfilingBundleType(bundleType);
281
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;
286
const isRNBundle =
287
bundleType === RN_OSS_DEV ||
288
bundleType === RN_OSS_PROD ||
289
bundleType === RN_OSS_PROFILING ||
290
bundleType === RN_FB_DEV ||
276
- bundleType === RN_FB_PROD;
291
+ bundleType === RN_FB_PROD ||
292
+ bundleType === RN_FB_PROFILING;
293
const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput;
294
return [
295
// Extract error codes from invariant() messages into a file.
@@ -404,7 +420,11 @@ async function createBundle(bundle, bundleType) {
420
const packageName = Packaging.getPackageName(bundle.entry);
421
422
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
+ ) {
428
const resolvedFBEntry = resolvedEntry.replace('.js', '.fb.js');
429
if (fs.existsSync(resolvedFBEntry)) {
430
resolvedEntry = resolvedFBEntry;
@@ -451,7 +471,10 @@ async function createBundle(bundle, bundleType) {
471
bundle.modulesToStub
472
),
473
// 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,
478
};
479
const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths(
480
bundleType,
@@ -563,11 +586,13 @@ async function buildEverything() {
586
await createBundle(bundle, NODE_PROFILING);
587
await createBundle(bundle, FB_WWW_DEV);
588
await createBundle(bundle, FB_WWW_PROD);
589
+ await createBundle(bundle, FB_WWW_PROFILING);
590
await createBundle(bundle, RN_OSS_DEV);
591
await createBundle(bundle, RN_OSS_PROD);
592
await createBundle(bundle, RN_OSS_PROFILING);
593
await createBundle(bundle, RN_FB_DEV);
594
await createBundle(bundle, RN_FB_PROD);
595
+ await createBundle(bundle, RN_FB_PROFILING);
596
}
597
598
await Packaging.copyAllShims();
scripts/rollup/bundles.js
+7
-2
@@ -8,11 +8,13 @@ const bundleTypes = {
8
NODE_PROFILING: 'NODE_PROFILING',
9
FB_WWW_DEV: 'FB_WWW_DEV',
10
FB_WWW_PROD: 'FB_WWW_PROD',
11
+ FB_WWW_PROFILING: 'FB_WWW_PROFILING',
12
RN_OSS_DEV: 'RN_OSS_DEV',
13
RN_OSS_PROD: 'RN_OSS_PROD',
14
RN_OSS_PROFILING: 'RN_OSS_PROFILING',
15
RN_FB_DEV: 'RN_FB_DEV',
16
RN_FB_PROD: 'RN_FB_PROD',
17
+ RN_FB_PROFILING: 'RN_FB_PROFILING',
18
};
19
20
const UMD_DEV = bundleTypes.UMD_DEV;
@@ -22,11 +24,13 @@ const NODE_PROD = bundleTypes.NODE_PROD;
24
const NODE_PROFILING = bundleTypes.NODE_PROFILING;
25
const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
26
const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
27
+const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
28
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
29
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
30
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
31
const RN_FB_DEV = bundleTypes.RN_FB_DEV;
32
const RN_FB_PROD = bundleTypes.RN_FB_PROD;
33
+const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
34
35
const moduleTypes = {
36
ISOMORPHIC: 'ISOMORPHIC',
@@ -76,6 +80,7 @@ const bundles = [
80
NODE_PROFILING,
81
FB_WWW_DEV,
82
FB_WWW_PROD,
83
+ FB_WWW_PROFILING,
84
],
85
moduleType: RENDERER,
86
entry: 'react-dom',
@@ -160,7 +165,7 @@ const bundles = [
165
/******* React Native *******/
166
{
167
label: 'native-fb',
163
- bundleTypes: [RN_FB_DEV, RN_FB_PROD],
168
+ bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
169
moduleType: RENDERER,
170
entry: 'react-native-renderer',
171
global: 'ReactNativeRenderer',
@@ -201,7 +206,7 @@ const bundles = [
206
/******* React Native Fabric *******/
207
{
208
label: 'native-fabric-fb',
204
- bundleTypes: [RN_FB_DEV, RN_FB_PROD],
209
+ bundleTypes: [RN_FB_DEV, RN_FB_PROD, RN_FB_PROFILING],
210
moduleType: RENDERER,
211
entry: 'react-native-renderer/fabric',
212
global: 'ReactFabric',
scripts/rollup/forks.js
+14
@@ -8,11 +8,13 @@ const UMD_DEV = bundleTypes.UMD_DEV;
8
const UMD_PROD = bundleTypes.UMD_PROD;
9
const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
10
const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
11
+const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
12
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
13
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
14
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
15
const RN_FB_DEV = bundleTypes.RN_FB_DEV;
16
const RN_FB_PROD = bundleTypes.RN_FB_PROD;
17
+const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
18
const RENDERER = moduleTypes.RENDERER;
19
const RECONCILER = moduleTypes.RECONCILER;
20
@@ -43,6 +45,7 @@ const forks = Object.freeze({
45
switch (bundleType) {
46
case RN_FB_DEV:
47
case RN_FB_PROD:
48
+ case RN_FB_PROFILING:
49
return 'shared/forks/ReactFeatureFlags.native-fb.js';
50
case RN_OSS_DEV:
51
case RN_OSS_PROD:
@@ -57,6 +60,7 @@ const forks = Object.freeze({
60
switch (bundleType) {
61
case RN_FB_DEV:
62
case RN_FB_PROD:
63
+ case RN_FB_PROFILING:
64
return 'shared/forks/ReactFeatureFlags.native-fabric-fb.js';
65
case RN_OSS_DEV:
66
case RN_OSS_PROD:
@@ -75,6 +79,7 @@ const forks = Object.freeze({
79
switch (bundleType) {
80
case FB_WWW_DEV:
81
case FB_WWW_PROD:
82
+ case FB_WWW_PROFILING:
83
return 'shared/forks/ReactFeatureFlags.www.js';
84
}
85
}
@@ -85,6 +90,7 @@ const forks = Object.freeze({
90
switch (bundleType) {
91
case FB_WWW_DEV:
92
case FB_WWW_PROD:
93
+ case FB_WWW_PROFILING:
94
return 'shared/forks/ReactScheduler.www.js';
95
default:
96
return null;
@@ -96,6 +102,7 @@ const forks = Object.freeze({
102
switch (bundleType) {
103
case FB_WWW_DEV:
104
case FB_WWW_PROD:
105
+ case FB_WWW_PROFILING:
106
return 'shared/forks/invariant.www.js';
107
default:
108
return null;
@@ -107,6 +114,7 @@ const forks = Object.freeze({
114
switch (bundleType) {
115
case FB_WWW_DEV:
116
case FB_WWW_PROD:
117
+ case FB_WWW_PROFILING:
118
return 'shared/forks/lowPriorityWarning.www.js';
119
default:
120
return null;
@@ -118,6 +126,7 @@ const forks = Object.freeze({
126
switch (bundleType) {
127
case FB_WWW_DEV:
128
case FB_WWW_PROD:
129
+ case FB_WWW_PROFILING:
130
return 'shared/forks/warning.www.js';
131
default:
132
return null;
@@ -130,6 +139,7 @@ const forks = Object.freeze({
139
switch (bundleType) {
140
case FB_WWW_DEV:
141
case FB_WWW_PROD:
142
+ case FB_WWW_PROFILING:
143
return 'react/src/forks/ReactCurrentOwner.www.js';
144
default:
145
return null;
@@ -141,6 +151,7 @@ const forks = Object.freeze({
151
switch (bundleType) {
152
case FB_WWW_DEV:
153
case FB_WWW_PROD:
154
+ case FB_WWW_PROFILING:
155
return 'shared/forks/invokeGuardedCallback.www.js';
156
default:
157
return null;
@@ -152,6 +163,7 @@ const forks = Object.freeze({
163
switch (bundleType) {
164
case FB_WWW_DEV:
165
case FB_WWW_PROD:
166
+ case FB_WWW_PROFILING:
167
// Use the www fork which shows an error dialog.
168
return 'react-reconciler/src/forks/ReactFiberErrorDialog.www.js';
169
case RN_OSS_DEV:
@@ -159,6 +171,7 @@ const forks = Object.freeze({
171
case RN_OSS_PROFILING:
172
case RN_FB_DEV:
173
case RN_FB_PROD:
174
+ case RN_FB_PROFILING:
175
switch (entry) {
176
case 'react-native-renderer':
177
case 'react-native-renderer/fabric':
@@ -204,6 +217,7 @@ const forks = Object.freeze({
217
switch (bundleType) {
218
case FB_WWW_DEV:
219
case FB_WWW_PROD:
220
+ case FB_WWW_PROFILING:
221
// Use the www fork which is integrated with TimeSlice profiling.
222
return 'react-dom/src/events/forks/EventListener-www.js';
223
default:
scripts/rollup/packaging.js
+4
@@ -17,11 +17,13 @@ const {
17
NODE_PROFILING,
18
FB_WWW_DEV,
19
FB_WWW_PROD,
20
+ FB_WWW_PROFILING,
21
RN_OSS_DEV,
22
RN_OSS_PROD,
23
RN_OSS_PROFILING,
24
RN_FB_DEV,
25
RN_FB_PROD,
26
+ RN_FB_PROFILING,
27
} = Bundles.bundleTypes;
28
29
function getPackageName(name) {
@@ -45,6 +47,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
47
];
48
case FB_WWW_DEV:
49
case FB_WWW_PROD:
50
+ case FB_WWW_PROFILING:
51
return [`build/facebook-www/${filename}`];
52
case RN_OSS_DEV:
53
case RN_OSS_PROD:
@@ -57,6 +60,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
60
}
61
case RN_FB_DEV:
62
case RN_FB_PROD:
63
+ case RN_FB_PROFILING:
64
switch (packageName) {
65
case 'react-native-renderer':
66
return [`build/react-native/fb/${filename}`];
scripts/rollup/wrappers.js
+28
@@ -10,11 +10,13 @@ const NODE_PROD = Bundles.bundleTypes.NODE_PROD;
10
const NODE_PROFILING = Bundles.bundleTypes.NODE_PROFILING;
11
const FB_WWW_DEV = Bundles.bundleTypes.FB_WWW_DEV;
12
const FB_WWW_PROD = Bundles.bundleTypes.FB_WWW_PROD;
13
+const FB_WWW_PROFILING = Bundles.bundleTypes.FB_WWW_PROFILING;
14
const RN_OSS_DEV = Bundles.bundleTypes.RN_OSS_DEV;
15
const RN_OSS_PROD = Bundles.bundleTypes.RN_OSS_PROD;
16
const RN_OSS_PROFILING = Bundles.bundleTypes.RN_OSS_PROFILING;
17
const RN_FB_DEV = Bundles.bundleTypes.RN_FB_DEV;
18
const RN_FB_PROD = Bundles.bundleTypes.RN_FB_PROD;
19
+const RN_FB_PROFILING = Bundles.bundleTypes.RN_FB_PROFILING;
20
21
const RECONCILER = Bundles.moduleTypes.RECONCILER;
22
@@ -141,6 +143,19 @@ ${license}
143
* @preserve-invariant-messages
144
*/
145
146
+${source}`;
147
+ },
148
+
149
+ /****************** FB_WWW_PROFILING ******************/
150
+ [FB_WWW_PROFILING](source, globalName, filename, moduleType) {
151
+ return `/**
152
+${license}
153
+ *
154
+ * @noflow
155
+ * @preventMunge
156
+ * @preserve-invariant-messages
157
+ */
158
+
159
${source}`;
160
},
161
@@ -221,6 +236,19 @@ ${license}
236
* ${'@gen' + 'erated'}
237
*/
238
239
+${source}`;
240
+ },
241
+
242
+ /****************** RN_FB_PROFILING ******************/
243
+ [RN_FB_PROFILING](source, globalName, filename, moduleType) {
244
+ return `/**
245
+${license}
246
+ *
247
+ * @noflow
248
+ * @preventMunge
249
+ * ${'@gen' + 'erated'}
250
+ */
251
+
252
${source}`;
253
},
254
};