diff --git a/fixtures/tracking/index.html b/fixtures/tracking/index.html index 8563ae7808c8a..30ec31d43112a 100644 --- a/fixtures/tracking/index.html +++ b/fixtures/tracking/index.html @@ -4,22 +4,34 @@ Test tracking UMD @@ -29,107 +41,33 @@

Test tracking UMD

This fixture tests that the new tracking API is accessible via UMD build using the UMD shim. It does not exhaustively test API functionality, only that the forwarded methods can be called.

-

Tests:

+

+ Before running the tests below, check the console to make sure there are no errors. +

+

+ Tests + +

    -
  1. - +
  2. + Test scheduler API +
  3. +
  4. + Test tracking API
  5. -
  6. - +
  7. + Test tracking subscriptions API
  8. -
  9. - +
  10. + Test end-to-end integration
- - - + + + - + diff --git a/fixtures/tracking/script.js b/fixtures/tracking/script.js new file mode 100644 index 0000000000000..8536ed4929ff7 --- /dev/null +++ b/fixtures/tracking/script.js @@ -0,0 +1,213 @@ +function runTest(listItem, callback) { + try { + callback(); + listItem.className = 'correct'; + listItem.setAttribute('data-value', 'All checks pass'); + } catch (error) { + listItem.className = 'incorrect'; + listItem.setAttribute('data-value', error); + } +} + +function runAllTests() { + try { + checkSchedulerAPI(); + } finally { + try { + checkSchedulerTrackingAPI(); + } finally { + try { + checkSchedulerTrackingSubscriptionsAPI(); + } finally { + checkEndToEndIntegration(); + } + } + } +} + +function checkSchedulerAPI() { + runTest(document.getElementById('checkSchedulerAPI'), () => { + if ( + typeof ReactScheduler === 'undefined' || + typeof ReactScheduler.unstable_now !== 'function' || + typeof ReactScheduler.unstable_scheduleWork !== 'function' || + typeof ReactScheduler.unstable_cancelScheduledWork !== 'function' + ) { + throw 'API is not defined'; + } + + if (ReactScheduler.unstable_now() !== performance.now()) { + throw 'API does not work'; + } + + // There is no real way to verify that the two APIs are connected. + }); +} + +function checkSchedulerTrackingAPI() { + runTest(document.getElementById('checkSchedulerTrackingAPI'), () => { + if ( + typeof ReactSchedulerTracking === 'undefined' || + typeof ReactSchedulerTracking.__getInteractionsRef !== 'function' || + typeof ReactSchedulerTracking.__getSubscriberRef !== 'function' || + typeof ReactSchedulerTracking.unstable_clear !== 'function' || + typeof ReactSchedulerTracking.unstable_getCurrent !== 'function' || + typeof ReactSchedulerTracking.unstable_getThreadID !== 'function' || + typeof ReactSchedulerTracking.unstable_track !== 'function' || + typeof ReactSchedulerTracking.unstable_wrap !== 'function' + ) { + throw 'API is not defined'; + } + + try { + let interactionsSet; + ReactSchedulerTracking.unstable_track('test', 123, () => { + interactionsSet = ReactSchedulerTracking.__getInteractionsRef().current; + }); + if (interactionsSet.size !== 1) { + throw null; + } + const interaction = Array.from(interactionsSet)[0]; + if (interaction.name !== 'test' || interaction.timestamp !== 123) { + throw null; + } + } catch (error) { + throw 'API does not work'; + } + + const ForwardedSchedulerTracking = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .SchedulerTracking; + + if ( + ReactSchedulerTracking.unstable_getThreadID() === + ForwardedSchedulerTracking.unstable_getThreadID() + ) { + throw 'API forwarding is broken'; + } + }); +} + +function checkSchedulerTrackingSubscriptionsAPI() { + runTest( + document.getElementById('checkSchedulerTrackingSubscriptionsAPI'), + () => { + if ( + typeof ReactSchedulerTrackingSubscriptions === 'undefined' || + typeof ReactSchedulerTrackingSubscriptions.unstable_subscribe !== + 'function' || + typeof ReactSchedulerTrackingSubscriptions.unstable_unsubscribe !== + 'function' + ) { + throw 'API is not defined'; + } + + const onInteractionScheduledWorkCompletedCalls = []; + const onInteractionTrackedCalls = []; + const onWorkCanceledCalls = []; + const onWorkScheduledCalls = []; + const onWorkStartedCalls = []; + const onWorkStoppedCalls = []; + const subscriber = { + onInteractionScheduledWorkCompleted: (...args) => + onInteractionScheduledWorkCompletedCalls.push(args), + onInteractionTracked: (...args) => onInteractionTrackedCalls.push(args), + onWorkCanceled: (...args) => onWorkCanceledCalls.push(args), + onWorkScheduled: (...args) => onWorkScheduledCalls.push(args), + onWorkStarted: (...args) => onWorkStartedCalls.push(args), + onWorkStopped: (...args) => onWorkStoppedCalls.push(args), + }; + + try { + ReactSchedulerTrackingSubscriptions.unstable_subscribe(subscriber); + ReactSchedulerTracking.unstable_track('foo', 123, () => {}); + ReactSchedulerTrackingSubscriptions.unstable_unsubscribe(subscriber); + if (onInteractionTrackedCalls.length !== 1) { + throw null; + } + const interaction = onInteractionTrackedCalls[0][0]; + if (interaction.name !== 'foo' || interaction.timestamp !== 123) { + throw null; + } + ReactSchedulerTracking.unstable_track('bar', 456, () => {}); + if (onInteractionTrackedCalls.length !== 1) { + throw null; + } + } catch (error) { + throw 'API does not forward methods'; + } + + const ForwardedSchedulerTrackingSubscriptions = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .SchedulerTrackingSubscriptions; + const ForwardedSchedulerTracking = + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .SchedulerTracking; + + try { + ForwardedSchedulerTrackingSubscriptions.unstable_subscribe(subscriber); + ReactSchedulerTracking.unstable_track('foo', 123, () => {}); + ForwardedSchedulerTracking.unstable_track('bar', 456, () => {}); + ReactSchedulerTrackingSubscriptions.unstable_unsubscribe(subscriber); + if (onInteractionTrackedCalls.length !== 3) { + throw null; + } + const interactionFoo = onInteractionTrackedCalls[1][0]; + const interactionBar = onInteractionTrackedCalls[2][0]; + if ( + interactionFoo.name !== 'foo' || + interactionFoo.timestamp !== 123 || + interactionBar.name !== 'bar' || + interactionBar.timestamp !== 456 + ) { + throw null; + } + ForwardedSchedulerTracking.unstable_track('baz', 789, () => {}); + if (onInteractionTrackedCalls.length !== 3) { + throw null; + } + } catch (error) { + throw 'API forwarding is broken'; + } + } + ); +} + +function checkEndToEndIntegration() { + runTest(document.getElementById('checkEndToEndIntegration'), () => { + try { + const onRenderCalls = []; + const onRender = (...args) => onRenderCalls.push(args); + const container = document.createElement('div'); + + ReactSchedulerTracking.unstable_track('render', 123, () => { + ReactDOM.render( + React.createElement( + React.unstable_Profiler, + {id: 'profiler', onRender}, + React.createElement('div', null, 'hi') + ), + container + ); + }); + + if (container.textContent !== 'hi') { + throw null; + } + + if (onRenderCalls.length !== 1) { + throw null; + } + const call = onRenderCalls[0]; + if (call.length !== 7) { + throw null; + } + const interaction = Array.from(call[6])[0]; + if (interaction.name !== 'render' || interaction.timestamp !== 123) { + throw null; + } + } catch (error) { + throw 'End to end integration is broken'; + } + }); +} diff --git a/packages/react-scheduler/npm/umd/react-scheduler-tracking-subscriptions.js b/packages/react-scheduler/npm/umd/react-scheduler-tracking-subscriptions.js new file mode 100644 index 0000000000000..21f529827d841 --- /dev/null +++ b/packages/react-scheduler/npm/umd/react-scheduler-tracking-subscriptions.js @@ -0,0 +1,39 @@ +/** + * @license React + * + * Copyright (c) 2013-present, Facebook, Inc. + * + * 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.ReactSchedulerTrackingSubscriptions = factory(global)); +})(this, function(global) { + function unstable_subscribe() { + // eslint-disable-next-line max-len + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTrackingSubscriptions.unstable_subscribe.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.SchedulerTrackingSubscriptions.unstable_unsubscribe.apply( + this, + arguments + ); + } + + return Object.freeze({ + unstable_subscribe: unstable_subscribe, + unstable_unsubscribe: unstable_unsubscribe, + }); +}); diff --git a/packages/react-scheduler/npm/umd/react-scheduler-tracking.js b/packages/react-scheduler/npm/umd/react-scheduler-tracking.js new file mode 100644 index 0000000000000..69f7f4a9b9571 --- /dev/null +++ b/packages/react-scheduler/npm/umd/react-scheduler-tracking.js @@ -0,0 +1,77 @@ +/** + * @license React + * + * Copyright (c) 2013-present, Facebook, Inc. + * + * 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.ReactSchedulerTracking = factory(global)); +})(this, function(global) { + function __getInteractionsRef() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getInteractionsRef.apply( + this, + arguments + ); + } + + function __getSubscriberRef() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getSubscriberRef.apply( + this, + arguments + ); + } + + function unstable_clear() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_clear.apply( + this, + arguments + ); + } + + function unstable_getCurrent() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_getCurrent.apply( + this, + arguments + ); + } + + function unstable_getThreadID() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_getThreadID.apply( + this, + arguments + ); + } + + function unstable_track() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_track.apply( + this, + arguments + ); + } + + function unstable_wrap() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_wrap.apply( + this, + arguments + ); + } + + return Object.freeze({ + __getInteractionsRef: __getInteractionsRef, + __getSubscriberRef: __getSubscriberRef, + unstable_clear: unstable_clear, + unstable_getCurrent: unstable_getCurrent, + unstable_getThreadID: unstable_getThreadID, + unstable_track: unstable_track, + unstable_wrap: unstable_wrap, + }); +}); diff --git a/packages/react-scheduler/npm/umd/react-scheduler.js b/packages/react-scheduler/npm/umd/react-scheduler.js new file mode 100644 index 0000000000000..f02ccba6bfbd3 --- /dev/null +++ b/packages/react-scheduler/npm/umd/react-scheduler.js @@ -0,0 +1,45 @@ +/** + * @license React + * + * Copyright (c) 2013-present, Facebook, Inc. + * + * 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.ReactScheduler = factory(global)); +})(this, function(global) { + function unstable_now() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_now.apply( + this, + arguments + ); + } + + function unstable_scheduleWork() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_scheduleWork.apply( + this, + arguments + ); + } + + function unstable_cancelScheduledWork() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_cancelScheduledWork.apply( + this, + arguments + ); + } + + return Object.freeze({ + unstable_now: unstable_now, + unstable_scheduleWork: unstable_scheduleWork, + unstable_cancelScheduledWork: unstable_cancelScheduledWork, + }); +}); diff --git a/packages/react/src/ReactSharedInternals.js b/packages/react/src/ReactSharedInternals.js index 80dd92464cf90..77190c6dd0c9f 100644 --- a/packages/react/src/ReactSharedInternals.js +++ b/packages/react/src/ReactSharedInternals.js @@ -7,22 +7,22 @@ import assign from 'object-assign'; import { - unstable_cancelScheduledWork as cancelScheduledWork, - unstable_now as now, - unstable_scheduleWork as scheduleWork, + unstable_cancelScheduledWork, + unstable_now, + unstable_scheduleWork, } from 'react-scheduler'; import { __getInteractionsRef, __getSubscriberRef, - unstable_clear as clear, - unstable_getCurrent as getCurrent, - unstable_getThreadID as getThreadID, - unstable_track as track, - unstable_wrap as wrap, + unstable_clear, + unstable_getCurrent, + unstable_getThreadID, + unstable_track, + unstable_wrap, } from 'react-scheduler/tracking'; import { - unstable_subscribe as subscribe, - unstable_unsubscribe as unsubscribe, + unstable_subscribe, + unstable_unsubscribe, } from 'react-scheduler/tracking-subscriptions'; import ReactCurrentOwner from './ReactCurrentOwner'; import ReactDebugCurrentFrame from './ReactDebugCurrentFrame'; @@ -41,22 +41,22 @@ if (__UMD__) { // CJS bundles use the shared NPM package. Object.assign(ReactSharedInternals, { Scheduler: { - cancelScheduledWork, - now, - scheduleWork, + unstable_cancelScheduledWork, + unstable_now, + unstable_scheduleWork, }, SchedulerTracking: { __getInteractionsRef, __getSubscriberRef, - clear, - getCurrent, - getThreadID, - track, - wrap, + unstable_clear, + unstable_getCurrent, + unstable_getThreadID, + unstable_track, + unstable_wrap, }, SchedulerTrackingSubscriptions: { - subscribe, - unsubscribe, + unstable_subscribe, + unstable_unsubscribe, }, }); } diff --git a/packages/shared/ReactScheduler.js b/packages/shared/ReactScheduler.js deleted file mode 100644 index 1e279f550bffa..0000000000000 --- a/packages/shared/ReactScheduler.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -'use strict'; -import { - unstable_now as now, - unstable_scheduleWork as scheduleWork, - unstable_cancelScheduledWork as cancelScheduledWork, -} from 'react-scheduler'; - -export {now, scheduleWork, cancelScheduledWork}; diff --git a/packages/shared/forks/ReactScheduler.umd.js b/packages/shared/forks/ReactScheduler.umd.js index cb074a848240b..81adf456e03e3 100644 --- a/packages/shared/forks/ReactScheduler.umd.js +++ b/packages/shared/forks/ReactScheduler.umd.js @@ -9,23 +9,12 @@ import React from 'react'; -export function unstable_now() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.now.apply( - this, - arguments, - ); -} +const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; -export function unstable_scheduleWork() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.scheduleWork.apply( - this, - arguments, - ); -} +const { + unstable_cancelScheduledWork, + unstable_now, + unstable_scheduleWork, +} = ReactInternals.Scheduler; -export function unstable_cancelScheduledWork() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.cancelScheduledWork.apply( - this, - arguments, - ); -} +export {unstable_cancelScheduledWork, unstable_now, unstable_scheduleWork}; diff --git a/packages/shared/forks/ReactScheduler.www.js b/packages/shared/forks/ReactScheduler.www.js index d18736eb838c3..0df242dfb1e9b 100644 --- a/packages/shared/forks/ReactScheduler.www.js +++ b/packages/shared/forks/ReactScheduler.www.js @@ -6,10 +6,10 @@ */ 'use strict'; -const {now, scheduleWork, cancelScheduledWork} = require('customSchedule'); +const { + unstable_now, + unstable_scheduleWork, + unstable_cancelScheduledWork, +} = require('customSchedule'); -export { - now as unstable_now, - scheduleWork as unstable_scheduleWork, - cancelScheduledWork as unstable_cancelScheduledWork, -}; +export {unstable_now, unstable_scheduleWork, unstable_cancelScheduledWork}; diff --git a/packages/shared/forks/ReactSchedulerTracking.umd.js b/packages/shared/forks/ReactSchedulerTracking.umd.js index 358bf3e55b28e..2d4b84ad536f6 100644 --- a/packages/shared/forks/ReactSchedulerTracking.umd.js +++ b/packages/shared/forks/ReactSchedulerTracking.umd.js @@ -9,51 +9,24 @@ import React from 'react'; -export function __getInteractionsRef() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getInteractionsRef.apply( - this, - arguments, - ); -} - -export function __getSubscriberRef() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getSubscriberRef.apply( - this, - arguments, - ); -} - -export function unstable_clear() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.clear.apply( - this, - arguments, - ); -} - -export function unstable_getCurrent() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.getCurrent.apply( - this, - arguments, - ); -} - -export function unstable_getThreadID() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.getThreadID.apply( - this, - arguments, - ); -} - -export function unstable_track() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.track.apply( - this, - arguments, - ); -} - -export function unstable_wrap() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.wrap.apply( - this, - arguments, - ); -} +const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + +const { + __getInteractionsRef, + __getSubscriberRef, + unstable_clear, + unstable_getCurrent, + unstable_getThreadID, + unstable_track, + unstable_wrap, +} = ReactInternals.SchedulerTracking; + +export { + __getInteractionsRef, + __getSubscriberRef, + unstable_clear, + unstable_getCurrent, + unstable_getThreadID, + unstable_track, + unstable_wrap, +}; diff --git a/packages/shared/forks/ReactSchedulerTrackingSubscriptions.umd.js b/packages/shared/forks/ReactSchedulerTrackingSubscriptions.umd.js index dc6e40bfe6c7f..1cbf6ccee8943 100644 --- a/packages/shared/forks/ReactSchedulerTrackingSubscriptions.umd.js +++ b/packages/shared/forks/ReactSchedulerTrackingSubscriptions.umd.js @@ -9,16 +9,11 @@ import React from 'react'; -export function unstable_subscribe() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTrackingSubscriptions.subscribe.apply( - this, - arguments, - ); -} +const ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; -export function unstable_unsubscribe() { - return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTrackingSubscriptions.unsubscribe.apply( - this, - arguments, - ); -} +const { + unstable_subscribe, + unstable_unsubscribe, +} = ReactInternals.SchedulerTrackingSubscriptions; + +export {unstable_subscribe, unstable_unsubscribe}; diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 167c5ff17bcec..504dc9ece0712 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -383,14 +383,7 @@ const bundles = [ /******* React Scheduler (experimental) *******/ { label: 'react-scheduler', - bundleTypes: [ - UMD_DEV, - UMD_PROD, - NODE_DEV, - NODE_PROD, - FB_WWW_DEV, - FB_WWW_PROD, - ], + bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD], moduleType: ISOMORPHIC, entry: 'react-scheduler', global: 'ReactScheduler', @@ -400,8 +393,6 @@ const bundles = [ { label: 'react-scheduler-tracking', bundleTypes: [ - UMD_DEV, - UMD_PROD, FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING, @@ -418,8 +409,6 @@ const bundles = [ { label: 'react-scheduler-tracking-subscriptions', bundleTypes: [ - UMD_DEV, - UMD_PROD, FB_WWW_DEV, FB_WWW_PROD, FB_WWW_PROFILING, @@ -430,7 +419,7 @@ const bundles = [ moduleType: ISOMORPHIC, entry: 'react-scheduler/tracking-subscriptions', global: 'ReactSchedulerTrackingSubscriptions', - externals: ['react-scheduler-tracking'], + externals: ['react-scheduler', 'react-scheduler/tracking'], }, ]; diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index 4152ab037f8ee..f82e79dbb2327 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -123,8 +123,7 @@ const forks = Object.freeze({ case UMD_DEV: case UMD_PROD: if (dependencies.indexOf('react') === -1) { - // We can only apply the optimizations to bundle that depend on React - // because we read assign() from an object exposed on React internals. + // For CJS bundles, use the shared NPM package. return null; } // Optimization: for UMDs, use the API that is already a part of the React @@ -140,8 +139,7 @@ const forks = Object.freeze({ case UMD_DEV: case UMD_PROD: if (dependencies.indexOf('react') === -1) { - // We can only apply the optimizations to bundle that depend on React - // because we read assign() from an object exposed on React internals. + // For CJS bundles, use the shared NPM package. return null; } // Optimization: for UMDs, use the API that is already a part of the React @@ -161,8 +159,7 @@ const forks = Object.freeze({ case UMD_DEV: case UMD_PROD: if (dependencies.indexOf('react') === -1) { - // We can only apply the optimizations to bundle that depend on React - // because we read assign() from an object exposed on React internals. + // For CJS bundles, use the shared NPM package. return null; } // Optimization: for UMDs, use the API that is already a part of the React diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index ab5103d159483..439838423a1df 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -23,8 +23,9 @@ const importSideEffects = Object.freeze({ const knownGlobals = Object.freeze({ react: 'React', 'react-dom': 'ReactDOM', - 'react-scheduler-tracking': 'ReactSchedulerTracking', - 'react-scheduler-tracking-subscriptions': + 'react-scheduler': 'ReactScheduler', + 'react-scheduler/tracking': 'ReactSchedulerTracking', + 'react-scheduler/tracking-subscriptions': 'ReactSchedulerTrackingSubscriptions', });