Skip to content

refactor(metro-file-map): Pre-resolve symlink targets and store normal posix paths#1687

Open
kitten wants to merge 4 commits intofacebook:mainfrom
kitten:@kitten/refactor/metro-file-map/preresolve-symlinks-and-normalize
Open

refactor(metro-file-map): Pre-resolve symlink targets and store normal posix paths#1687
kitten wants to merge 4 commits intofacebook:mainfrom
kitten:@kitten/refactor/metro-file-map/preresolve-symlinks-and-normalize

Conversation

@kitten
Copy link
Copy Markdown
Contributor

@kitten kitten commented Apr 11, 2026

Summary

Note

This is part of the same pick/patch-set from an experiment on the Expo repo,
like #1676, #1677, and #1686, for metro-file-map (conflicts are expected, since changes were pulled out into separate PRs for clarity)

The symlinks have two oddities to them compared to other file data operations and entries:

  • a separate WeakMap cache is kept for resolved symlink targets that have been converted
  • the values stored for symlink targets may be absolute paths and are unnormalised system paths

The WeakMap (in theory) is inefficient especially for projects with a larger amount of symlinks. It's also not necessary since the values can be trivially pre-resolved to a normal path. We can additionally store this value as a posix normal path, to make sure that it's identical between systems, which may help testing.

Changelog: [Internal] Pre-resolve symlinks and store normalized symlink targets in file map

Test plan

  • Unit tests were added to demonstrate the changes
  • This can further be tested E2E in the linked Expo PR, although not in isolation (if necessary I can create a new, isolated branch with a pnpm patch for these changes)

kitten added 4 commits April 11, 2026 01:37
The WeakMap is likely more expensive and this can leave unnormalized
absolute paths in the file map cache.

NOTE: This bumps the `CACHE_BREAKER` value!
This keeps the metro-file-map value system-stable. Before they could
store absolute paths, and system paths, however, this is now normalized
to posix normal paths.
@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 Apr 11, 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 Apr 11, 2026
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.

1 participant