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

Use single entry point for SSR via browser field #10362

Merged
merged 7 commits into from
Aug 2, 2017
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
7 changes: 0 additions & 7 deletions packages/react-dom/node-stream.js

This file was deleted.

5 changes: 4 additions & 1 deletion packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
"README.md",
"index.js",
"server.js",
"node-stream.js",
"server.browser.js",
"test-utils.js",
"unstable-native-dependencies.js",
"cjs/",
"umd/"
],
"browser": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nicer to do this with a more public browser entry point instead of the internal package details (personally I'd prefer not exposing those as separate files at all and just inline them).

With a public entry point it's at least possible to manually require the browser version if you need to. This encourages require to the internal implementation details instead.

"./server.js": "./server.browser.js"
},
"browserify": {
"transform": [
"loose-envify"
Expand Down
7 changes: 7 additions & 0 deletions packages/react-dom/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-dom-server.browser.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server.browser.development.js');
}
4 changes: 2 additions & 2 deletions packages/react-dom/server.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.production.min.js');
module.exports = require('./cjs/react-dom-server.node.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server.development.js');
module.exports = require('./cjs/react-dom-server.node.development.js');
}
14 changes: 7 additions & 7 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ const bundles = [
moduleName: 'ReactDOMServer',
sourceMap: false,
},
entry: 'src/renderers/dom/ReactDOMServerEntry',
entry: 'src/renderers/dom/ReactDOMServerBrowserEntry',
externals: ['prop-types', 'prop-types/checkPropTypes'],
fbEntry: 'src/renderers/dom/ReactDOMServerEntry',
fbEntry: 'src/renderers/dom/ReactDOMServerBrowserEntry',
hasteName: 'ReactDOMServer',
isRenderer: true,
label: 'dom-server-string',
label: 'dom-server-browser',
manglePropertiesOnProd: false,
name: 'react-dom/server',
name: 'react-dom/server.browser',
paths: [
'src/renderers/dom/**/*.js',
'src/renderers/shared/**/*.js',
Expand All @@ -199,12 +199,12 @@ const bundles = [
moduleName: 'ReactDOMNodeStream',
sourceMap: false,
},
entry: 'src/renderers/dom/ReactDOMNodeStreamEntry',
entry: 'src/renderers/dom/ReactDOMServerNodeEntry',
externals: ['prop-types', 'prop-types/checkPropTypes', 'stream'],
isRenderer: true,
label: 'dom-server-node-stream',
label: 'dom-server-server-node',
manglePropertiesOnProd: false,
name: 'react-dom/node-stream',
name: 'react-dom/server.node',
paths: [
'src/renderers/dom/**/*.js',
'src/renderers/shared/**/*.js',
Expand Down
236 changes: 90 additions & 146 deletions scripts/rollup/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,92 +25,116 @@
"gzip": 6703
},
"react-dom.development.js (UMD_DEV)": {
"size": 639824,
"gzip": 145999
"size": 640604,
"gzip": 146616
},
"react-dom.production.min.js (UMD_PROD)": {
"size": 121920,
"gzip": 38871
"size": 121735,
"gzip": 38859
},
"react-dom.development.js (NODE_DEV)": {
"size": 599220,
"gzip": 136402
"size": 599999,
"gzip": 136960
},
"react-dom.production.min.js (NODE_PROD)": {
"size": 118838,
"gzip": 37788
"size": 118657,
"gzip": 37769
},
"ReactDOMFiber-dev.js (FB_DEV)": {
"size": 595749,
"gzip": 135868
"size": 596499,
"gzip": 136409
},
"ReactDOMFiber-prod.js (FB_PROD)": {
"size": 431003,
"gzip": 96867
"size": 430689,
"gzip": 96928
},
"react-dom-test-utils.development.js (NODE_DEV)": {
"size": 56074,
"gzip": 14162
"size": 55917,
"gzip": 14141
},
"ReactTestUtils-dev.js (FB_DEV)": {
"size": 55864,
"gzip": 14128
"size": 55707,
"gzip": 14105
},
"ReactDOMServerStack-dev.js (FB_DEV)": {
"size": 460810,
"gzip": 111966
"react-dom-unstable-native-dependencies.development.js (UMD_DEV)": {
"size": 89486,
"gzip": 22619
},
"ReactDOMServerStack-prod.js (FB_PROD)": {
"size": 338222,
"gzip": 81957
"react-dom-unstable-native-dependencies.production.min.js (UMD_PROD)": {
"size": 18338,
"gzip": 5956
},
"react-dom-server.development.js (UMD_DEV)": {
"size": 122993,
"gzip": 31032
"react-dom-unstable-native-dependencies.development.js (NODE_DEV)": {
"size": 82914,
"gzip": 20689
},
"react-dom-server.production.min.js (UMD_PROD)": {
"size": 22819,
"gzip": 8627
"react-dom-unstable-native-dependencies.production.min.js (NODE_PROD)": {
"size": 16978,
"gzip": 5429
},
"react-dom-server.development.js (NODE_DEV)": {
"size": 92141,
"gzip": 23593
"ReactDOMUnstableNativeDependencies-dev.js (FB_DEV)": {
"size": 82613,
"gzip": 20656
},
"react-dom-server.production.min.js (NODE_PROD)": {
"size": 21214,
"gzip": 8026
"ReactDOMUnstableNativeDependencies-prod.js (FB_PROD)": {
"size": 67256,
"gzip": 16011
},
"react-dom-server.browser.development.js (UMD_DEV)": {
"size": 123259,
"gzip": 31130
},
"react-dom-server.browser.production.min.js (UMD_PROD)": {
"size": 22069,
"gzip": 8359
},
"react-dom-server.browser.development.js (NODE_DEV)": {
"size": 92395,
"gzip": 23727
},
"react-dom-server.browser.production.min.js (NODE_PROD)": {
"size": 20470,
"gzip": 7751
},
"ReactDOMServer-dev.js (FB_DEV)": {
"size": 91478,
"gzip": 23641
},
"ReactDOMServer-prod.js (FB_PROD)": {
"size": 49904,
"gzip": 13944
},
"ReactDOMServerStream-dev.js (FB_DEV)": {
"size": 264750,
"gzip": 67600
"react-dom-server.node.development.js (NODE_DEV)": {
"size": 95082,
"gzip": 24294
},
"ReactDOMServerStream-prod.js (FB_PROD)": {
"size": 198041,
"gzip": 51047
"react-dom-server.node.production.min.js (NODE_PROD)": {
"size": 21375,
"gzip": 8033
},
"react-art.development.js (UMD_DEV)": {
"size": 373050,
"gzip": 82463
"size": 373020,
"gzip": 82667
},
"react-art.production.min.js (UMD_PROD)": {
"size": 94183,
"gzip": 29145
"size": 94024,
"gzip": 29099
},
"react-art.development.js (NODE_DEV)": {
"size": 294419,
"gzip": 62436
"size": 294390,
"gzip": 62633
},
"react-art.production.min.js (NODE_PROD)": {
"size": 55748,
"gzip": 17250
"size": 55594,
"gzip": 17147
},
"ReactARTFiber-dev.js (FB_DEV)": {
"size": 293279,
"gzip": 62507
"size": 293221,
"gzip": 62686
},
"ReactARTFiber-prod.js (FB_PROD)": {
"size": 220571,
"gzip": 45660
"size": 220287,
"gzip": 45716
},
"ReactNativeStack-dev.js (RN_DEV)": {
"size": 188445,
Expand All @@ -121,112 +145,32 @@
"gzip": 26398
},
"ReactNativeFiber-dev.js (RN_DEV)": {
"size": 290148,
"gzip": 52574
"size": 290448,
"gzip": 52727
},
"ReactNativeFiber-prod.js (RN_PROD)": {
"size": 224144,
"gzip": 38909
"size": 224421,
"gzip": 39029
},
"react-test-renderer.development.js (NODE_DEV)": {
"size": 291782,
"gzip": 61299
"size": 292225,
"gzip": 61530
},
"ReactTestRendererFiber-dev.js (FB_DEV)": {
"size": 290600,
"gzip": 61383
"size": 291017,
"gzip": 61598
},
"react-test-renderer-shallow.development.js (NODE_DEV)": {
"size": 10302,
"gzip": 2587
"size": 10145,
"gzip": 2581
},
"ReactShallowRenderer-dev.js (FB_DEV)": {
"size": 10208,
"gzip": 2541
"size": 10051,
"gzip": 2533
},
"react-noop-renderer.development.js (NODE_DEV)": {
"size": 285709,
"gzip": 59710
},
"ReactHTMLString-dev.js (FB_DEV)": {
"size": 265654,
"gzip": 67793
},
"ReactHTMLString-prod.js (FB_PROD)": {
"size": 197868,
"gzip": 51197
},
"react-dom-stream.development.js (UMD_DEV)": {
"size": 307410,
"gzip": 77346
},
"react-dom-stream.production.min.js (UMD_PROD)": {
"size": 66444,
"gzip": 22648
},
"react-dom-stream.development.js (NODE_DEV)": {
"size": 265257,
"gzip": 67607
},
"react-dom-stream.production.min.js (NODE_PROD)": {
"size": 62695,
"gzip": 21279
},
"ReactHTMLStream-dev.js (FB_DEV)": {
"size": 264745,
"gzip": 67531
},
"ReactHTMLStream-prod.js (FB_PROD)": {
"size": 197512,
"gzip": 50920
},
"ReactDOMServer-dev.js (FB_DEV)": {
"size": 91224,
"gzip": 23517
},
"ReactDOMServer-prod.js (FB_PROD)": {
"size": 55353,
"gzip": 15240
},
"react-dom-node-stream.development.js (NODE_DEV)": {
"size": 93872,
"gzip": 24085
},
"react-dom-node-stream.production.min.js (NODE_PROD)": {
"size": 22057,
"gzip": 8338
},
"ReactDOMNodeStream-dev.js (FB_DEV)": {
"size": 264918,
"gzip": 67597
},
"ReactDOMNodeStream-prod.js (FB_PROD)": {
"size": 197610,
"gzip": 50956
},
"react-dom-unstable-native-dependencies.development.js (UMD_DEV)": {
"size": 89486,
"gzip": 22619
},
"react-dom-unstable-native-dependencies.production.min.js (UMD_PROD)": {
"size": 18338,
"gzip": 5956
},
"react-dom-unstable-native-dependencies.development.js (NODE_DEV)": {
"size": 82914,
"gzip": 20689
},
"react-dom-unstable-native-dependencies.production.min.js (NODE_PROD)": {
"size": 16978,
"gzip": 5429
},
"ReactDOMUnstableNativeDependencies-dev.js (FB_DEV)": {
"size": 82613,
"gzip": 20656
},
"ReactDOMUnstableNativeDependencies-prod.js (FB_PROD)": {
"size": 67256,
"gzip": 16011
"size": 286152,
"gzip": 59943
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/node_modules/react-dom/server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading