Skip to content

perf(plugin-utils): remember package resolutions and module code in the resolver - #901

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

owjs3901 merged 1 commit into
mainfrom
perf/js-resolver-memo

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

  • createModuleResolver now remembers package resolutions per importing directory. An entry stays until the package manifest's stamp changes or the entry file disappears. onPackageManifest is still reported on every hit.
  • Module code is cached per path and read again only when the file's stamp (mtime, ctime, size) changes.
  • Misses are never cached, so a package installed or a file created later is still found.

The extractor's resolver state is per file, so before this a shared module (tokens, a barrel, a package) was found and read again for every importer.

Test plan

  • bun test src/import-graph.test.ts --coverage: import-graph.ts at 100% lines and functions
  • New tests cover re-reading after an edit, a manifest change, a removed entry, and a removed package
  • CI

🤖 Generated with Claude Code

…he resolver

The extractor asks the resolver again for every file that imports a module,
so a shared token file or package was found and read once per importer.
Package resolutions are kept per importing directory until the manifest or
the entry changes, and module code until the file's stamp changes. Misses
are not kept, so a package installed later is still found.

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 Δ
packages/plugin-utils/src/import-graph.ts 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 dda29d6 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