Skip to content

perf(deps): read each package.json once when resolving dep subpaths - #1093

Merged
sxzz merged 3 commits into
rolldown:mainfrom
Cherry:perf/cache-dep-subpath-exports
Nov 2, 2026
Merged

sxzz merged 3 commits into
rolldown:mainfrom
Cherry:perf/cache-dep-subpath-exports

Conversation

@Cherry

@Cherry Cherry commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

AI usage

  • No AI was used in this PR.
  • AI was used: Claude Opus 5.5
    • I have carefully reviewed the AI-generated content myself.

Description

With deps.resolveDepSubpath turned on, every subpath import reads and parses the dependency's package.json again just to check for exports. We noticed it in one of our builds, which parsed drizzle-orm's 177 KB package.json over 5,000 times.

This caches that check per package.json for the build, and clears it on buildStart so watch rebuilds still pick up changes. On a fixture with 600 files importing subpaths of one big package, our builds went from ~1.75s to ~0.5s, about the same as with the option off.

Added a test that imports subpaths of a package with exports and one without, from a couple of files, to make sure each package still gets its own answer.

@netlify

netlify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit f1cc317
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6ae885b3bea2d20118ff40bf
😎 Deploy Preview https://deploy-preview-1093--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown@1093 -D
npm i https://pkg.pr.new/rolldown/tsdown@1093 -D
yarn add https://pkg.pr.new/rolldown/tsdown@1093.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1093 -D
npm i https://pkg.pr.new/rolldown/tsdown/create-tsdown@1093 -D
yarn add https://pkg.pr.new/rolldown/tsdown/create-tsdown@1093.tgz -D

@tsdown/css

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1093 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1093 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/css@1093.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1093 -D
npm i https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1093 -D
yarn add https://pkg.pr.new/rolldown/tsdown/@tsdown/exe@1093.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1093 -D
npm i https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1093 -D
yarn add https://pkg.pr.new/rolldown/tsdown/tsdown-migrate@1093.tgz -D

commit: f1cc317

@Cherry
Cherry force-pushed the perf/cache-dep-subpath-exports branch from d9932ed to 8248a43 Compare October 11, 2026 15:45

@Andrew-Smith-93 Andrew-Smith-93 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/e2e.test.ts:1490

Could we add a focused DepsPlugin cache test? Concurrent subpath resolutions sharing one packageJsonPath should cause one read for the exports check. After buildStart, the same plugin should reread it and observe a changed exports field. The current output test would pass without caching, so it doesn’t protect read deduplication or rebuild invalidation.

@Cherry

Cherry commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

yeah that makes sense. Added a unit test in deps.test.ts - it checks that a changed exports field is ignored within a build and picked up after buildStart. It fails if either the cache or the clear is removed. I skipped a separate concurrency test since the cache stores the promise, so concurrent lookups share one read.

Replace the exports-only cache with a package.json cache that
readBundledDepInfo also uses, so bundled modules of a package no longer
re-read its package.json either.
@sxzz
sxzz merged commit 4435a48 into rolldown:main Nov 2, 2026
16 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.

4 participants