diff --git a/packages/schedule/npm/umd/schedule-tracing.profiling.min.js b/packages/schedule/npm/umd/schedule-tracing.profiling.min.js new file mode 100644 index 0000000000000..e361c64ac666e --- /dev/null +++ b/packages/schedule/npm/umd/schedule-tracing.profiling.min.js @@ -0,0 +1,79 @@ +/** + * @license React + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +(function(global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' + ? (module.exports = factory(require('react'))) + : typeof define === 'function' && define.amd // eslint-disable-line no-undef + ? define(['react'], factory) // eslint-disable-line no-undef + : (global.ScheduleTracing = factory(global)); +})(this, function(global) { + function unstable_clear() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_clear.apply( + this, + arguments + ); + } + + function unstable_getCurrent() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getCurrent.apply( + this, + arguments + ); + } + + function unstable_getThreadID() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_getThreadID.apply( + this, + arguments + ); + } + + function unstable_subscribe() { + // eslint-disable-next-line max-len + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_subscribe.apply( + this, + arguments + ); + } + + function unstable_trace() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_trace.apply( + this, + arguments + ); + } + + function unstable_unsubscribe() { + // eslint-disable-next-line max-len + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_unsubscribe.apply( + this, + arguments + ); + } + + function unstable_wrap() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ScheduleTracing.unstable_wrap.apply( + this, + arguments + ); + } + + return Object.freeze({ + unstable_clear: unstable_clear, + unstable_getCurrent: unstable_getCurrent, + unstable_getThreadID: unstable_getThreadID, + unstable_subscribe: unstable_subscribe, + unstable_trace: unstable_trace, + unstable_unsubscribe: unstable_unsubscribe, + unstable_wrap: unstable_wrap, + }); +}); diff --git a/packages/schedule/npm/umd/schedule.profiling.min.js b/packages/schedule/npm/umd/schedule.profiling.min.js new file mode 100644 index 0000000000000..43a338f741b52 --- /dev/null +++ b/packages/schedule/npm/umd/schedule.profiling.min.js @@ -0,0 +1,45 @@ +/** + * @license React + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +(function(global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' + ? (module.exports = factory(require('react'))) + : typeof define === 'function' && define.amd // eslint-disable-line no-undef + ? define(['react'], factory) // eslint-disable-line no-undef + : (global.Schedule = factory(global)); +})(this, function(global) { + function unstable_now() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Schedule.unstable_now.apply( + this, + arguments + ); + } + + function unstable_scheduleWork() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Schedule.unstable_scheduleWork.apply( + this, + arguments + ); + } + + function unstable_cancelScheduledWork() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Schedule.unstable_cancelScheduledWork.apply( + this, + arguments + ); + } + + return Object.freeze({ + unstable_now: unstable_now, + unstable_scheduleWork: unstable_scheduleWork, + unstable_cancelScheduledWork: unstable_cancelScheduledWork, + }); +}); diff --git a/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js b/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js index 2bdb38be097f8..36552fdde5d56 100644 --- a/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js +++ b/packages/schedule/src/__tests__/ScheduleUMDBundle-test.internal.js @@ -37,18 +37,26 @@ describe('Scheduling UMD bundle', () => { const api = require('../../index'); const umdAPIDev = require('../../npm/umd/schedule.development'); const umdAPIProd = require('../../npm/umd/schedule.production.min'); + const umdAPIProfiling = require('../../npm/umd/schedule.profiling.min'); const secretAPI = require('react/src/ReactSharedInternals').default; - validateForwardedAPIs(api, [umdAPIDev, umdAPIProd, secretAPI.Schedule]); + validateForwardedAPIs(api, [ + umdAPIDev, + umdAPIProd, + umdAPIProfiling, + secretAPI.Schedule, + ]); }); it('should define the same tracing API', () => { const api = require('../../tracing'); const umdAPIDev = require('../../npm/umd/schedule-tracing.development'); const umdAPIProd = require('../../npm/umd/schedule-tracing.production.min'); + const umdAPIProfiling = require('../../npm/umd/schedule-tracing.profiling.min'); const secretAPI = require('react/src/ReactSharedInternals').default; validateForwardedAPIs(api, [ umdAPIDev, umdAPIProd, + umdAPIProfiling, secretAPI.ScheduleTracing, ]); }); diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 7fb8e8616aff2..fddee3ee337df 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -38,6 +38,7 @@ process.on('unhandledRejection', err => { const { UMD_DEV, UMD_PROD, + UMD_PROFILING, NODE_DEV, NODE_PROD, NODE_PROFILING, @@ -113,6 +114,7 @@ function getBabelConfig(updateBabelOptions, bundleType, filename) { }); case UMD_DEV: case UMD_PROD: + case UMD_PROFILING: case NODE_DEV: case NODE_PROD: case NODE_PROFILING: @@ -158,6 +160,7 @@ function getFormat(bundleType) { switch (bundleType) { case UMD_DEV: case UMD_PROD: + case UMD_PROFILING: return `umd`; case NODE_DEV: case NODE_PROD: @@ -183,6 +186,8 @@ function getFilename(name, globalName, bundleType) { return `${name}.development.js`; case UMD_PROD: return `${name}.production.min.js`; + case UMD_PROFILING: + return `${name}.profiling.min.js`; case NODE_DEV: return `${name}.development.js`; case NODE_PROD: @@ -214,6 +219,7 @@ function isProductionBundleType(bundleType) { return false; case UMD_PROD: case NODE_PROD: + case UMD_PROFILING: case NODE_PROFILING: case FB_WWW_PROD: case FB_WWW_PROFILING: @@ -244,6 +250,7 @@ function isProfilingBundleType(bundleType) { case NODE_PROFILING: case RN_FB_PROFILING: case RN_OSS_PROFILING: + case UMD_PROFILING: return true; default: throw new Error(`Unknown type: ${bundleType}`); @@ -280,7 +287,10 @@ function getPlugins( const forks = Modules.getForks(bundleType, entry, moduleType); const isProduction = isProductionBundleType(bundleType); const isProfiling = isProfilingBundleType(bundleType); - const isUMDBundle = bundleType === UMD_DEV || bundleType === UMD_PROD; + const isUMDBundle = + bundleType === UMD_DEV || + bundleType === UMD_PROD || + bundleType === UMD_PROFILING; const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD || @@ -430,7 +440,9 @@ async function createBundle(bundle, bundleType) { } const shouldBundleDependencies = - bundleType === UMD_DEV || bundleType === UMD_PROD; + bundleType === UMD_DEV || + bundleType === UMD_PROD || + bundleType === UMD_PROFILING; const peerGlobals = Modules.getPeerGlobals(bundle.externals, bundleType); let externals = Object.keys(peerGlobals); if (!shouldBundleDependencies) { @@ -580,6 +592,7 @@ async function buildEverything() { for (const bundle of Bundles.bundles) { await createBundle(bundle, UMD_DEV); await createBundle(bundle, UMD_PROD); + await createBundle(bundle, UMD_PROFILING); await createBundle(bundle, NODE_DEV); await createBundle(bundle, NODE_PROD); await createBundle(bundle, NODE_PROFILING); diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 1279ebbc10f43..2035acf5bfef8 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -3,6 +3,7 @@ const bundleTypes = { UMD_DEV: 'UMD_DEV', UMD_PROD: 'UMD_PROD', + UMD_PROFILING: 'UMD_PROFILING', NODE_DEV: 'NODE_DEV', NODE_PROD: 'NODE_PROD', NODE_PROFILING: 'NODE_PROFILING', @@ -19,6 +20,7 @@ const bundleTypes = { const UMD_DEV = bundleTypes.UMD_DEV; const UMD_PROD = bundleTypes.UMD_PROD; +const UMD_PROFILING = bundleTypes.UMD_PROFILING; const NODE_DEV = bundleTypes.NODE_DEV; const NODE_PROD = bundleTypes.NODE_PROD; const NODE_PROFILING = bundleTypes.NODE_PROFILING; @@ -58,9 +60,9 @@ const bundles = [ bundleTypes: [ UMD_DEV, UMD_PROD, + UMD_PROFILING, NODE_DEV, NODE_PROD, - NODE_PROFILING, FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING, @@ -77,6 +79,7 @@ const bundles = [ bundleTypes: [ UMD_DEV, UMD_PROD, + UMD_PROFILING, NODE_DEV, NODE_PROD, NODE_PROFILING, diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index 9c4f4d024cf57..22ef8ca0c26be 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -6,6 +6,7 @@ const inlinedHostConfigs = require('../shared/inlinedHostConfigs'); const UMD_DEV = bundleTypes.UMD_DEV; const UMD_PROD = bundleTypes.UMD_PROD; +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; @@ -24,7 +25,11 @@ const forks = Object.freeze({ // Optimization: for UMDs, use object-assign polyfill that is already a part // of the React package instead of bundling it again. 'object-assign': (bundleType, entry, dependencies) => { - if (bundleType !== UMD_DEV && bundleType !== UMD_PROD) { + if ( + bundleType !== UMD_DEV && + bundleType !== UMD_PROD && + bundleType !== UMD_PROFILING + ) { // It's only relevant for UMD bundles since that's where the duplication // happens. Other bundles just require('object-assign') anyway. return null; @@ -118,6 +123,7 @@ const forks = Object.freeze({ switch (bundleType) { case UMD_DEV: case UMD_PROD: + case UMD_PROFILING: if (dependencies.indexOf('react') === -1) { // It's only safe to use this fork for modules that depend on React, // because they read the re-exported API from the SECRET_INTERNALS object. @@ -136,6 +142,7 @@ const forks = Object.freeze({ switch (bundleType) { case UMD_DEV: case UMD_PROD: + case UMD_PROFILING: if (dependencies.indexOf('react') === -1) { // It's only safe to use this fork for modules that depend on React, // because they read the re-exported API from the SECRET_INTERNALS object. diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index d222b3fe62ecf..2e3880832dfac 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -5,6 +5,7 @@ const bundleTypes = require('./bundles').bundleTypes; const UMD_DEV = bundleTypes.UMD_DEV; const UMD_PROD = bundleTypes.UMD_PROD; +const UMD_PROFILING = bundleTypes.UMD_PROFILING; // For any external that is used in a DEV-only condition, explicitly // specify whether it has side effects during import or not. This lets @@ -32,7 +33,9 @@ function getPeerGlobals(externals, bundleType) { externals.forEach(name => { if ( !knownGlobals[name] && - (bundleType === UMD_DEV || bundleType === UMD_PROD) + (bundleType === UMD_DEV || + bundleType === UMD_PROD || + bundleType === UMD_PROFILING) ) { throw new Error('Cannot build UMD without a global name for: ' + name); } diff --git a/scripts/rollup/packaging.js b/scripts/rollup/packaging.js index d2c8c96ad289b..d6ca3b937c3ee 100644 --- a/scripts/rollup/packaging.js +++ b/scripts/rollup/packaging.js @@ -12,6 +12,7 @@ const { const { UMD_DEV, UMD_PROD, + UMD_PROFILING, NODE_DEV, NODE_PROD, NODE_PROFILING, @@ -41,6 +42,7 @@ function getBundleOutputPaths(bundleType, filename, packageName) { return [`build/node_modules/${packageName}/cjs/${filename}`]; case UMD_DEV: case UMD_PROD: + case UMD_PROFILING: return [ `build/node_modules/${packageName}/umd/${filename}`, `build/dist/${filename}`, diff --git a/scripts/rollup/wrappers.js b/scripts/rollup/wrappers.js index 2ad177b7086fc..b80e77121fb81 100644 --- a/scripts/rollup/wrappers.js +++ b/scripts/rollup/wrappers.js @@ -5,6 +5,7 @@ const reactVersion = require('../../package.json').version; const UMD_DEV = Bundles.bundleTypes.UMD_DEV; const UMD_PROD = Bundles.bundleTypes.UMD_PROD; +const UMD_PROFILING = Bundles.bundleTypes.UMD_PROFILING; const NODE_DEV = Bundles.bundleTypes.NODE_DEV; const NODE_PROD = Bundles.bundleTypes.NODE_PROD; const NODE_PROFILING = Bundles.bundleTypes.NODE_PROFILING; @@ -49,6 +50,16 @@ ${license} ${source}`; }, + /***************** UMD_PROFILING *****************/ + [UMD_PROFILING](source, globalName, filename, moduleType) { + return `/** @license React v${reactVersion} + * ${filename} + * +${license} + */ +${source}`; + }, + /***************** NODE_DEV *****************/ [NODE_DEV](source, globalName, filename, moduleType) { return `/** @license React v${reactVersion}