Stop treating all Node.js builtins implicitly as externals (#34249)

This commit is contained in:
Sebastian "Sebbie" Silbermann 2025-08-25 09:39:56 +02:00 committed by GitHub
parent 090777d78a
commit 9eede45646
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 16 deletions

View File

@ -144,7 +144,6 @@ function getBabelConfig(
updateBabelOptions, updateBabelOptions,
bundleType, bundleType,
packageName, packageName,
externals,
isDevelopment, isDevelopment,
bundle bundle
) { ) {
@ -354,7 +353,6 @@ function forbidFBJSImports() {
function getPlugins( function getPlugins(
entry, entry,
externals,
updateBabelOptions, updateBabelOptions,
filename, filename,
packageName, packageName,
@ -402,8 +400,8 @@ function getPlugins(
forbidFBJSImports(), forbidFBJSImports(),
// Use Node resolution mechanism. // Use Node resolution mechanism.
resolve({ resolve({
// skip: externals, // TODO: options.skip was removed in @rollup/plugin-node-resolve 3.0.0 // `external` rollup config takes care of marking builtins as externals
preferBuiltins: bundle.preferBuiltins, preferBuiltins: false,
}), }),
// Remove license headers from individual modules // Remove license headers from individual modules
stripBanner({ stripBanner({
@ -415,7 +413,6 @@ function getPlugins(
updateBabelOptions, updateBabelOptions,
bundleType, bundleType,
packageName, packageName,
externals,
!isProduction, !isProduction,
bundle bundle
) )
@ -690,7 +687,6 @@ async function createBundle(bundle, bundleType) {
onwarn: handleRollupWarning, onwarn: handleRollupWarning,
plugins: getPlugins( plugins: getPlugins(
bundle.entry, bundle.entry,
externals,
bundle.babel, bundle.babel,
filename, filename,
packageName, packageName,

View File

@ -363,7 +363,14 @@ const bundles = [
global: 'ReactDOMServer', global: 'ReactDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], externals: [
'react',
'react-dom',
'async_hooks',
'crypto',
'stream',
'util',
],
}, },
{ {
bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [], bundleTypes: __EXPERIMENTAL__ ? [FB_WWW_DEV, FB_WWW_PROD] : [],
@ -460,7 +467,14 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], externals: [
'react',
'react-dom',
'async_hooks',
'crypto',
'stream',
'util',
],
}, },
{ {
bundleTypes: [NODE_DEV, NODE_PROD], bundleTypes: [NODE_DEV, NODE_PROD],
@ -472,7 +486,14 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], externals: [
'react',
'react-dom',
'async_hooks',
'crypto',
'stream',
'util',
],
}, },
{ {
bundleTypes: [NODE_DEV, NODE_PROD], bundleTypes: [NODE_DEV, NODE_PROD],
@ -483,7 +504,7 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], externals: ['react'],
}, },
/******* React Server DOM Webpack Client *******/ /******* React Server DOM Webpack Client *******/
@ -588,7 +609,14 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'async_hooks', 'react-dom'], externals: [
'react',
'react-dom',
'async_hooks',
'crypto',
'stream',
'util',
],
}, },
{ {
bundleTypes: [NODE_DEV, NODE_PROD], bundleTypes: [NODE_DEV, NODE_PROD],
@ -599,7 +627,7 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'async_hooks', 'react-dom'], externals: ['react'],
}, },
/******* React Server DOM Turbopack Client *******/ /******* React Server DOM Turbopack Client *******/
@ -656,7 +684,14 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'async_hooks', 'react-dom'], externals: [
'react',
'react-dom',
'async_hooks',
'crypto',
'stream',
'util',
],
}, },
{ {
bundleTypes: [NODE_DEV, NODE_PROD], bundleTypes: [NODE_DEV, NODE_PROD],
@ -667,7 +702,7 @@ const bundles = [
global: 'ReactServerDOMServer', global: 'ReactServerDOMServer',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'async_hooks', 'react-dom'], externals: ['react', 'react-dom'],
}, },
/******* React Server DOM Parcel Client *******/ /******* React Server DOM Parcel Client *******/
@ -711,7 +746,14 @@ const bundles = [
condition: 'react-server', condition: 'react-server',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'util', 'crypto', 'async_hooks', 'react-dom'], externals: [
'react',
'react-dom',
'async_hooks',
'crypto',
'stream',
'util',
],
}, },
/******* React Server DOM ESM Client *******/ /******* React Server DOM ESM Client *******/
@ -729,7 +771,7 @@ const bundles = [
entry: 'react-server-dom-esm/client.node', entry: 'react-server-dom-esm/client.node',
minifyWithProdErrorCodes: false, minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false, wrapWithModuleBoundaries: false,
externals: ['react', 'react-dom', 'util', 'crypto'], externals: ['react', 'react-dom', 'util'],
}, },
/******* React Server DOM ESM Node.js Loader *******/ /******* React Server DOM ESM Node.js Loader *******/
@ -1215,6 +1257,8 @@ const bundles = [
'hermes-parser', 'hermes-parser',
'zod', 'zod',
'zod-validation-error', 'zod-validation-error',
'crypto',
'util',
], ],
tsconfig: './packages/eslint-plugin-react-hooks/tsconfig.json', tsconfig: './packages/eslint-plugin-react-hooks/tsconfig.json',
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`, 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`,