Skip to content

Use www feature flags for eslint-plugin-react-hooks without __DEV__#36230

Draft
EugeneChoi4 wants to merge 1 commit intofacebook:mainfrom
EugeneChoi4:fix/eslint-plugin-react-hooks-dev-guard
Draft

Use www feature flags for eslint-plugin-react-hooks without __DEV__#36230
EugeneChoi4 wants to merge 1 commit intofacebook:mainfrom
EugeneChoi4:fix/eslint-plugin-react-hooks-dev-guard

Conversation

@EugeneChoi4
Copy link
Copy Markdown
Contributor

#35951 added ReactFeatureFlags support to eslint-plugin-react-hooks by adding FB_WWW_DEV/FB_WWW_PROD bundle types and copying the www build output for DiffTrain. However, the FB_WWW wrapper uses if (__DEV__) instead of if (process.env.NODE_ENV !== "production"), which causes ReferenceErrors in Node.js environments (Jest tests, arc lint) where __DEV__ is not defined.

The fix exploits the fact that feature flag resolution and the dev/prod wrapper are independent in the React build system:

  • Feature flags are resolved via forks.js based on entry + bundleType
  • The dev/prod wrapper is chosen via wrappers.js based on bundleType

By adding an entry-specific override in forks.js for eslint-plugin-react-hooks, we can use ReactFeatureFlags.www.js (www flag values) with NODE_DEV bundleType (process.env.NODE_ENV wrapper). This gives us www feature flags without __DEV__.

Changes:

  • forks.js: Return ReactFeatureFlags.www.js for eslint-plugin-react-hooks regardless of bundleType
  • bundles.js: Remove FB_WWW_DEV/FB_WWW_PROD (no longer needed)
  • runtime_commit_artifacts.yml: Copy NODE_DEV output instead of FB_WWW_DEV
  • validate/index.js: Remove ESLintPluginReactHooks www validation skip

Summary

How did you test this change?

PR facebook#35951 added ReactFeatureFlags support to eslint-plugin-react-hooks
by adding FB_WWW_DEV/FB_WWW_PROD bundle types and copying the www build
output for DiffTrain. However, the FB_WWW wrapper uses `if (__DEV__)`
instead of `if (process.env.NODE_ENV !== "production")`, which causes
ReferenceErrors in Node.js environments (Jest tests, arc lint) where
`__DEV__` is not defined.

The fix exploits the fact that feature flag resolution and the dev/prod
wrapper are independent in the React build system:

- Feature flags are resolved via `forks.js` based on entry + bundleType
- The dev/prod wrapper is chosen via `wrappers.js` based on bundleType

By adding an entry-specific override in `forks.js` for
eslint-plugin-react-hooks, we can use `ReactFeatureFlags.www.js` (www
flag values) with `NODE_DEV` bundleType (`process.env.NODE_ENV` wrapper).
This gives us www feature flags without `__DEV__`.

Changes:
- forks.js: Return ReactFeatureFlags.www.js for eslint-plugin-react-hooks
  regardless of bundleType
- bundles.js: Remove FB_WWW_DEV/FB_WWW_PROD (no longer needed)
- runtime_commit_artifacts.yml: Copy NODE_DEV output instead of FB_WWW_DEV
- validate/index.js: Remove ESLintPluginReactHooks www validation skip
@meta-cla meta-cla bot added the CLA Signed label Apr 8, 2026
@react-sizebot
Copy link
Copy Markdown

Comparing: 1b45e24...7f540c3

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 612.91 kB 612.91 kB = 108.30 kB 108.31 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 678.85 kB 678.85 kB = 119.27 kB 119.27 kB
facebook-www/ReactDOM-prod.classic.js = 698.24 kB 698.24 kB = 122.65 kB 122.65 kB
facebook-www/ReactDOM-prod.modern.js = 688.55 kB 688.55 kB = 121.03 kB 121.03 kB
facebook-www/ESLintPluginReactHooks-dev.classic.js Deleted 2,042.93 kB 0.00 kB Deleted 298.53 kB 0.00 kB
facebook-www/ESLintPluginReactHooks-dev.modern.js Deleted 2,042.93 kB 0.00 kB Deleted 298.53 kB 0.00 kB
facebook-www/ESLintPluginReactHooks-prod.classic.js Deleted 2,038.50 kB 0.00 kB Deleted 297.56 kB 0.00 kB
facebook-www/ESLintPluginReactHooks-prod.modern.js Deleted 2,038.50 kB 0.00 kB Deleted 297.56 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ESLintPluginReactHooks-dev.classic.js Deleted 2,042.93 kB 0.00 kB Deleted 298.53 kB 0.00 kB
facebook-www/ESLintPluginReactHooks-dev.modern.js Deleted 2,042.93 kB 0.00 kB Deleted 298.53 kB 0.00 kB
facebook-www/ESLintPluginReactHooks-prod.classic.js Deleted 2,038.50 kB 0.00 kB Deleted 297.56 kB 0.00 kB
facebook-www/ESLintPluginReactHooks-prod.modern.js Deleted 2,038.50 kB 0.00 kB Deleted 297.56 kB 0.00 kB

Generated by 🚫 dangerJS against 7f540c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants