Skip to content

Commit 9eede45

Browse files
authored
Stop treating all Node.js builtins implicitly as externals (facebook#34249)
1 parent 090777d commit 9eede45

File tree

2 files changed

+56
-16
lines changed

2 files changed

+56
-16
lines changed

scripts/rollup/build.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ function getBabelConfig(
144144
updateBabelOptions,
145145
bundleType,
146146
packageName,
147-
externals,
148147
isDevelopment,
149148
bundle
150149
) {
@@ -354,7 +353,6 @@ function forbidFBJSImports() {
354353

355354
function getPlugins(
356355
entry,
357-
externals,
358356
updateBabelOptions,
359357
filename,
360358
packageName,
@@ -402,8 +400,8 @@ function getPlugins(
402400
forbidFBJSImports(),
403401
// Use Node resolution mechanism.
404402
resolve({
405-
// skip: externals, // TODO: options.skip was removed in @rollup/plugin-node-resolve 3.0.0
406-
preferBuiltins: bundle.preferBuiltins,
403+
// `external` rollup config takes care of marking builtins as externals
404+
preferBuiltins: false,
407405
}),
408406
// Remove license headers from individual modules
409407
stripBanner({
@@ -415,7 +413,6 @@ function getPlugins(
415413
updateBabelOptions,
416414
bundleType,
417415
packageName,
418-
externals,
419416
!isProduction,
420417
bundle
421418
)
@@ -690,7 +687,6 @@ async function createBundle(bundle, bundleType) {
690687
onwarn: handleRollupWarning,
691688
plugins: getPlugins(
692689
bundle.entry,
693-
externals,
694690
bundle.babel,
695691
filename,
696692
packageName,

scripts/rollup/bundles.js

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,14 @@ const bundles = [
363363
global: 'ReactDOMServer',
364364
minifyWithProdErrorCodes: false,
365365
wrapWithModuleBoundaries: false,
366-
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
366+
externals: [
367+
'react',
368+
'react-dom',
369+
'async_hooks',
370+
'crypto',
371+
'stream',
372+
'util',
373+
],
367374
},
368375
{
369376
bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [],
@@ -460,7 +467,14 @@ const bundles = [
460467
global: 'ReactServerDOMServer',
461468
minifyWithProdErrorCodes: false,
462469
wrapWithModuleBoundaries: false,
463-
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
470+
externals: [
471+
'react',
472+
'react-dom',
473+
'async_hooks',
474+
'crypto',
475+
'stream',
476+
'util',
477+
],
464478
},
465479
{
466480
bundleTypes: [NODE_DEV, NODE_PROD],
@@ -472,7 +486,14 @@ const bundles = [
472486
global: 'ReactServerDOMServer',
473487
minifyWithProdErrorCodes: false,
474488
wrapWithModuleBoundaries: false,
475-
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
489+
externals: [
490+
'react',
491+
'react-dom',
492+
'async_hooks',
493+
'crypto',
494+
'stream',
495+
'util',
496+
],
476497
},
477498
{
478499
bundleTypes: [NODE_DEV, NODE_PROD],
@@ -483,7 +504,7 @@ const bundles = [
483504
global: 'ReactServerDOMServer',
484505
minifyWithProdErrorCodes: false,
485506
wrapWithModuleBoundaries: false,
486-
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
507+
externals: ['react'],
487508
},
488509

489510
/******* React Server DOM Webpack Client *******/
@@ -588,7 +609,14 @@ const bundles = [
588609
global: 'ReactServerDOMServer',
589610
minifyWithProdErrorCodes: false,
590611
wrapWithModuleBoundaries: false,
591-
externals: ['react', 'util', 'async_hooks', 'react-dom'],
612+
externals: [
613+
'react',
614+
'react-dom',
615+
'async_hooks',
616+
'crypto',
617+
'stream',
618+
'util',
619+
],
592620
},
593621
{
594622
bundleTypes: [NODE_DEV, NODE_PROD],
@@ -599,7 +627,7 @@ const bundles = [
599627
global: 'ReactServerDOMServer',
600628
minifyWithProdErrorCodes: false,
601629
wrapWithModuleBoundaries: false,
602-
externals: ['react', 'util', 'async_hooks', 'react-dom'],
630+
externals: ['react'],
603631
},
604632

605633
/******* React Server DOM Turbopack Client *******/
@@ -656,7 +684,14 @@ const bundles = [
656684
global: 'ReactServerDOMServer',
657685
minifyWithProdErrorCodes: false,
658686
wrapWithModuleBoundaries: false,
659-
externals: ['react', 'util', 'async_hooks', 'react-dom'],
687+
externals: [
688+
'react',
689+
'react-dom',
690+
'async_hooks',
691+
'crypto',
692+
'stream',
693+
'util',
694+
],
660695
},
661696
{
662697
bundleTypes: [NODE_DEV, NODE_PROD],
@@ -667,7 +702,7 @@ const bundles = [
667702
global: 'ReactServerDOMServer',
668703
minifyWithProdErrorCodes: false,
669704
wrapWithModuleBoundaries: false,
670-
externals: ['react', 'util', 'async_hooks', 'react-dom'],
705+
externals: ['react', 'react-dom'],
671706
},
672707

673708
/******* React Server DOM Parcel Client *******/
@@ -711,7 +746,14 @@ const bundles = [
711746
condition: 'react-server',
712747
minifyWithProdErrorCodes: false,
713748
wrapWithModuleBoundaries: false,
714-
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'],
749+
externals: [
750+
'react',
751+
'react-dom',
752+
'async_hooks',
753+
'crypto',
754+
'stream',
755+
'util',
756+
],
715757
},
716758

717759
/******* React Server DOM ESM Client *******/
@@ -729,7 +771,7 @@ const bundles = [
729771
entry: 'react-server-dom-esm/client.node',
730772
minifyWithProdErrorCodes: false,
731773
wrapWithModuleBoundaries: false,
732-
externals: ['react', 'react-dom', 'util', 'crypto'],
774+
externals: ['react', 'react-dom', 'util'],
733775
},
734776

735777
/******* React Server DOM ESM Node.js Loader *******/
@@ -1215,6 +1257,8 @@ const bundles = [
12151257
'hermes-parser',
12161258
'zod',
12171259
'zod-validation-error',
1260+
'crypto',
1261+
'util',
12181262
],
12191263
tsconfig: './packages/eslint-plugin-react-hooks/tsconfig.json',
12201264
prebuild: `mkdir -p ./compiler/packages/babel-plugin-react-compiler/dist && echo "module.exports = require('../src/index.ts');" > ./compiler/packages/babel-plugin-react-compiler/dist/index.js`,

0 commit comments

Comments
 (0)