Skip to content
Closed
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
3 changes: 1 addition & 2 deletions packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ export const {
requestIdleCallbackBeforeFirstFrame,
requestTimerEventBeforeFirstFrame,
enableMessageLoopImplementation,
enableProfiling,
} = require('SchedulerFeatureFlags');

export const enableProfiling = __PROFILE__;
29 changes: 23 additions & 6 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const {
FB_WWW_DEV,
FB_WWW_PROD,
FB_WWW_PROFILING,
FB_WWW_COMBINED,
RN_OSS_DEV,
RN_OSS_PROD,
RN_OSS_PROFILING,
Expand Down Expand Up @@ -111,6 +112,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) {
case FB_WWW_DEV:
case FB_WWW_PROD:
case FB_WWW_PROFILING:
case FB_WWW_COMBINED:
return Object.assign({}, options, {
plugins: options.plugins.concat([
// Minify invariant messages
Expand Down Expand Up @@ -192,6 +194,7 @@ function getFormat(bundleType) {
case FB_WWW_DEV:
case FB_WWW_PROD:
case FB_WWW_PROFILING:
case FB_WWW_COMBINED:
case RN_OSS_DEV:
case RN_OSS_PROD:
case RN_OSS_PROFILING:
Expand Down Expand Up @@ -230,6 +233,8 @@ function getFilename(name, globalName, bundleType) {
case RN_FB_PROFILING:
case RN_OSS_PROFILING:
return `${globalName}-profiling.js`;
case FB_WWW_COMBINED:
return `${globalName}-combined.js`;
}
}

Expand All @@ -238,6 +243,7 @@ function isProductionBundleType(bundleType) {
case UMD_DEV:
case NODE_DEV:
case FB_WWW_DEV:
case FB_WWW_COMBINED:
case RN_OSS_DEV:
case RN_FB_DEV:
return false;
Expand All @@ -261,6 +267,7 @@ function isProfilingBundleType(bundleType) {
switch (bundleType) {
case FB_WWW_DEV:
case FB_WWW_PROD:
case FB_WWW_COMBINED:
case NODE_DEV:
case NODE_PROD:
case RN_FB_DEV:
Expand Down Expand Up @@ -326,6 +333,20 @@ function getPlugins(
bundleType === RN_FB_PROD ||
bundleType === RN_FB_PROFILING;
const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput;

const replaceConfig = {
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
__UMD__: isUMDBundle ? 'true' : 'false',
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
};

if (bundleType !== FB_WWW_COMBINED) {
// Turn __DEV__ and process.env checks into constants so the dev-only
// branches can be dead code eliminated in the prod bundles. Except for the
// FB_WWW_COMBINED bundle type, which runs in both dev and prod.
replaceConfig.__DEV__ = isProduction ? 'false' : 'true';
}

return [
// Extract error codes from invariant() messages into a file.
shouldExtractErrors && {
Expand Down Expand Up @@ -355,12 +376,7 @@ function getPlugins(
},
},
// Turn __DEV__ and process.env checks into constants.
replace({
__DEV__: isProduction ? 'false' : 'true',
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
__UMD__: isUMDBundle ? 'true' : 'false',
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
}),
replace(replaceConfig),
// We still need CommonJS for external deps like object-assign.
commonjs(),
// Apply dead code elimination and/or minification.
Expand Down Expand Up @@ -648,6 +664,7 @@ async function buildEverything() {
[bundle, FB_WWW_DEV],
[bundle, FB_WWW_PROD],
[bundle, FB_WWW_PROFILING],
[bundle, FB_WWW_COMBINED],
[bundle, RN_OSS_DEV],
[bundle, RN_OSS_PROD],
[bundle, RN_OSS_PROFILING],
Expand Down
19 changes: 4 additions & 15 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const bundleTypes = {
FB_WWW_DEV: 'FB_WWW_DEV',
FB_WWW_PROD: 'FB_WWW_PROD',
FB_WWW_PROFILING: 'FB_WWW_PROFILING',
FB_WWW_COMBINED: 'FB_WWW_COMBINED',
RN_OSS_DEV: 'RN_OSS_DEV',
RN_OSS_PROD: 'RN_OSS_PROD',
RN_OSS_PROFILING: 'RN_OSS_PROFILING',
Expand All @@ -28,6 +29,7 @@ const {
FB_WWW_DEV,
FB_WWW_PROD,
FB_WWW_PROFILING,
FB_WWW_COMBINED,
RN_OSS_DEV,
RN_OSS_PROD,
RN_OSS_PROFILING,
Expand Down Expand Up @@ -411,13 +413,7 @@ const bundles = [

/******* React Scheduler (experimental) *******/
{
bundleTypes: [
NODE_DEV,
NODE_PROD,
FB_WWW_DEV,
FB_WWW_PROD,
FB_WWW_PROFILING,
],
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_COMBINED],
moduleType: ISOMORPHIC,
entry: 'scheduler',
global: 'Scheduler',
Expand All @@ -426,14 +422,7 @@ const bundles = [

/******* React Scheduler Mock (experimental) *******/
{
bundleTypes: [
UMD_DEV,
UMD_PROD,
NODE_DEV,
NODE_PROD,
FB_WWW_DEV,
FB_WWW_PROD,
],
bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_WWW_COMBINED],
moduleType: ISOMORPHIC,
entry: 'scheduler/unstable_mock',
global: 'SchedulerMock',
Expand Down
9 changes: 4 additions & 5 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const UMD_PROFILING = bundleTypes.UMD_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 FB_WWW_COMBINED = bundleTypes.FB_WWW_COMBINED;
const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
Expand Down Expand Up @@ -158,11 +159,7 @@ const forks = Object.freeze({
},

'scheduler/src/SchedulerFeatureFlags': (bundleType, entry, dependencies) => {
if (
bundleType === FB_WWW_DEV ||
bundleType === FB_WWW_PROD ||
bundleType === FB_WWW_PROFILING
) {
if (bundleType === FB_WWW_COMBINED) {
Copy link
Contributor

@trueadm trueadm Sep 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the other two bundleTypes here (FB_WWW_DEV and FB_WWW_PROD)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the purpose of the combined bundle is to replace the dev and prod bundles with a single bundle that includes both code paths

return 'scheduler/src/forks/SchedulerFeatureFlags.www.js';
}
return 'scheduler/src/SchedulerFeatureFlags';
Expand All @@ -186,6 +183,7 @@ const forks = Object.freeze({
case FB_WWW_DEV:
case FB_WWW_PROD:
case FB_WWW_PROFILING:
case FB_WWW_COMBINED:
return 'shared/forks/lowPriorityWarning.www.js';
default:
return null;
Expand All @@ -198,6 +196,7 @@ const forks = Object.freeze({
case FB_WWW_DEV:
case FB_WWW_PROD:
case FB_WWW_PROFILING:
case FB_WWW_COMBINED:
return 'shared/forks/warningWithoutStack.www.js';
default:
return null;
Expand Down
2 changes: 2 additions & 0 deletions scripts/rollup/packaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {
FB_WWW_DEV,
FB_WWW_PROD,
FB_WWW_PROFILING,
FB_WWW_COMBINED,
RN_OSS_DEV,
RN_OSS_PROD,
RN_OSS_PROFILING,
Expand Down Expand Up @@ -50,6 +51,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) {
case FB_WWW_DEV:
case FB_WWW_PROD:
case FB_WWW_PROFILING:
case FB_WWW_COMBINED:
return [`build/facebook-www/${filename}`];
case RN_OSS_DEV:
case RN_OSS_PROD:
Expand Down
14 changes: 14 additions & 0 deletions scripts/rollup/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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 FB_WWW_COMBINED = Bundles.bundleTypes.FB_WWW_COMBINED;
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;
Expand Down Expand Up @@ -167,6 +168,19 @@ ${license}
* @preserve-invariant-messages
*/

${source}`;
},

/****************** FB_WWW_COMBINED ******************/
[FB_WWW_COMBINED](source, globalName, filename, moduleType) {
return `/**
${license}
*
* @noflow
* @preventMunge
* @preserve-invariant-messages
*/

${source}`;
},

Expand Down