Skip to content

Route virtualized-lists feature flags through react-private-interface - #57940

Open
giaBaoJS wants to merge 1 commit into
react:mainfrom
giaBaoJS:fix-57933-virtualized-lists-exports
Open

Route virtualized-lists feature flags through react-private-interface#57940
giaBaoJS wants to merge 1 commit into
react:mainfrom
giaBaoJS:fix-57933-virtualized-lists-exports

Conversation

@giaBaoJS

@giaBaoJS giaBaoJS commented Aug 13, 2026

Copy link
Copy Markdown

Summary:

Fixes #57933.

@react-native/virtualized-lists is published separately and used to import ReactNativeFeatureFlags through the unexported path react-native/src/private/featureflags/ReactNativeFeatureFlags. Metro therefore warned and fell back to file-based resolution whenever an app rendered a virtualized list.

Following the maintainer's suggested direction, this PR now:

  • exposes ReactNativeFeatureFlags from the existing private package boundary, react-native/react-private-interface;
  • routes both runtime consumers (VirtualizedList.js and VirtualizeUtils.js) through that boundary; and
  • keeps the generic monorepo guard that rejects runtime deep imports from published packages when the target subpath is not exported.

This avoids exposing any new src/private/* subpath while preserving the existing feature-flag singleton.

The four similar imports in @react-native/jest-preset remain out of scope because they are all import type and are erased before resolution.

Changelog:

[GENERAL] [FIXED] - Fix the Metro package-exports warning caused by @react-native/virtualized-lists importing an unexported React Native subpath.

Test Plan:

The regression test is intentionally independent of Jest's patched resolver: it reads the package exports map directly and checks runtime imports shipped by published workspace packages.

Counterfactual with the final test kept but only the two virtualized-lists imports reverted:

FAIL package exports › published packages must only deep import exported react-native subpaths

@react-native/virtualized-lists: Lists/VirtualizeUtils.js imports
'react-native/src/private/featureflags/ReactNativeFeatureFlags',
which is not listed in react-native's \"exports\"

@react-native/virtualized-lists: Lists/VirtualizedList.js imports
'react-native/src/private/featureflags/ReactNativeFeatureFlags',
which is not listed in react-native's \"exports\"

Restoring the private-interface imports makes the same test pass.

After rebasing onto current main:

yarn test scripts/monorepo-tests/__tests__/check-packages-test.js \
  packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js \
  packages/virtualized-lists/Lists/__tests__/VirtualizeUtils-test.js --runInBand

3 suites passed
106 tests passed / 1 skipped
59 snapshots passed

yarn flow-check
Found 0 errors

yarn lint
Done (0 warnings, 0 errors)

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 13, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 13, 2026
@huntie

huntie commented Aug 13, 2026

Copy link
Copy Markdown
Member

Great spot! We'll need to solve this slightly differently however, I think by adding this API to react-private-interface.

import {ReactNativeFeatureFlags} from 'react-native/react-private-interface';

Patch here: https://gist.github.com/huntie/0523e2dd114dacf904d28211ad6b67be. Can you apply/retitle this PR to match? :)

@giaBaoJS
giaBaoJS force-pushed the fix-57933-virtualized-lists-exports branch from 7cfe4fb to 3c68fe8 Compare August 18, 2026 15:14
@giaBaoJS giaBaoJS changed the title Export the ReactNativeFeatureFlags subpath used by virtualized-lists Route virtualized-lists feature flags through react-private-interface Aug 18, 2026
});
});

// Files matching these patterns are excluded from every published package via

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.87.0] VirtualizedList triggers Metro package-exports warning

2 participants