unstable_enablePackageExports and unstable_enableSymlinks in combination may result in non-real module paths in the graph, because PackageExportsResolve only uses context.doesFileExist and does not necessarily return real paths.
Often, especially with pnpm, this results in a module appearing multiple times under different paths in the output bundle, as if duplicated on the file system, which causes incorrect behaviour for stateful modules and increases bundle size.
The fix mirrors the implementation of resolveSourceFileForExt in the non-exports resolver.
Changelog:
- **[Experimental]:** Fix module duplication due to non-real resolved paths when combining `unstable_enablePackageExports` and `unstable_enableSymlinks`.
Summary: Fix: https://github.com/facebook/metro/issues/1197
unstable_enablePackageExports
andunstable_enableSymlinks
in combination may result in non-real module paths in the graph, becausePackageExportsResolve
only usescontext.doesFileExist
and does not necessarily return real paths.Often, especially with pnpm, this results in a module appearing multiple times under different paths in the output bundle, as if duplicated on the file system, which causes incorrect behaviour for stateful modules and increases bundle size.
The fix mirrors the implementation of
resolveSourceFileForExt
in the non-exports resolver.Changelog:
Differential Revision: D52964393