You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expose ReactNativeFeatureFlags through react-private-interface (#57940)
Summary:
Fixes#57933.
`react-native/virtualized-lists` is published separately and imported `ReactNativeFeatureFlags` through `react-native/src/private/featureflags/ReactNativeFeatureFlags`, which is not listed in `react-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:
- `ReactNativeFeatureFlags` is exposed on the existing private package boundary, `react-native/react-private-interface` (both the runtime getter and the `.js.flow` re-export);
- `VirtualizedList.js` and `VirtualizeUtils.js` import 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.js` and `scripts/shared/monorepoUtils.js` changes have been dropped — the PR is now just the patch above. Happy to look at enabling `react-native/no-deep-imports` on `virtualized-lists` as a follow-up if that's wanted.
`VirtualizeUtils.js` is included alongside `VirtualizedList.js` because it carried the same runtime deep import. The remaining occurrences are out of scope: the four in `react-native/jest-preset` are all `import type` and are erased before resolution, and the one in `VirtualizeUtils-test.js` is not shipped (`virtualized-lists` excludes `**/__tests__/**` from `files`).
## Changelog:
[GENERAL] [FIXED] - Fix the Metro package-exports warning caused by `react-native/virtualized-lists` importing an unexported React Native subpath.
Pull Request resolved: #57940
Test Plan:
No new test is added. The existing `virtualized-lists` suites already cover this route, because `VirtualizeUtils`/`VirtualizedList` read the flags at runtime through the new boundary.
Counterfactual — dropping only the `ReactNativeFeatureFlags` getter and its `import typeof` from `react-private-interface.js`, keeping the two `virtualized-lists` imports:
```text
TypeError: Cannot read properties of undefined (reading 'fixVirtualizeListCollapseWindowSize')
182 | let lastWillAddMore;
183 |
> 184 | if (ReactNativeFeatureFlags.fixVirtualizeListCollapseWindowSize()) {
| ^
at computeWindowedRenderLimits (packages/virtualized-lists/Lists/VirtualizeUtils.js:184:32)
at Object.<anonymous> (packages/virtualized-lists/Lists/__tests__/VirtualizeUtils-test.js:261:47)
Test Suites: 2 failed, 6 passed, 8 total
Tests: 20 failed, 1 skipped, 151 passed, 172 total
```
Restoring the getter makes it green again.
```text
$ yarn jest packages/virtualized-lists scripts/monorepo-tests packages/react-native/Libraries/ReactPrivate --runInBand
Test Suites: 9 passed, 9 total
Tests: 1 skipped, 176 passed, 177 total
Snapshots: 69 passed, 69 total
$ yarn flow-check
Found 0 errors
$ yarn lint
$ eslint --max-warnings 0 .
Done in 10.23s.
```
Reviewed By: javache
Differential Revision: D119164284
Pulled By: cortinico
fbshipit-source-id: 1e8ae3b85ae7fb28c55f207f887a97aad85b563c
0 commit comments