Fix FB_WWW eprh bundle dev guard (#36238)
We use FB_WWW bundle to inject internal feature flag values, but need to use NODE guard type because this is a node script -- __DEV__ is breaking internal builds Follow up to https://github.com/facebook/react/pull/35951
Jack Pope committed
Apr 8, 2026 at 14:12 UTC
733d3aaf99e30627ec25174da9d39efbaa97dba3
3 files changed
+15
-4
scripts/rollup/build.js
+2
-1
@@ -453,7 +453,8 @@ function getPlugins(
453
globalName,
454
filename,
455
moduleType,
456
- bundle.wrapWithModuleBoundaries
456
+ bundle.wrapWithModuleBoundaries,
457
+ bundle.wrapWithNodeDevGuard
458
);
459
},
460
},
scripts/rollup/bundles.js
+4
-1
@@ -1235,12 +1235,15 @@ const bundles = [
1235
// currently required in order for the package to be copied over correctly.
1236
// So, it would be worth improving that flow.
1237
name: 'eslint-plugin-react-hooks',
1238
- bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD, CJS_DTS],
1238
+ bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, CJS_DTS],
1239
moduleType: ISOMORPHIC,
1240
entry: 'eslint-plugin-react-hooks/src/index.ts',
1241
global: 'ESLintPluginReactHooks',
1242
minifyWithProdErrorCodes: false,
1243
wrapWithModuleBoundaries: false,
1244
+ // This is a Node.js build tool (ESLint plugin), not a www runtime bundle.
1245
+ // Use process.env.NODE_ENV guard instead of __DEV__ for the dev wrapper.
1246
+ wrapWithNodeDevGuard: true,
1247
preferBuiltins: true,
1248
externals: [
1249
'@babel/core',
scripts/rollup/wrappers.js
+9
-2
@@ -510,7 +510,8 @@ function wrapWithTopLevelDefinitions(
510
globalName,
511
filename,
512
moduleType,
513
- wrapWithModuleBoundaries
513
+ wrapWithModuleBoundaries,
514
+ wrapWithNodeDevGuard
515
) {
516
if (wrapWithModuleBoundaries) {
517
switch (bundleType) {
@@ -553,8 +554,14 @@ function wrapWithTopLevelDefinitions(
554
return wrapper(source, globalName, filename, moduleType);
555
}
556
557
+ // Node.js build tools (e.g. ESLint plugins) use process.env.NODE_ENV instead
558
+ // of __DEV__ even when building for FB_WWW, since they run in Node.js where
559
+ // __DEV__ is not defined.
560
+ const effectiveBundleType =
561
+ wrapWithNodeDevGuard && bundleType === FB_WWW_DEV ? NODE_DEV : bundleType;
562
+
563
// All the other packages.
557
- const wrapper = topLevelDefinitionWrappers[bundleType];
564
+ const wrapper = topLevelDefinitionWrappers[effectiveBundleType];
565
if (typeof wrapper !== 'function') {
566
throw new Error(`Unsupported build type: ${bundleType}.`);
567
}