-
Notifications
You must be signed in to change notification settings - Fork 48.7k
[Flight] Build node-webstreams version of bundled webpack server #33456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export {default as rendererVersion} from 'shared/ReactVersion'; | ||
export const rendererPackageName = 'react-server-dom-webpack'; | ||
|
||
export * from 'react-client/src/ReactFlightClientStreamConfigWeb'; | ||
export * from 'react-client/src/ReactClientConsoleConfigServer'; | ||
export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpack'; | ||
export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackServer'; | ||
export * from 'react-server-dom-webpack/src/client/ReactFlightClientConfigTargetWebpackServer'; | ||
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; | ||
export const usedWithSSR = true; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
'use strict'; | ||
|
||
var n, w; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-webpack-client.node.production.js'); | ||
n = require('./cjs/react-server-dom-webpack-client.node.production.js'); | ||
w = require('./cjs/react-server-dom-webpack-client.node-webstreams.production.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-webpack-client.node.development.js'); | ||
n = require('./cjs/react-server-dom-webpack-client.node.development.js'); | ||
w = require('./cjs/react-server-dom-webpack-client.node-webstreams.development.js'); | ||
} | ||
|
||
exports.registerServerReference = function (r, i, e) { | ||
return w.registerServerReference(n.registerServerReference(r, i, e), i, e); | ||
}; | ||
exports.createServerReference = function (i, c, e, d, f) { | ||
return w.registerServerReference( | ||
n.createServerReference(i, c, e, d, f), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed this in #33442, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are now but I'm not sure they always will so for now just passing along the fully signature in case we change it. We really should have one of these builds for SSR and a different one for RSC because they have different constraints. Calling a Server Reference from RSC should maybe be ok. Also, we should really be passing the DEV only So we should really accept all args. |
||
i, | ||
e | ||
); | ||
}; | ||
|
||
exports.createFromNodeStream = n.createFromNodeStream; | ||
exports.createFromFetch = w.createFromFetch; | ||
exports.createFromReadableStream = w.createFromReadableStream; | ||
|
||
exports.createTemporaryReferenceSet = w.createTemporaryReferenceSet; | ||
exports.encodeReply = w.encodeReply; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export * from './ReactFlightDOMClientEdge'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export { | ||
renderToReadableStream, | ||
prerender as unstable_prerender, | ||
decodeReply, | ||
decodeReplyFromAsyncIterable, | ||
decodeAction, | ||
decodeFormState, | ||
registerServerReference, | ||
registerClientReference, | ||
createClientModuleProxy, | ||
createTemporaryReferenceSet, | ||
} from './ReactFlightDOMServerEdge'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,14 +296,19 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) { | |
|
||
// We mock createHook so that we can automatically clean it up. | ||
let installedHook = null; | ||
let outgoingHook = null; | ||
jest.mock('async_hooks', () => { | ||
const actual = jest.requireActual('async_hooks'); | ||
return { | ||
...actual, | ||
createHook(config) { | ||
if (installedHook) { | ||
installedHook.disable(); | ||
// We unmount when there's more than two hooks installed. | ||
// We use two because the build of server.node actually installs two hooks. | ||
// One in each build. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reveals that we're actually installing two Basically you have to deep link to make it optimized. |
||
if (outgoingHook) { | ||
outgoingHook.disable(); | ||
} | ||
outgoingHook = installedHook; | ||
return (installedHook = actual.createHook(config)); | ||
}, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this wrapper mess with source mapping? I remember you mentioned in the past that module indirection is ok, but wrapper is not, because React doesn't let you customize how many stack frames to pop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That only matters on the
server
entry point and that one isn't wrapped because they are not using module state but instead attaches meta data on the function. I was hoping to change that to be the shared state model as the client but if we do that we'll just also have to hoist that shared state into a separate internal bundle.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm wrong about this. It doesn't matter for
registerServerReference
but it does matter forcreateServerReference
.