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

Put .server.js at the end of bundle filenames #20419

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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-server-dom-webpack-writer.browser.server.production.min.js');
module.exports = require('./cjs/react-server-dom-webpack-writer.browser.production.min.server.js');
Copy link

Choose a reason for hiding this comment

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

as an outsider this is super confusing, .browser.server? so which is it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These suffixes are internal filenames so they would be automatically determined by the environment. This is similar how we have ReactDOMServer that has a browser build. As a consumer you don't think about those suffixes.

} else {
module.exports = require('./cjs/react-server-dom-webpack-writer.browser.server.development.js');
module.exports = require('./cjs/react-server-dom-webpack-writer.browser.development.server.js');
}
4 changes: 2 additions & 2 deletions packages/react-server-dom-webpack/npm/writer.node.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-server-dom-webpack-writer.node.server.production.min.js');
module.exports = require('./cjs/react-server-dom-webpack-writer.node.production.min.server.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-writer.node.server.development.js');
module.exports = require('./cjs/react-server-dom-webpack-writer.node.development.server.js');
}
4 changes: 2 additions & 2 deletions packages/react/npm/unstable-index.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-unstable-index.server.production.min.js');
module.exports = require('./cjs/react-unstable-index.production.min.server.js');
} else {
module.exports = require('./cjs/react-unstable-index.server.development.js');
module.exports = require('./cjs/react-unstable-index.development.server.js');
}
14 changes: 13 additions & 1 deletion scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ deepFreeze(bundles);
deepFreeze(bundleTypes);
deepFreeze(moduleTypes);

function getFilename(bundle, bundleType) {
function getOriginalFilename(bundle, bundleType) {
let name = bundle.entry;
const globalName = bundle.global;
// we do this to replace / to -, for react-dom/server
Expand Down Expand Up @@ -871,6 +871,18 @@ function getFilename(bundle, bundleType) {
}
}

function getFilename(bundle, bundleType) {
const originalFilename = getOriginalFilename(bundle, bundleType);
if (originalFilename.indexOf('.server.') !== -1) {
// Ensure .server.js is the final suffix.
// This is important for the Server tooling convention.
return originalFilename
.replace('.server.', '.')
.replace('.js', '.server.js');
}
return originalFilename;
}

module.exports = {
bundleTypes,
moduleTypes,
Expand Down