Use www feature flags for eslint-plugin-react-hooks without __DEV__#36230
Draft
EugeneChoi4 wants to merge 1 commit intofacebook:mainfrom
Draft
Use www feature flags for eslint-plugin-react-hooks without __DEV__#36230EugeneChoi4 wants to merge 1 commit intofacebook:mainfrom
EugeneChoi4 wants to merge 1 commit intofacebook:mainfrom
Conversation
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
|
Comparing: 1b45e24...7f540c3 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#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 ofif (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:
forks.jsbased on entry + bundleTypewrappers.jsbased on bundleTypeBy adding an entry-specific override in
forks.jsfor eslint-plugin-react-hooks, we can useReactFeatureFlags.www.js(www flag values) withNODE_DEVbundleType (process.env.NODE_ENVwrapper). This gives us www feature flags without__DEV__.Changes:
Summary
How did you test this change?