Conversation
robhogan
added this pull request to stack #2016
October 3, 2026 21:33
robhogan
marked this pull request as ready for review
October 3, 2026 21:36
robhogan
requested review from
huntie and
motiz88
and
a balanced review from Copilot
October 3, 2026 21:38
There was a problem hiding this comment.
Copilot review overview
馃煝 Approval recommended
The refactor preserves existing routing semantics and includes focused unit and integration coverage for Windows behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Centralizes Metro鈥檚 virtual project/watch-folder URL routing and fixes Windows bundle serving.
Changes:
- Adds bidirectional path/URL mapping via
ProjectRouteMap. - Refactors Server routing, asset handling, and source URLs.
- Enables Windows integration coverage.
| File | Description |
|---|---|
packages/鈥媘etro/鈥媠rc/鈥婼erver.js |
Delegates routing to ProjectRouteMap. |
packages/鈥媘etro/鈥媠rc/鈥婼erver/鈥媉_tests__/鈥婼erver-test.js |
Updates asset and round-trip assertions. |
packages/鈥媘etro/鈥媠rc/鈥媗ib/鈥婸rojectRouteMap.js |
Implements virtual-prefix mappings. |
packages/鈥媘etro/鈥媠rc/鈥媗ib/鈥媉_tests__/鈥婸rojectRouteMap-test.js |
Tests route-map behavior. |
packages/鈥媘etro/鈥媠rc/鈥媔ntegration_tests/鈥媉_tests__/鈥媠erver-test.js |
Enables cross-platform prefixed-route tests. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
*Recreating #1707 / [D104223068](https://www.internalfb.com/diff/D104223068) (@motiz88) for GH first without a diff attachment* Extracts a `ProjectRouteMap` class from `Server`, centralising the `[metro-watchFolders]` and `[metro-project]` virtual prefix resolution previously spread across `_resolveWatchFolderPrefix`, `_sourceRequestRoutingMap`, and `_getModuleSourceUrl`. `ProjectRouteMap` provides: - `filePathOfUrlDecodedPathname`: resolves `[metro-project]/...` and `[metro-watchFolders]/N/...` prefixed pathnames to absolute file paths. Returns null for non-prefixed paths or invalid indices. - `urlPathnameOfFilePath`: maps an absolute file path to the corresponding prefixed URL pathname. Server now delegates to `ProjectRouteMap` from `_resolveRelativePath`, `_getEntryPointAbsolutePath`, `_getModuleSourceUrl`, and source file serving. No behavioural change is intended here, but this does incidentally fix a Windows bug that was affecting the original implementation. Changelog: * **[Fix]:** Fix `/[metro-project]/` and `/[metro-watchFolders]/` bundle serving on Windows. Test plan: See [D104223068](https://www.internalfb.com/diff/D104223068)
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.
Recreating #1707 / D104223068 (@motiz88) for GH first without a diff attachment
Extracts a
ProjectRouteMapclass fromServer, centralising the[metro-watchFolders]and[metro-project]virtual prefix resolution previously spread across_resolveWatchFolderPrefix,_sourceRequestRoutingMap, and_getModuleSourceUrl.ProjectRouteMapprovides:filePathOfUrlDecodedPathname: resolves[metro-project]/...and[metro-watchFolders]/N/...prefixed pathnames to absolute file paths. Returns null for non-prefixed paths or invalid indices.urlPathnameOfFilePath: maps an absolute file path to the corresponding prefixed URL pathname.Server now delegates to
ProjectRouteMapfrom_resolveRelativePath,_getEntryPointAbsolutePath,_getModuleSourceUrl, and source file serving.No behavioural change is intended here, but this does incidentally fix a Windows bug that was affecting the original implementation.
Changelog:
/[metro-project]/and/[metro-watchFolders]/bundle serving on Windows.Test plan:
See D104223068