diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 008c7d74e1..377e241db3 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -147,7 +147,12 @@ function getCommonJsConfig(bundleType) { // ], // }; // change of plan: let's bundle them again - return {}; + return { + ignore: [ + 'react/lib/ReactCurrentOwner', + 'ReactCurrentOwner', + ], + }; } } diff --git a/scripts/rollup/forwarding/ReactCurrentOwner.js b/scripts/rollup/forwarding/ReactCurrentOwner.js index ca1f92cd86..aaff25ffa3 100644 --- a/scripts/rollup/forwarding/ReactCurrentOwner.js +++ b/scripts/rollup/forwarding/ReactCurrentOwner.js @@ -6,14 +6,25 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule ReactCurrentOwner - * @flow + * */ 'use strict'; -const { - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, -} = require('React-fb'); +/** + * Keeps track of the current owner. + * + * The current owner is the component who should own any components that are + * currently being constructed. + */ +var ReactCurrentOwner = { -module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; + /** + * @internal + * @type {ReactComponent} + */ + current: null, + +}; + +module.exports = ReactCurrentOwner; diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index 7bc6aad3cc..3f843b83a4 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -40,18 +40,35 @@ function getExternalModules(bundleType) { } } -function getInternalModules() { - return { - // we tell Rollup where these files are located internally, otherwise - // it doesn't pick them up and assumes they're external - reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'), - 'ReactCurrentOwner': resolve('./src/isomorphic/classic/element/ReactCurrentOwner.js'), - 'ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'), - 'react/lib/ReactCurrentOwner': resolve('./src/isomorphic/classic/element/ReactCurrentOwner.js'), - 'react/lib/checkPropTypes': resolve('./src/isomorphic/classic/types/checkPropTypes.js'), - 'react/lib/ReactDebugCurrentFrame': resolve('./src/isomorphic/classic/element/ReactDebugCurrentFrame.js'), - 'react/lib/ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'), - }; +function getInternalModules(bundleType) { + switch (bundleType) { + case bundleTypes.DEV: + case bundleTypes.PROD: + return { + // we tell Rollup where these files are located internally, otherwise + // it doesn't pick them up and assumes they're external + 'ReactCurrentOwner': resolve('./src/isomorphic/classic/element/ReactCurrentOwner.js'), + 'react/lib/ReactCurrentOwner': resolve('./src/isomorphic/classic/element/ReactCurrentOwner.js'), + + // + reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'), + 'ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'), + 'react/lib/checkPropTypes': resolve('./src/isomorphic/classic/types/checkPropTypes.js'), + 'react/lib/ReactDebugCurrentFrame': resolve('./src/isomorphic/classic/element/ReactDebugCurrentFrame.js'), + 'react/lib/ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'), + }; + case bundleTypes.NODE: + case bundleTypes.FB: + return { + // we tell Rollup where these files are located internally, otherwise + // it doesn't pick them up and assumes they're external + reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'), + 'ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'), + 'react/lib/checkPropTypes': resolve('./src/isomorphic/classic/types/checkPropTypes.js'), + 'react/lib/ReactDebugCurrentFrame': resolve('./src/isomorphic/classic/element/ReactDebugCurrentFrame.js'), + 'react/lib/ReactComponentTreeHook': resolve('./src/isomorphic/hooks/ReactComponentTreeHook.js'), + }; + } } function replaceInternalModules(bundleType) { @@ -128,6 +145,7 @@ function replaceFbjsModuleAliases(bundleType) { 'fbjs/lib/ExecutionEnvironment': 'ExecutionEnvironment', 'fbjs/lib/createNodesFromMarkup': 'createNodesFromMarkup', 'fbjs/lib/performanceNow': 'performanceNow', + 'react/lib/ReactCurrentOwner': 'ReactCurrentOwner', "'react'": "'React'", }; }