Revert "Move the Webpack manifest config to one level deeper (#26083)" (#26111)
Just kidding. We're not going to need any other fields afaik after all.
Sebastian Markbåge committed
Feb 6, 2023 at 10:50 UTC
4bf2113a153522904e34e7a2cef3c1de1c10cbec
8 files changed
+21
-24
fixtures/flight/server/handler.server.js
+4
-3
@@ -20,9 +20,10 @@ module.exports = function (req, res) {
20
const App = m.default.default || m.default;
21
res.setHeader('Access-Control-Allow-Origin', '*');
22
const moduleMap = JSON.parse(data);
23
- const {pipe} = renderToPipeableStream(React.createElement(App), {
24
- clientManifest: moduleMap,
25
- });
23
+ const {pipe} = renderToPipeableStream(
24
+ React.createElement(App),
25
+ moduleMap
26
+ );
27
pipe(res);
28
}
29
);
packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js
+2
-2
@@ -27,12 +27,12 @@ type Options = {
27
28
function renderToReadableStream(
29
model: ReactModel,
30
- webpackMaps: BundlerConfig,
30
+ webpackMap: BundlerConfig,
31
options?: Options,
32
): ReadableStream {
33
const request = createRequest(
34
model,
35
- webpackMaps,
35
+ webpackMap,
36
options ? options.onError : undefined,
37
options ? options.context : undefined,
38
options ? options.identifierPrefix : undefined,
packages/react-server-dom-webpack/src/ReactFlightDOMServerNode.js
+2
-2
@@ -37,12 +37,12 @@ type PipeableStream = {
37
38
function renderToPipeableStream(
39
model: ReactModel,
40
- webpackMaps: BundlerConfig,
40
+ webpackMap: BundlerConfig,
41
options?: Options,
42
): PipeableStream {
43
const request = createRequest(
44
model,
45
- webpackMaps,
45
+ webpackMap,
46
options ? options.onError : undefined,
47
options ? options.context : undefined,
48
options ? options.identifierPrefix : undefined,
packages/react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js
+2
-4
@@ -13,9 +13,7 @@ type WebpackMap = {
13
},
14
};
15
16
-export type BundlerConfig = {
17
- clientManifest: WebpackMap,
18
-};
16
+export type BundlerConfig = WebpackMap;
17
18
// eslint-disable-next-line no-unused-vars
19
export type ClientReference<T> = {
@@ -56,7 +54,7 @@ export function resolveModuleMetaData<T>(
54
clientReference: ClientReference<T>,
55
): ModuleMetaData {
56
const resolvedModuleData =
59
- config.clientManifest[clientReference.filepath][clientReference.name];
57
+ config[clientReference.filepath][clientReference.name];
58
if (clientReference.async) {
59
return {
60
id: resolvedModuleData.id,
packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js
+2
-2
@@ -102,9 +102,9 @@ module.exports = function register() {
102
target.default = Object.defineProperties(
103
(function () {
104
throw new Error(
105
- `Attempted to call the default export of ${moduleId} from the server` +
105
+ `Attempted to call the default export of ${moduleId} from the server ` +
106
`but it's on the client. It's not possible to invoke a client function from ` +
107
- `the server, it can only be rendered as a Component or passed to props of a` +
107
+ `the server, it can only be rendered as a Component or passed to props of a ` +
108
`Client Component.`,
109
);
110
}: any),
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js
+2
-2
@@ -936,8 +936,8 @@ describe('ReactFlightDOM', () => {
936
});
937
938
// We simulate a bug in the Webpack bundler which causes an error on the server.
939
- for (const id in webpackMap.clientManifest) {
940
- Object.defineProperty(webpackMap.clientManifest, id, {
939
+ for (const id in webpackMap) {
940
+ Object.defineProperty(webpackMap, id, {
941
get: () => {
942
throw new Error('bug in the bundler');
943
},
packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js
+2
-4
@@ -473,14 +473,12 @@ describe('ReactFlightDOMBrowser', () => {
473
const ClientComponentOnTheServer = clientExports(ClientComponent);
474
475
// In the SSR bundle this module won't exist. We simulate this by deleting it.
476
- const clientId =
477
- webpackMap.clientManifest[ClientComponentOnTheClient.filepath]['*'].id;
476
+ const clientId = webpackMap[ClientComponentOnTheClient.filepath]['*'].id;
477
delete webpackModules[clientId];
478
479
// Instead, we have to provide a translation from the client meta data to the SSR
480
// meta data.
482
- const ssrMetaData =
483
- webpackMap.clientManifest[ClientComponentOnTheServer.filepath]['*'];
481
+ const ssrMetaData = webpackMap[ClientComponentOnTheServer.filepath]['*'];
482
const translationMap = {
483
[clientId]: {
484
'*': ssrMetaData,
packages/react-server-dom-webpack/src/__tests__/utils/WebpackMock.js
+5
-5
@@ -13,7 +13,7 @@ const Module = require('module');
13
let webpackModuleIdx = 0;
14
const webpackModules = {};
15
const webpackErroredModules = {};
16
-const webpackMap = {clientManifest: {}};
16
+const webpackMap = {};
17
global.__webpack_require__ = function (id) {
18
if (webpackErroredModules[id]) {
19
throw webpackErroredModules[id];
@@ -44,7 +44,7 @@ exports.clientModuleError = function clientModuleError(moduleError) {
44
const idx = '' + webpackModuleIdx++;
45
webpackErroredModules[idx] = moduleError;
46
const path = url.pathToFileURL(idx).href;
47
- webpackMap.clientManifest[path] = {
47
+ webpackMap[path] = {
48
'': {
49
id: idx,
50
chunks: [],
@@ -65,7 +65,7 @@ exports.clientExports = function clientExports(moduleExports) {
65
const idx = '' + webpackModuleIdx++;
66
webpackModules[idx] = moduleExports;
67
const path = url.pathToFileURL(idx).href;
68
- webpackMap.clientManifest[path] = {
68
+ webpackMap[path] = {
69
'': {
70
id: idx,
71
chunks: [],
@@ -81,7 +81,7 @@ exports.clientExports = function clientExports(moduleExports) {
81
moduleExports.then(
82
asyncModuleExports => {
83
for (const name in asyncModuleExports) {
84
- webpackMap.clientManifest[path][name] = {
84
+ webpackMap[path][name] = {
85
id: idx,
86
chunks: [],
87
name: name,
@@ -92,7 +92,7 @@ exports.clientExports = function clientExports(moduleExports) {
92
);
93
}
94
for (const name in moduleExports) {
95
- webpackMap.clientManifest[path][name] = {
95
+ webpackMap[path][name] = {
96
id: idx,
97
chunks: [],
98
name: name,