Skip to content

Commit 350a07e

Browse files
committed
Fix Rollup v3 build issues
1 parent e66332a commit 350a07e

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

packages/react-server-dom-webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"./server.node.unbundled": "./server.node.unbundled.js",
6767
"./node-loader": "./esm/react-server-dom-webpack-node-loader.production.min.js",
6868
"./node-register": "./node-register.js",
69-
"./src/*": "./src/*",
69+
"./src/*": "./src/*.js",
7070
"./package.json": "./package.json"
7171
},
7272
"main": "index.js",

scripts/rollup/build.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,30 @@ function getBabelConfig(
173173
return options;
174174
}
175175

176+
let getRollupInteropValue = id => {
177+
// ReactNoop.js and ReactNoopPersistent.js do `import ReactFiberReconciler from 'react-reconciler'`.
178+
// That gets turned into a `require()`, but the `module.exports = function reconciler()` wrapper
179+
// gets added later, so Rollup isn't fully aware of it, and tries to use `RFR.default` instead.
180+
// Force Rollup to use the `require()`'d value directly, without adding a `.default`.
181+
// Other cases:
182+
// - `react-art` needs to deal with imports from the `art` package
183+
// - `react-server/flight` and `react-client/flight`
184+
// -`error-stack-parser`
185+
const exactModuleNames = [
186+
'react-reconciler',
187+
'react-server/flight',
188+
'react-client/flight',
189+
'error-stack-parser',
190+
];
191+
192+
if (exactModuleNames.includes(id) || id.startsWith('art/')) {
193+
return 'default';
194+
}
195+
196+
// For all other modules, handle imports without any import helper utils
197+
return 'esModule';
198+
};
199+
176200
function getRollupOutputOptions(
177201
outputPath,
178202
format,
@@ -187,7 +211,7 @@ function getRollupOutputOptions(
187211
format,
188212
globals,
189213
freeze: !isProduction,
190-
interop: false,
214+
interop: getRollupInteropValue,
191215
name: globalName,
192216
sourcemap: false,
193217
esModule: false,
@@ -612,7 +636,7 @@ async function createBundle(bundle, bundleType) {
612636
output: {
613637
externalLiveBindings: false,
614638
freeze: false,
615-
interop: false,
639+
interop: getRollupInteropValue,
616640
esModule: false,
617641
},
618642
};

scripts/rollup/bundles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ const bundles = [
442442
{
443443
bundleTypes: [NODE_ES2015],
444444
moduleType: RENDERER_UTILS,
445-
entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js',
445+
entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister',
446446
name: 'react-server-dom-webpack-node-register',
447447
global: 'ReactFlightWebpackNodeRegister',
448448
minifyWithProdErrorCodes: false,

0 commit comments

Comments
 (0)