diff --git a/fixtures/flight/server/handler.server.js b/fixtures/flight/server/handler.server.js index a51d653c0ab54..251833a52d15b 100644 --- a/fixtures/flight/server/handler.server.js +++ b/fixtures/flight/server/handler.server.js @@ -20,9 +20,10 @@ module.exports = function (req, res) { const App = m.default.default || m.default; res.setHeader('Access-Control-Allow-Origin', '*'); const moduleMap = JSON.parse(data); - const {pipe} = renderToPipeableStream(React.createElement(App), { - clientManifest: moduleMap, - }); + const {pipe} = renderToPipeableStream( + React.createElement(App), + moduleMap + ); pipe(res); } ); diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js b/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js index b0d5d0a2a0beb..be2343121e2a0 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js @@ -27,12 +27,12 @@ type Options = { function renderToReadableStream( model: ReactModel, - webpackMaps: BundlerConfig, + webpackMap: BundlerConfig, options?: Options, ): ReadableStream { const request = createRequest( model, - webpackMaps, + webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js b/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js index d05787fccf830..82ff956c99d72 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js @@ -37,12 +37,12 @@ type PipeableStream = { function renderToPipeableStream( model: ReactModel, - webpackMaps: BundlerConfig, + webpackMap: BundlerConfig, options?: Options, ): PipeableStream { const request = createRequest( model, - webpackMaps, + webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, diff --git a/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js b/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js index 500e79adf7b0a..c662d6d51f243 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js +++ b/packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js @@ -13,9 +13,7 @@ type WebpackMap = { }, }; -export type BundlerConfig = { - clientManifest: WebpackMap, -}; +export type BundlerConfig = WebpackMap; // eslint-disable-next-line no-unused-vars export type ClientReference = { @@ -56,7 +54,7 @@ export function resolveModuleMetaData( clientReference: ClientReference, ): ModuleMetaData { const resolvedModuleData = - config.clientManifest[clientReference.filepath][clientReference.name]; + config[clientReference.filepath][clientReference.name]; if (clientReference.async) { return { id: resolvedModuleData.id, diff --git a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js index 1f3202bdc153b..d2045e9364f3b 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js +++ b/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js @@ -102,9 +102,9 @@ module.exports = function register() { target.default = Object.defineProperties( (function () { throw new Error( - `Attempted to call the default export of ${moduleId} from the server` + + `Attempted to call the default export of ${moduleId} from the server ` + `but it's on the client. It's not possible to invoke a client function from ` + - `the server, it can only be rendered as a Component or passed to props of a` + + `the server, it can only be rendered as a Component or passed to props of a ` + `Client Component.`, ); }: any), diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js index 36c3139c1af3d..89868fe82d055 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js @@ -936,8 +936,8 @@ describe('ReactFlightDOM', () => { }); // We simulate a bug in the Webpack bundler which causes an error on the server. - for (const id in webpackMap.clientManifest) { - Object.defineProperty(webpackMap.clientManifest, id, { + for (const id in webpackMap) { + Object.defineProperty(webpackMap, id, { get: () => { throw new Error('bug in the bundler'); }, diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js index 9e82695f738a1..6dd68c16be9fb 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js @@ -473,14 +473,12 @@ describe('ReactFlightDOMBrowser', () => { const ClientComponentOnTheServer = clientExports(ClientComponent); // In the SSR bundle this module won't exist. We simulate this by deleting it. - const clientId = - webpackMap.clientManifest[ClientComponentOnTheClient.filepath]['*'].id; + const clientId = webpackMap[ClientComponentOnTheClient.filepath]['*'].id; delete webpackModules[clientId]; // Instead, we have to provide a translation from the client meta data to the SSR // meta data. - const ssrMetaData = - webpackMap.clientManifest[ClientComponentOnTheServer.filepath]['*']; + const ssrMetaData = webpackMap[ClientComponentOnTheServer.filepath]['*']; const translationMap = { [clientId]: { '*': ssrMetaData, diff --git a/packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js b/packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js index 80617e9283bbf..607e6e0d6c76c 100644 --- a/packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js +++ b/packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js @@ -13,7 +13,7 @@ const Module = require('module'); let webpackModuleIdx = 0; const webpackModules = {}; const webpackErroredModules = {}; -const webpackMap = {clientManifest: {}}; +const webpackMap = {}; global.__webpack_require__ = function (id) { if (webpackErroredModules[id]) { throw webpackErroredModules[id]; @@ -44,7 +44,7 @@ exports.clientModuleError = function clientModuleError(moduleError) { const idx = '' + webpackModuleIdx++; webpackErroredModules[idx] = moduleError; const path = url.pathToFileURL(idx).href; - webpackMap.clientManifest[path] = { + webpackMap[path] = { '': { id: idx, chunks: [], @@ -65,7 +65,7 @@ exports.clientExports = function clientExports(moduleExports) { const idx = '' + webpackModuleIdx++; webpackModules[idx] = moduleExports; const path = url.pathToFileURL(idx).href; - webpackMap.clientManifest[path] = { + webpackMap[path] = { '': { id: idx, chunks: [], @@ -81,7 +81,7 @@ exports.clientExports = function clientExports(moduleExports) { moduleExports.then( asyncModuleExports => { for (const name in asyncModuleExports) { - webpackMap.clientManifest[path][name] = { + webpackMap[path][name] = { id: idx, chunks: [], name: name, @@ -92,7 +92,7 @@ exports.clientExports = function clientExports(moduleExports) { ); } for (const name in moduleExports) { - webpackMap.clientManifest[path][name] = { + webpackMap[path][name] = { id: idx, chunks: [], name: name,