Skip to content
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

Rename react-server-dom-webpack entry points to /client and /server #25504

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/flight-browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1>Flight Example</h1>
<script src="../../build/node_modules/react/umd/react.development.js"></script>
<script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="../../build/node_modules/react-dom/umd/react-dom-server.browser.development.js"></script>
<script src="../../build/node_modules/react-server-dom-webpack/umd/react-server-dom-webpack-writer.browser.development.server.js"></script>
<script src="../../build/node_modules/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js"></script>
<script src="../../build/node_modules/react-server-dom-webpack/umd/react-server-dom-webpack.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
<script type="text/babel">
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/server/handler.server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const {renderToPipeableStream} = require('react-server-dom-webpack/writer');
const {renderToPipeableStream} = require('react-server-dom-webpack/server');
const {readFile} = require('fs');
const {resolve} = require('path');
const React = require('react');
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import {Suspense} from 'react';
import ReactDOM from 'react-dom/client';
import ReactServerDOMReader from 'react-server-dom-webpack';
import ReactServerDOMReader from 'react-server-dom-webpack/client';

let data = ReactServerDOMReader.createFromFetch(fetch('http://localhost:3001'));

Expand Down
10 changes: 10 additions & 0 deletions packages/react-server-dom-webpack/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its 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/ReactFlightDOMClient';
2 changes: 1 addition & 1 deletion packages/react-server-dom-webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from './src/ReactFlightDOMClient';
throw new Error('Use react-server-dom-webpack/client instead.');
7 changes: 7 additions & 0 deletions packages/react-server-dom-webpack/npm/client.js
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-webpack-client.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-client.development.js');
}
15 changes: 10 additions & 5 deletions packages/react-server-dom-webpack/npm/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its 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';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack.development.js');
}
throw new Error('Use react-server-dom-webpack/client instead.');
7 changes: 7 additions & 0 deletions packages/react-server-dom-webpack/npm/server.browser.js
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-webpack-server.browser.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-server.browser.development.js');
}
7 changes: 7 additions & 0 deletions packages/react-server-dom-webpack/npm/server.node.js
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-webpack-server.node.production.min.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-server.node.development.js');
}

This file was deleted.

7 changes: 0 additions & 7 deletions packages/react-server-dom-webpack/npm/writer.node.server.js

This file was deleted.

