Skip to content

Commit

Permalink
Put .server.js at the end of bundle filenames (#20419)
Browse files Browse the repository at this point in the history
* Put .server.js at the end of bundle filenames

* Client too
  • Loading branch information
gaearon authored Dec 9, 2020
1 parent 03126dd commit dbf40ef
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
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');
} 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');
}
19 changes: 18 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,23 @@ function getFilename(bundle, bundleType) {
}
}

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

module.exports = {
bundleTypes,
moduleTypes,
Expand Down

0 comments on commit dbf40ef

Please sign in to comment.