Skip to content

feat(native): cache the runtime-imports walk for detecting undeclared React Native libraries - #791

Open
danfry1 wants to merge 3 commits into
mainfrom
feat/runtime-imports-detection-cache
Open

danfry1 wants to merge 3 commits into
mainfrom
feat/runtime-imports-detection-cache

Conversation

@danfry1

@danfry1 danfry1 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Ecosystem detection can, when asked, detect a declared package that imports react-native without declaring it, and caches each package's runtime-imports walk on disk. Nothing passes the option yet, so behaviour is unchanged.

Why

A React Native library with no react-native dependency or peer is invisible to manifest detection (#763). Its runtime graph carries the signal, but walking every declared package costs hundreds of milliseconds per config evaluation, too much to pay on every start.

Changes

  • src/native/runtime-imports-cache.ts: one entry per installed package, keyed by its directory and valid while its package.json name, version, size and mtime are unchanged. Packages outside node_modules and patched packages (patch-package, pnpm and bun patchedDependencies) are never cached. Stored in node_modules/.cache/vitest-native and written atomically.
  • detectEcosystemPackages takes undeclaredReactNative: { cacheFile }.
  • A package with no root export counts when it has a ./react-native subpath, or one carrying a react-native condition, that the project imports. Other subpaths such as ./react are ignored.

Notes

  • Held for 0.16: wiring it into the plugin is a default-behaviour decision.

Part of #763.

… React Native libraries

Detection can now, when asked, detect a declared package that imports react-native
without declaring it (#763). Each package's walk is cached on disk until its installed
package.json changes; nothing passes the option yet.
@danfry1 danfry1 added this to the 0.16.0 milestone Nov 13, 2026
@danfry1 danfry1 added enhancement New feature or request area:ownership Which side (Node or Vite) loads a module; double instances, aliases, mocks reaching Node code labels Nov 13, 2026
… point

A package with no root export counts when it has a ./react-native subpath, or one
carrying a react-native condition, that the project imports. Its other subpaths,
such as ./react, are ignored.

This branch has not been deployed

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

Labels

area:ownership Which side (Node or Vite) loads a module; double instances, aliases, mocks reaching Node code enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant