Repository navigation
Conversation
Modules with no file on disk need a graph path that can't be mistaken for a real one. This reserves `metro-virtual:<absolute path>` for them (#2036 lets resolvers produce such modules), and updates the places where a module path leaves Metro to handle it. A module path becomes user-visible in development module names, HMR source URLs, server-URL source paths and async bundle paths. Each derives a name from the path with `path` functions, which give machine-dependent results for a path that isn't absolute. They now go through one set of helpers in `lib/virtualModule`: dev names use `metro-virtual:<relative path>`, and URLs get a leading `[metro-virtual]` segment, following `[metro-watchFolders]`. `getAllFiles` leaves virtual modules out, since they have no file. Nothing produces a `metro-virtual:` path until #2036, so existing bundles are unchanged. Changelog: Internal Test plan: New unit tests for the helpers, plus HMR, dev name, async path and `getAllFiles` cases for a virtual module. In particular, a virtual module at the same path as a real file gets distinct HMR URLs.
robhogan
marked this pull request as draft
October 11, 2026 14:41
robhogan
added this pull request to stack #2057
October 11, 2026 14:41
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modules with no file on disk need a graph path that can't be mistaken for a real one. This reserves
metro-virtual:<absolute path>for them (#2036 lets resolvers produce such modules), and updates the places where a module path leaves Metro to handle it.A module path becomes user-visible in development module names, HMR source URLs, server-URL source paths and async bundle paths. Each derives a name from the path with
pathfunctions, which give machine-dependent results for a path that isn't absolute. They now go through one set of helpers inlib/virtualModule: dev names usemetro-virtual:<relative path>, and URLs get a leading[metro-virtual]segment, following[metro-watchFolders].getAllFilesleaves virtual modules out, since they have no file.Nothing produces a
metro-virtual:path until #2036, so existing bundles are unchanged.Changelog: Internal
Test plan: New unit tests for the helpers, plus HMR, dev name, async path and
getAllFilescases for a virtual module. In particular, a virtual module at the same path as a real file gets distinct HMR URLs.