From 9da7d303601a38ff11ec5593a4a56313a4098cc2 Mon Sep 17 00:00:00 2001 From: mofeiZ <34200447+mofeiZ@users.noreply.github.com> Date: Thu, 3 Nov 2022 11:15:29 -0400 Subject: [PATCH] [ServerRenderer] Move fizz external runtime implementation to react-dom-bindings (#25617) Following [comment](https://github.com/facebook/react/pull/25437#discussion_r1010944983) in #25437 , the external runtime implementation should be moved from `react-dom` to `react-dom-bindings`. I did have a question here: I set the entrypoint to `react-dom/unstable_server-external-runtime.js`, since a.) I was following #25436 as an example and b.) `react-dom-bindings` was missing a `README.md` and `npm/`. This also involved adding the external runtime to `package.json`. However, the external runtime isn't really a `react-dom` entrypoint. Is this change alright, or should I change the bundling code instead? ## How did you test this change? --- .../src/server/ReactDOMServerExternalRuntime.js | 2 +- packages/react-dom/package.json | 1 + packages/react-dom/unstable_server-external-runtime.js | 2 +- scripts/rollup/bundles.js | 2 +- scripts/shared/inlinedHostConfigs.js | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) rename packages/{react-dom => react-dom-bindings}/src/server/ReactDOMServerExternalRuntime.js (89%) diff --git a/packages/react-dom/src/server/ReactDOMServerExternalRuntime.js b/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js similarity index 89% rename from packages/react-dom/src/server/ReactDOMServerExternalRuntime.js rename to packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js index 1260df97965d1..01f53697e2e5f 100644 --- a/packages/react-dom/src/server/ReactDOMServerExternalRuntime.js +++ b/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js @@ -11,7 +11,7 @@ import { completeBoundaryWithStyles, completeBoundary, completeSegment, -} from '../../../react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSet'; +} from './fizz-instruction-set/ReactDOMFizzInstructionSet'; // Intentionally does nothing. Implementation will be added in future PR. // eslint-disable-next-line no-unused-vars diff --git a/packages/react-dom/package.json b/packages/react-dom/package.json index baa9032ef4c62..ee675b040a9db 100644 --- a/packages/react-dom/package.json +++ b/packages/react-dom/package.json @@ -65,6 +65,7 @@ "./profiling": "./profiling.js", "./test-utils": "./test-utils.js", "./unstable_testing": "./unstable_testing.js", + "./unstable_server-external-runtime": "./unstable_server-external-runtime.js", "./src/*": "./src/*", "./package.json": "./package.json" }, diff --git a/packages/react-dom/unstable_server-external-runtime.js b/packages/react-dom/unstable_server-external-runtime.js index 1f23240f15541..f2b257fbf49aa 100644 --- a/packages/react-dom/unstable_server-external-runtime.js +++ b/packages/react-dom/unstable_server-external-runtime.js @@ -7,4 +7,4 @@ * @flow */ -export * from 'react-dom/src/server/ReactDOMServerExternalRuntime'; +export * from 'react-dom-bindings/src/server/ReactDOMServerExternalRuntime'; diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 6563bb62b204b..df208162b9b60 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -291,7 +291,7 @@ const bundles = [ { bundleTypes: [BROWSER_SCRIPT], moduleType: RENDERER, - entry: 'react-dom/src/server/ReactDOMServerExternalRuntime.js', + entry: 'react-dom/unstable_server-external-runtime', outputPath: 'unstable_server-external-runtime.js', global: 'ReactDOMServerExternalRuntime', minifyWithProdErrorCodes: false, diff --git a/scripts/shared/inlinedHostConfigs.js b/scripts/shared/inlinedHostConfigs.js index 9e978c80c25a1..74ba7bcf4a03c 100644 --- a/scripts/shared/inlinedHostConfigs.js +++ b/scripts/shared/inlinedHostConfigs.js @@ -15,7 +15,7 @@ module.exports = [ 'react-dom/src/server/ReactDOMFizzServerNode.js', 'react-dom/static.node', 'react-dom/server-rendering-stub', - 'react-dom/src/server/ReactDOMServerExternalRuntime.js', + 'react-dom/unstable_server-external-runtime', 'react-server-dom-webpack/server.node', 'react-server-dom-webpack/client', ], @@ -53,7 +53,7 @@ module.exports = [ 'react-dom/src/server/ReactDOMFizzServerBrowser.js', 'react-dom/static.browser', 'react-dom/server-rendering-stub', - 'react-dom/src/server/ReactDOMServerExternalRuntime.js', + 'react-dom/unstable_server-external-runtime', 'react-server-dom-webpack/server.browser', 'react-server-dom-webpack/client', ],