-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flight] Implement
react-server-dom-turbopack
(#27315)
stacked on #27314 Turbopack requires a different module loading strategy than Webpack and as such this PR implements a new package `react-server-dom-turbopack` which largely follows the `react-server-dom-webpack` but is implemented for this new bundler
- Loading branch information
Showing
68 changed files
with
6,733 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/react-client/src/forks/ReactFlightClientConfig.dom-browser-turbopack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* 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 'react-client/src/ReactFlightClientConfigBrowser'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerTurbopack'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerTurbopackBrowser'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigTargetTurbopackBrowser'; | ||
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; | ||
export const usedWithSSR = false; |
15 changes: 15 additions & 0 deletions
15
packages/react-client/src/forks/ReactFlightClientConfig.dom-edge-turbopack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* 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 'react-client/src/ReactFlightClientConfigBrowser'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerTurbopack'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerTurbopackServer'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigTargetTurbopackServer'; | ||
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; | ||
export const usedWithSSR = true; |
15 changes: 15 additions & 0 deletions
15
packages/react-client/src/forks/ReactFlightClientConfig.dom-node-turbopack-bundled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* 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 'react-client/src/ReactFlightClientConfigNode'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerTurbopack'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerTurbopackServer'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigTargetTurbopackServer'; | ||
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; | ||
export const usedWithSSR = true; |
14 changes: 14 additions & 0 deletions
14
packages/react-client/src/forks/ReactFlightClientConfig.dom-node-turbopack.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* 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 'react-client/src/ReactFlightClientConfigNode'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigBundlerNode'; | ||
export * from 'react-server-dom-turbopack/src/ReactFlightClientConfigTargetTurbopackServer'; | ||
export * from 'react-dom-bindings/src/shared/ReactFlightClientConfigDOM'; | ||
export const usedWithSSR = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# react-server-dom-turbopack | ||
|
||
Experimental React Flight bindings for DOM using Turbopack. | ||
|
||
**Use it at your own risk.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './src/ReactFlightDOMClientBrowser'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './src/ReactFlightDOMClientEdge'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './client.browser'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './src/ReactFlightDOMClientNode'; |
10 changes: 10 additions & 0 deletions
10
packages/react-server-dom-turbopack/client.node.unbundled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './src/ReactFlightDOMClientNode'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
10 changes: 10 additions & 0 deletions
10
...s/react-server-dom-turbopack/esm/react-server-dom-turbopack-node-loader.production.min.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '../src/ReactFlightTurbopackNodeLoader.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
||
throw new Error('Use react-server-dom-turbopack/client instead.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
|
||
module.exports = require('./src/ReactFlightTurbopackNodeRegister'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.browser.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.browser.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.edge.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.edge.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./client.browser'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.node.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.node.development.js'); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/react-server-dom-turbopack/npm/client.node.unbundled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.node.unbundled.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-client.node.unbundled.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* 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 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
throw new Error('Use react-server-dom-turbopack/client instead.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./cjs/react-server-dom-turbopack-node-register.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.browser.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.browser.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.edge.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.edge.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
throw new Error( | ||
'The React Server Writer cannot be used outside a react-server environment. ' + | ||
'You must configure Node.js using the `--conditions react-server` flag.' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.node.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.node.development.js'); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/react-server-dom-turbopack/npm/server.node.unbundled.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.node.unbundled.production.min.js'); | ||
} else { | ||
module.exports = require('./cjs/react-server-dom-turbopack-server.node.unbundled.development.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"name": "react-server-dom-turbopack", | ||
"description": "React Server Components bindings for DOM using Turbopack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.", | ||
"version": "18.2.0", | ||
"keywords": [ | ||
"react" | ||
], | ||
"homepage": "https://reactjs.org/", | ||
"bugs": "https://github.com/facebook/react/issues", | ||
"license": "MIT", | ||
"files": [ | ||
"LICENSE", | ||
"README.md", | ||
"index.js", | ||
"client.js", | ||
"client.browser.js", | ||
"client.edge.js", | ||
"client.node.js", | ||
"client.node.unbundled.js", | ||
"server.js", | ||
"server.browser.js", | ||
"server.edge.js", | ||
"server.node.js", | ||
"server.node.unbundled.js", | ||
"node-register.js", | ||
"cjs/", | ||
"umd/", | ||
"esm/" | ||
], | ||
"exports": { | ||
".": "./index.js", | ||
"./client": { | ||
"workerd": "./client.edge.js", | ||
"deno": "./client.edge.js", | ||
"worker": "./client.edge.js", | ||
"node": { | ||
"turbopack": "./client.node.js", | ||
"webpack": "./client.node.js", | ||
"default": "./client.node.unbundled.js" | ||
}, | ||
"edge-light": "./client.edge.js", | ||
"browser": "./client.browser.js", | ||
"default": "./client.browser.js" | ||
}, | ||
"./client.browser": "./client.browser.js", | ||
"./client.edge": "./client.edge.js", | ||
"./client.node": "./client.node.js", | ||
"./client.node.unbundled": "./client.node.unbundled.js", | ||
"./server": { | ||
"react-server": { | ||
"workerd": "./server.edge.js", | ||
"deno": "./server.browser.js", | ||
"node": { | ||
"turbopack": "./server.node.js", | ||
"webpack": "./server.node.js", | ||
"default": "./server.node.unbundled.js" | ||
}, | ||
"edge-light": "./server.edge.js", | ||
"browser": "./server.browser.js" | ||
}, | ||
"default": "./server.js" | ||
}, | ||
"./server.browser": "./server.browser.js", | ||
"./server.edge": "./server.edge.js", | ||
"./server.node": "./server.node.js", | ||
"./server.node.unbundled": "./server.node.unbundled.js", | ||
"./node-loader": "./esm/react-server-dom-turbopack-node-loader.production.min.js", | ||
"./node-register": "./node-register.js", | ||
"./src/*": "./src/*.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "index.js", | ||
"repository": { | ||
"type" : "git", | ||
"url" : "https://github.com/facebook/react.git", | ||
"directory": "packages/react-server-dom-turbopack" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"dependencies": { | ||
"acorn-loose": "^8.3.0", | ||
"neo-async": "^2.6.1", | ||
"loose-envify": "^1.1.0" | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"loose-envify" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './src/ReactFlightDOMServerBrowser'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './src/ReactFlightDOMServerEdge'; |
Oops, something went wrong.