Repository navigation
perf(binding): parse each importer once to locate its module references - #900
Merged
Merged
Conversation
Every resolver request parsed the importing file again, with a full semantic build, to find where it references the specifier, so a file with k imports was parsed k extra times per extraction. Index every reference of a source in one parse and keep that index with the source for the extraction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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.
Summary
ResolverState::requestruns before every JS resolver call. It parsed the importing file and ran a semantic build with nodes, just to find where the file references that one specifier (needed only if the resolver later fails). A file with k imports was parsed k extra times per extraction. Imported modules that get explored for constants, barrels or styled definitions paid the same again.original_module_referencesnow indexes every specifier's locations in one parse, with one forward pass for line/column (before, each offset re-scanned the prefix).ResolverStatekeeps the index in aOnceCellper source for the life of the extraction.original_module_reference_locationskeeps its signature and output, so all the existing location tests still pin the behaviour. Diagnostics are unchanged.Measure
The large-app rows from #899 (each component imports from
@devup-ui/reactand../tokens; each route imports from the barrel).Test plan
cargo test -p extractor module_reference(11, including a new multi-specifier index test)cargo test -p devup-ui-binding-core,cargo test -p devup-ui-wasm resolvercargo clippy --workspace --all-targets --all-features -D warningsRefs #686
🤖 Generated with Claude Code