20 changes: 11 additions & 9 deletions packages/react-server-dom-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"README.md",
"index.js",
"plugin.js",
"writer.js",
"writer.browser.server.js",
"writer.node.server.js",
"client.js",
"server.js",
"server.browser.js",
"server.node.js",
"node-register.js",
"cjs/",
"umd/",
Expand All @@ -24,15 +25,16 @@
"exports": {
".": "./index.js",
"./plugin": "./plugin.js",
"./writer": {
"./client": "./client.js",
"./server": {
"react-server": {
"node": "./writer.node.server.js",
"browser": "./writer.browser.server.js"
"node": "./server.node.js",
"browser": "./server.browser.js"
},
"default": "./writer.js"
"default": "./server.js"
},
"./writer.node.server": "./writer.node.server.js",
"./writer.browser.server": "./writer.browser.server.js",
"./server.node": "./server.node.js",
"./server.browser": "./server.browser.js",
"./node-loader": "./esm/react-server-dom-webpack-node-loader.js",
"./node-register": "./node-register.js",
"./src/*": "./src/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
*/

throw new Error(
'The React Server Writer cannot be used outside a react-server environment. ' +
'The React Server cannot be used outside a react-server environment. ' +
'You must configure Node.js using the `--conditions react-server` flag.',
);
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ClientReferenceDependency extends ModuleDependency {
// We use the Flight client implementation because you can't get to these
// without the client runtime so it's the first time in the loading sequence
// you might want them.
const clientImportName = 'react-server-dom-webpack';
const clientImportName = 'react-server-dom-webpack/client';
const clientFileName = require.resolve('../');

type ClientReferenceSearchPath = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('ReactFlightDOM', () => {
use = React.experimental_use;
Suspense = React.Suspense;
ReactDOMClient = require('react-dom/client');
ReactServerDOMWriter = require('react-server-dom-webpack/writer.node.server');
ReactServerDOMReader = require('react-server-dom-webpack');
ReactServerDOMWriter = require('react-server-dom-webpack/server.node');
ReactServerDOMReader = require('react-server-dom-webpack/client');

ErrorBoundary = class extends React.Component {
state = {hasError: false, error: null};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('ReactFlightDOMBrowser', () => {
React = require('react');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server.browser');
ReactServerDOMWriter = require('react-server-dom-webpack/writer.browser.server');
ReactServerDOMReader = require('react-server-dom-webpack');
ReactServerDOMWriter = require('react-server-dom-webpack/server.browser');
ReactServerDOMReader = require('react-server-dom-webpack/client');
Suspense = React.Suspense;
use = React.experimental_use;
});
Expand Down
16 changes: 8 additions & 8 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,32 +377,32 @@ const bundles = [
externals: ['react'],
},

/******* React Server DOM Webpack Writer *******/
/******* React Server DOM Webpack Server *******/
{
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
moduleType: RENDERER,
entry: 'react-server-dom-webpack/writer.browser.server',
global: 'ReactServerDOMWriter',
entry: 'react-server-dom-webpack/server.browser',
global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false,
externals: ['react', 'react-dom'],
},
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-server-dom-webpack/writer.node.server',
global: 'ReactServerDOMWriter',
entry: 'react-server-dom-webpack/server.node',
global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'react-dom'],
},

/******* React Server DOM Webpack Reader *******/
/******* React Server DOM Webpack Client *******/
{
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
moduleType: RENDERER,
entry: 'react-server-dom-webpack',
global: 'ReactServerDOMReader',
entry: 'react-server-dom-webpack/client',
global: 'ReactServerDOMClient',
minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false,
externals: ['react'],
Expand Down
20 changes: 11 additions & 9 deletions scripts/shared/inlinedHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module.exports = [
'react-dom/static.node',
'react-dom/server-rendering-stub',
'react-dom/src/server/ReactDOMServerExternalRuntime.js',
'react-server-dom-webpack/writer.node.server',
'react-server-dom-webpack',
'react-server-dom-webpack/server.node',
'react-server-dom-webpack/client',
],
paths: [
'react-dom',
Expand All @@ -30,9 +30,10 @@ module.exports = [
'react-dom/src/server/ReactDOMFizzServerNode.js', // react-dom/server.node
'react-dom/src/server/ReactDOMFizzStaticNode.js',
'react-server-dom-webpack',
'react-server-dom-webpack/writer',
'react-server-dom-webpack/writer.node.server',
'react-server-dom-webpack/src/ReactFlightDOMServerNode.js', // react-server-dom-webpack/writer.node.server
'react-server-dom-webpack/client',
'react-server-dom-webpack/server',
'react-server-dom-webpack/server.node',
'react-server-dom-webpack/src/ReactFlightDOMServerNode.js', // react-server-dom-webpack/server.node
'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations.
'react-devtools',
'react-devtools-core',
Expand All @@ -53,8 +54,8 @@ module.exports = [
'react-dom/static.browser',
'react-dom/server-rendering-stub',
'react-dom/src/server/ReactDOMServerExternalRuntime.js',
'react-server-dom-webpack/writer.browser.server',
'react-server-dom-webpack',
'react-server-dom-webpack/server.browser',
'react-server-dom-webpack/client',
],
paths: [
'react-dom',
Expand All @@ -66,8 +67,9 @@ module.exports = [
'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/server.browser
'react-dom/src/server/ReactDOMFizzStaticBrowser.js',
'react-server-dom-webpack',
'react-server-dom-webpack/writer.browser.server',
'react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js', // react-server-dom-webpack/writer.browser.server
'react-server-dom-webpack/client',
'react-server-dom-webpack/server.browser',
'react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js', // react-server-dom-webpack/server.browser
'react-client/src/ReactFlightClientStream.js', // We can only type check this in streaming configurations.
'react-devtools',
'react-devtools-core',
Expand Down