From a110dc21dd62ebe8dc6260d3a541974028ebe921 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Fri, 8 May 2020 11:19:36 -0700 Subject: [PATCH] Remove unnecessary ReactMutableSource fork --- packages/react-dom/src/client/ReactDOMRoot.js | 4 ++-- .../src/ReactFiberReconciler.js | 6 +++++ .../src/ReactFiberReconciler.new.js | 1 + .../src/ReactFiberReconciler.old.js | 1 + .../src/ReactMutableSource.js | 24 ------------------- scripts/jest/setupHostConfigs.js | 8 ------- scripts/rollup/forks.js | 20 ---------------- 7 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 packages/react-reconciler/src/ReactMutableSource.js diff --git a/packages/react-dom/src/client/ReactDOMRoot.js b/packages/react-dom/src/client/ReactDOMRoot.js index 34a3223a0cd6e..928cfd3543ed0 100644 --- a/packages/react-dom/src/client/ReactDOMRoot.js +++ b/packages/react-dom/src/client/ReactDOMRoot.js @@ -29,8 +29,6 @@ export type RootOptions = { ... }; -import {findHostInstanceWithNoPortals} from 'react-reconciler/src/ReactFiberReconciler'; -import {registerMutableSourceForHydration} from 'react-reconciler/src/ReactMutableSource'; import { isContainerMarkedAsRoot, markContainerAsRoot, @@ -48,6 +46,8 @@ import {ensureListeningTo} from './ReactDOMComponent'; import { createContainer, updateContainer, + findHostInstanceWithNoPortals, + registerMutableSourceForHydration, } from 'react-reconciler/src/ReactFiberReconciler'; import invariant from 'shared/invariant'; import { diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js index 78992d9d7837c..6cc795b2ed6e3 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.js @@ -49,6 +49,7 @@ import { findBoundingRects as findBoundingRects_old, focusWithin as focusWithin_old, observeVisibleRects as observeVisibleRects_old, + registerMutableSourceForHydration as registerMutableSourceForHydration_old, } from './ReactFiberReconciler.old'; import { @@ -86,6 +87,7 @@ import { findBoundingRects as findBoundingRects_new, focusWithin as focusWithin_new, observeVisibleRects as observeVisibleRects_new, + registerMutableSourceForHydration as registerMutableSourceForHydration_new, } from './ReactFiberReconciler.new'; export const createContainer = enableNewReconciler @@ -186,3 +188,7 @@ export const focusWithin = enableNewReconciler export const observeVisibleRects = enableNewReconciler ? observeVisibleRects_new : observeVisibleRects_old; + +export const registerMutableSourceForHydration = enableNewReconciler + ? registerMutableSourceForHydration_new + : registerMutableSourceForHydration_old; diff --git a/packages/react-reconciler/src/ReactFiberReconciler.new.js b/packages/react-reconciler/src/ReactFiberReconciler.new.js index ded0241bb2b87..bb039e4dd0365 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.new.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.new.js @@ -87,6 +87,7 @@ import { findHostInstancesForRefresh, } from './ReactFiberHotReloading.new'; +export {registerMutableSourceForHydration} from './ReactMutableSource.new'; export {createPortal} from './ReactPortal'; export { createComponentSelector, diff --git a/packages/react-reconciler/src/ReactFiberReconciler.old.js b/packages/react-reconciler/src/ReactFiberReconciler.old.js index 8646598564c30..68d3fbd206c55 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.old.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.old.js @@ -85,6 +85,7 @@ import { findHostInstancesForRefresh, } from './ReactFiberHotReloading.old'; +export {registerMutableSourceForHydration} from './ReactMutableSource.old'; export {createPortal} from './ReactPortal'; export { createComponentSelector, diff --git a/packages/react-reconciler/src/ReactMutableSource.js b/packages/react-reconciler/src/ReactMutableSource.js deleted file mode 100644 index 0b48c6183c3fb..0000000000000 --- a/packages/react-reconciler/src/ReactMutableSource.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 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. - * - * @flow - */ - -import {enableNewReconciler} from 'shared/ReactFeatureFlags'; - -// The entry file imports either the old or new version of mutable source. -// This is necessary since ReactDOMRoot imports this module directly. -// Note that it's not possible to export all of the API methods, -// as the new and old implementations fork slightly (due to the lanes refactor). -// It's only necessary to export the subset of the API required by ReactDOMRoot. - -import {registerMutableSourceForHydration as registerMutableSourceForHydration_old} from './ReactMutableSource.old'; - -import {registerMutableSourceForHydration as registerMutableSourceForHydration_new} from './ReactMutableSource.new'; - -export const registerMutableSourceForHydration = enableNewReconciler - ? registerMutableSourceForHydration_new - : registerMutableSourceForHydration_old; diff --git a/scripts/jest/setupHostConfigs.js b/scripts/jest/setupHostConfigs.js index 7f525dee4891e..9a4af65cf0c59 100644 --- a/scripts/jest/setupHostConfigs.js +++ b/scripts/jest/setupHostConfigs.js @@ -10,14 +10,6 @@ jest.mock('react-reconciler/src/ReactFiberReconciler', () => { ); }); -jest.mock('react-reconciler/src/ReactMutableSource', () => { - return require.requireActual( - __VARIANT__ - ? 'react-reconciler/src/ReactMutableSource.new' - : 'react-reconciler/src/ReactMutableSource.old' - ); -}); - // When testing the custom renderer code path through `react-reconciler`, // turn the export into a function, and use the argument as host config. const shimHostConfigPath = 'react-reconciler/src/ReactFiberHostConfig'; diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index 93e12fe04dbd8..b0319333ea80d 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -280,26 +280,6 @@ const forks = Object.freeze({ return 'react-reconciler/src/ReactFiberReconciler.old.js'; }, - 'react-reconciler/src/ReactMutableSource': ( - bundleType, - entry, - dependencies, - moduleType, - bundle - ) => { - if (bundle.enableNewReconciler) { - switch (bundleType) { - case FB_WWW_DEV: - case FB_WWW_PROD: - case FB_WWW_PROFILING: - // Use the forked version of the reconciler - return 'react-reconciler/src/ReactMutableSource.new.js'; - } - } - // Otherwise, use the non-forked version. - return 'react-reconciler/src/ReactMutableSource.old.js'; - }, - 'react-reconciler/src/ReactFiberHotReloading': ( bundleType, entry,