Expose ReactNativeFeatureFlags through react-private-interface - #57940
Expose ReactNativeFeatureFlags through react-private-interface#57940giaBaoJS wants to merge 1 commit into
Conversation
|
Great spot! We'll need to solve this slightly differently however, I think by adding this API to import {ReactNativeFeatureFlags} from 'react-native/react-private-interface';Patch here: https://gist.github.com/huntie/0523e2dd114dacf904d28211ad6b67be. Can you apply/retitle this PR to match? :) |
7cfe4fb to
3c68fe8
Compare
| }); | ||
| }); | ||
|
|
||
| // Files matching these patterns are excluded from every published package via |
There was a problem hiding this comment.
Can we drop or separate out the changes from this file?
At minimum, we've reimplemented ESLint and should instead reuse it — should be a case of enabling the react-native/no-deep-imports rule directly on the virtualized-lists codebase. (But also, we're probably fine without adding new checks.)
3c68fe8 to
7deb545
Compare
|
Thanks for the patch @huntie — applied and retitled. I also routed |
Hardcode support for the react-native/react-private-interface package
export ("types": null) so build-types does not expand src/private/*
dependencies into types_generated.
This unblocks exposing ReactNativeFeatureFlags through
react-private-interface (react#57940).
- Skip the import in simpleResolve
- Do not follow src/private deps from react-private-interface.js.flow
- Strip ./private/* re-exports from the generated .d.ts
- Give api-extractor a minimal temp exports map for this subpath
Co-authored-by: Alex Hunt <huntie@users.noreply.github.com>
Minimum fix for react#57940: when react-private-interface gains a ReactNativeFeatureFlags export, do not translate src/private/featureflags/* into types_generated. - Skip react-native/react-private-interface in simpleResolve - Block feature-flags deps from react-private-interface.js.flow - Strip the feature-flags re-export from the generated .d.ts Co-authored-by: Alex Hunt <huntie@users.noreply.github.com>
|
No problem at all — thanks for digging into the root cause and drafting #58075 rather than asking me to work around it. I'll leave this as-is and rebase once that lands; ping me if you want the |
Summary:
Fixes #57933.
@react-native/virtualized-listsis published separately and importedReactNativeFeatureFlagsthroughreact-native/src/private/featureflags/ReactNativeFeatureFlags, which is not listed inreact-native's"exports". Metro therefore warned and fell back to file-based resolution whenever an app rendered a virtualized list.Thanks @huntie for the patch and the direction — this PR now applies it instead of the original approach:
ReactNativeFeatureFlagsis exposed on the existing private package boundary,react-native/react-private-interface(both the runtime getter and the.js.flowre-export);VirtualizedList.jsandVirtualizeUtils.jsimport it from there.No new
src/private/*subpath is exported, and the feature-flag singleton is unchanged.Per your review, the
scripts/monorepo-tests/__tests__/check-packages-test.jsandscripts/shared/monorepoUtils.jschanges have been dropped — the PR is now just the patch above. Happy to look at enabling@react-native/no-deep-importsonvirtualized-listsas a follow-up if that's wanted.VirtualizeUtils.jsis included alongsideVirtualizedList.jsbecause it carried the same runtime deep import. The remaining occurrences are out of scope: the four in@react-native/jest-presetare allimport typeand are erased before resolution, and the one inVirtualizeUtils-test.jsis not shipped (virtualized-listsexcludes**/__tests__/**fromfiles).Changelog:
[GENERAL] [FIXED] - Fix the Metro package-exports warning caused by
@react-native/virtualized-listsimporting an unexported React Native subpath.Test Plan:
No new test is added. The existing
virtualized-listssuites already cover this route, becauseVirtualizeUtils/VirtualizedListread the flags at runtime through the new boundary.Counterfactual — dropping only the
ReactNativeFeatureFlagsgetter and itsimport typeoffromreact-private-interface.js, keeping the twovirtualized-listsimports:Restoring the getter makes it green again.