Skip to content

perf(binding): parse each importer once to locate its module references - #900

Merged
owjs3901 merged 1 commit into
mainfrom
perf/resolver-cache
Nov 14, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
perf/resolver-cache

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

  • ResolverState::request runs 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_references now indexes every specifier's locations in one parse, with one forward pass for line/column (before, each offset re-scanned the prefix). ResolverState keeps the index in a OnceCell per source for the life of the extraction.
  • original_module_reference_locations keeps 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/react and ../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 resolver
  • cargo clippy --workspace --all-targets --all-features -D warnings
  • CI (coverage 100%)

Refs #686

🤖 Generated with Claude Code

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

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
libs/binding/src/resolver_state.rs 100.00% <100.00%> (ø)
libs/extractor/src/module_reference.rs 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@owjs3901
owjs3901 merged commit 6bcb1ac into main Nov 14, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant