Repository navigation
Conversation
## Context #1949 records what a resolution looks up in the file map, but Haste lookups aren't paths. With `allowHaste`, every bare specifier is looked up by name in the Haste map, and a module of that name appearing later changes the result. So the name needs observing whether or not it was found. ## This change This adds `haste` to `ResolutionObservations`. It's the bare name, not the platform, because `HastePlugin` falls back from platform to `native` to generic and a change to any of those can change the answer: https://github.com/react/metro/blob/6dbe97956af0f66f7a1d88014ba0b784a4a4d893/packages/metro-file-map/src/plugins/HastePlugin.js#L194-L213 It's free in the default config, where nothing can have a Haste name and the map is empty. Otherwise the set is created on the first name recorded, since most resolutions are relative imports that never consult Haste. No measurable cost either way. Invalidating from these needs `HastePlugin` to report which names a change rebound, which is #1953. ## Benchmark AI-driven, flag on in all columns, 7 interleaved rounds. Everything is within half a percent, inside the run-to-run spread. | scenario | #1949 | this PR | #1949, Haste enabled | this PR, Haste enabled | |---|---|---|---|---| | first build (ms) | 112.4 | 111.8 | 111.2 | 110.6 | | rebuild, nothing changed (ms) | 7.75 | 7.78 | 7.81 | 7.79 | | after a source edit, the edited module's dependencies (µs) | 177 | 168 | 170 | 172 | | after a `package.json` change, re-resolving everything (ms) | 93.2 | 93.2 | 93.6 | 94.1 | | heap retained after resolving (MB) | 18.8 | 18.8 | | 19.1 | Changelog: Internal ## Test plan New tests cover Haste inert, a name found and not found, a deep import, and a relative import. Benchmark app: the synthetic RN 0.87 app described in #1945 (2.8k-module bundle, 34k-file file map). "Haste enabled" sets `enableGlobalPackages: true`, which gives its first-party packages Haste names.
Collaborator
Author
|
Opened by mistake, duplicate of #1952 |
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.
Context
#1949 records what a resolution looks up in the file map, but Haste lookups aren't paths. With
allowHaste, every bare specifier is looked up by name in the Haste map, and a module of that name appearing later changes the result. So the name needs observing whether or not it was found.This change
This adds
hastetoResolutionObservations. It's the bare name, not the platform, becauseHastePluginfalls back from platform tonativeto generic and a change to any of those can change the answer:metro/packages/metro-file-map/src/plugins/HastePlugin.js
Lines 194 to 213 in 6dbe979
It's free in the default config, where nothing can have a Haste name and the map is empty. Otherwise the set is created on the first name recorded, since most resolutions are relative imports that never consult Haste. No measurable cost either way.
Invalidating from these needs
HastePluginto report which names a change rebound, which is #1953.Benchmark
AI-driven, flag on in all columns, 7 interleaved rounds. Everything is within half a percent, inside the run-to-run spread.
package.jsonchange, re-resolving everything (ms)Changelog: Internal
Test plan
New tests cover Haste inert, a name found and not found, a deep import, and a relative import.
Benchmark app: the synthetic RN 0.87 app described in #1945 (2.8k-module bundle, 34k-file file map). "Haste enabled" sets
enableGlobalPackages: true, which gives its first-party packages Haste names.