Skip to content

Commit

Permalink
Revert "Move the Webpack manifest config to one level deeper (#26083)" (
Browse files Browse the repository at this point in the history
#26111)

Just kidding. We're not going to need any other fields afaik after all.
  • Loading branch information
sebmarkbage authored Feb 6, 2023
1 parent 855b77c commit 4bf2113
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
7 changes: 4 additions & 3 deletions fixtures/flight/server/handler.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
Expand Down Expand Up @@ -56,7 +54,7 @@ export function resolveModuleMetaData<T>(
clientReference: ClientReference<T>,
): ModuleMetaData {
const resolvedModuleData =
config.clientManifest[clientReference.filepath][clientReference.name];
config[clientReference.filepath][clientReference.name];
if (clientReference.async) {
return {
id: resolvedModuleData.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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: [],
Expand All @@ -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: [],
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 4bf2113

Please sign in to comment.