From 2ccfa657d9529cab25eaa25144efc64df12b13c7 Mon Sep 17 00:00:00 2001 From: lauren Date: Mon, 5 Dec 2022 12:08:28 -0800 Subject: [PATCH] Fork ReactDOMSharedInternals for www (#25791) This isn't the right way to do this, but internally we have some restrictions so we need to add an indirection. Let's land this now so we can catch up our sync and then fix forward from there. Co-authored-by: Jan Kassens --- .../shared/forks/ReactDOMSharedInternals.www.js | 16 ++++++++++++++++ scripts/rollup/forks.js | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 packages/shared/forks/ReactDOMSharedInternals.www.js diff --git a/packages/shared/forks/ReactDOMSharedInternals.www.js b/packages/shared/forks/ReactDOMSharedInternals.www.js new file mode 100644 index 0000000000000..41f52fca4c6c6 --- /dev/null +++ b/packages/shared/forks/ReactDOMSharedInternals.www.js @@ -0,0 +1,16 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + */ + +// $FlowIgnore[cannot-resolve-module] provided by www +const ReactDOM = require('ReactDOMComet'); + +const ReactDOMSharedInternals = + ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + +export default ReactDOMSharedInternals; diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index 93833be1467b4..db046be29ac2d 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -70,6 +70,14 @@ const forks = Object.freeze({ if (entry === 'react-dom' || entry === 'react-dom/server-rendering-stub') { return './packages/react-dom/src/ReactDOMSharedInternals.js'; } + switch (bundleType) { + case FB_WWW_DEV: + case FB_WWW_PROD: + case FB_WWW_PROFILING: + return './packages/shared/forks/ReactDOMSharedInternals.www.js'; + default: + break; + } if ( !entry.startsWith('react-dom/') && dependencies.indexOf('react-dom') === -1