Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/facebook/react into update-…
Browse files Browse the repository at this point in the history
…rollup
  • Loading branch information
ymqy committed Feb 7, 2023
2 parents 3b43cbd + 1445acf commit fffa57b
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 154 deletions.
195 changes: 67 additions & 128 deletions .circleci/config.yml

Large diffs are not rendered by default.

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
4 changes: 2 additions & 2 deletions scripts/shared/inlinedHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module.exports = [
{
shortName: 'dom',
shortName: 'dom-node',
entryPoints: [
'react-dom',
'react-dom/unstable_testing',
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = [
isServerSupported: true,
},
{
shortName: 'bun',
shortName: 'dom-bun',
entryPoints: ['react-dom', 'react-dom/src/server/ReactDOMFizzServerBun.js'],
paths: [
'react-dom',
Expand Down

0 comments on commit fffa57b

Please sign in to comment.