Skip to content

Commit

Permalink
Use the server src files as entry points for the builds/tests (#21683)
Browse files Browse the repository at this point in the history
* Use the server src files as entry points for the builds/tests

We need one top level entry point to target two builds so we can't have
the top level one be the entry point for the builds.

* Same thing but with the modern entry point
  • Loading branch information
sebmarkbage authored Jun 14, 2021
1 parent e601854 commit 9343f87
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions fixtures/fizz-ssr-browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ <h1>Fizz Example</h1>
</p>
</div>
<script src="../../build/node_modules/react/umd/react.development.js"></script>
<script src="../../build/node_modules/react-dom/umd/react-dom-unstable-fizz.browser.development.js"></script>
<script src="../../build/node_modules/react-dom/umd/react-dom-server.browser.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
<script type="text/babel">
let controller = new AbortController();
let stream = ReactDOMFizzServer.renderToReadableStream(
let stream = ReactDOMServer.renderToReadableStream(
<html>
<body>Success</body>
</html>,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/ssr/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {unstable_createRoot as createRoot} from 'react-dom';
import {createRoot} from 'react-dom';

import App from './components/App';

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/npm/server.browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-server.browser.production.min.js');
module.exports = require('./cjs/react-dom-server-legacy.browser.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server.browser.development.js');
module.exports = require('./cjs/react-dom-server-legacy.browser.development.js');
}
4 changes: 2 additions & 2 deletions packages/react-dom/npm/server.node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-server.node.production.min.js');
module.exports = require('./cjs/react-dom-server-legacy.node.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server.node.development.js');
module.exports = require('./cjs/react-dom-server-legacy.node.development.js');
}
4 changes: 2 additions & 2 deletions packages/react-dom/npm/unstable-fizz.browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-unstable-fizz.browser.production.min.js');
module.exports = require('./cjs/react-dom-server.browser.production.min.js');
} else {
module.exports = require('./cjs/react-dom-unstable-fizz.browser.development.js');
module.exports = require('./cjs/react-dom-server.browser.development.js');
}
4 changes: 2 additions & 2 deletions packages/react-dom/npm/unstable-fizz.node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-unstable-fizz.node.production.min.js');
module.exports = require('./cjs/react-dom-server.node.production.min.js');
} else {
module.exports = require('./cjs/react-dom-unstable-fizz.node.development.js');
module.exports = require('./cjs/react-dom-server.node.development.js');
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export {
renderToNodeStream,
renderToStaticNodeStream,
version,
} from './src/server/ReactDOMServerLegacyPartialRendererBrowser';
} from './ReactDOMServerLegacyPartialRendererBrowser';
29 changes: 16 additions & 13 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ const bundles = [
? [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD]
: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
moduleType: RENDERER,
entry: 'react-dom/server.browser',
entry: 'react-dom/src/server/ReactDOMLegacyServerBrowser',
name: 'react-dom-server-legacy.browser',
global: 'ReactDOMServer',
externals: ['react'],
babel: opts =>
Expand All @@ -247,7 +248,8 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-dom/server.node',
entry: 'react-dom/src/server/ReactDOMLegacyServerNode',
name: 'react-dom-server-legacy.node',
externals: ['react', 'stream'],
babel: opts =>
Object.assign({}, opts, {
Expand All @@ -261,23 +263,25 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
moduleType: RENDERER,
entry: 'react-dom/unstable-fizz.browser',
global: 'ReactDOMFizzServer',
externals: ['react', 'react-dom/server'],
entry: 'react-dom/src/server/ReactDOMFizzServerBrowser',
name: 'react-dom-server.browser',
global: 'ReactDOMServer',
externals: ['react'],
},
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-dom/unstable-fizz.node',
global: 'ReactDOMFizzServer',
externals: ['react', 'react-dom/server'],
entry: 'react-dom/src/server/ReactDOMFizzServerNode',
name: 'react-dom-server.node',
global: 'ReactDOMServer',
externals: ['react'],
},
{
bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [],
moduleType: RENDERER,
entry: 'react-server-dom-relay/src/ReactDOMServerFB',
global: 'ReactDOMServer',
externals: ['react', 'react-dom/server'],
externals: ['react'],
},

/******* React Server DOM Webpack Writer *******/
Expand All @@ -286,14 +290,14 @@ const bundles = [
moduleType: RENDERER,
entry: 'react-server-dom-webpack/writer.browser.server',
global: 'ReactServerDOMWriter',
externals: ['react', 'react-dom/server'],
externals: ['react'],
},
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: RENDERER,
entry: 'react-server-dom-webpack/writer.node.server',
global: 'ReactServerDOMWriter',
externals: ['react', 'react-dom/server'],
externals: ['react'],
},

/******* React Server DOM Webpack Reader *******/
Expand Down Expand Up @@ -340,7 +344,6 @@ const bundles = [
global: 'ReactFlightDOMRelayServer', // TODO: Rename to Writer
externals: [
'react',
'react-dom/server',
'ReactFlightDOMRelayServerIntegration',
'JSResourceReference',
],
Expand Down Expand Up @@ -785,7 +788,7 @@ deepFreeze(bundleTypes);
deepFreeze(moduleTypes);

function getOriginalFilename(bundle, bundleType) {
let name = bundle.entry;
let name = bundle.name || bundle.entry;
const globalName = bundle.global;
// we do this to replace / to -, for react-dom/server
name = name.replace('/index.', '.').replace('/', '-');
Expand Down
9 changes: 6 additions & 3 deletions scripts/shared/inlinedHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = [
entryPoints: [
'react-dom',
'react-dom/testing',
'react-dom/unstable-fizz.node',
'react-dom/src/server/ReactDOMFizzServerNode',
'react-server-dom-webpack/writer.node.server',
'react-server-dom-webpack',
],
Expand All @@ -36,7 +36,7 @@ module.exports = [
entryPoints: [
'react-dom',
'react-dom/testing',
'react-dom/unstable-fizz.browser',
'react-dom/src/server/ReactDOMFizzServerBrowser',
'react-server-dom-webpack/writer.browser.server',
'react-server-dom-webpack',
],
Expand All @@ -55,7 +55,10 @@ module.exports = [
},
{
shortName: 'dom-legacy',
entryPoints: ['react-dom/server.browser', 'react-dom/server.node'],
entryPoints: [
'react-dom/src/server/ReactDOMLegacyServerBrowser', // react-dom/server.browser
'react-dom/src/server/ReactDOMLegacyServerNode', // react-dom/server.node
],
paths: [
'react-dom',
'react-dom/server',
Expand Down

0 comments on commit 9343f87

Please sign in to comment.