Skip to content

feat: delete stale outputs after emit - #1100

Open
edimitchel wants to merge 4 commits into
rolldown:mainfrom
edimitchel:feat/clean-after-emit
Open

edimitchel wants to merge 4 commits into
rolldown:mainfrom
edimitchel:feat/clean-after-emit

Conversation

@edimitchel

Copy link
Copy Markdown

Summary

clean used to delete the previous output before writing the new one. In watch mode that happened on every START, so anything reading outDir (Vite, Nest, tsc --watch) saw a missing package until the rebuild finished.

A single build and every successful watch rebuild now overwrite emitted files, then delete only the clean targets that were not emitted again. Copied files are kept too, so they are not unlinked before copy runs. Several one-shot builds started together still wipe first: they can share one output directory, and a post-build sweep from one config would delete the others' files.

Refs #1079

Test plan

  • vitest run tests/clean.test.ts (existing clean cases, plus a write-time probe and a watch rebuild)
  • Start tsdown --watch next to a consumer that imports dist, edit a source file, and confirm the consumer no longer fails while dist is being rewritten
  • Delete a source file under unbundle / hashed output and confirm the orphan is removed only after the rebuild succeeds

Watch rebuilds and a single build overwrite files in place, then remove
only the clean targets that were not emitted again. Several one-shot
builds still wipe first so they can share one output directory.
@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit a00f9fe
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6ad2459d679952ee3c59ceeb
😎 Deploy Preview https://deploy-preview-1100--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 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

tsdown

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

create-tsdown

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

@tsdown/css

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

@tsdown/exe

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

tsdown-migrate

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

commit: a00f9fe

It still named OutputChunk and OutputAsset after their import was removed.
ESM and CJS each finished by deleting every file the other had just
emitted, including dist/index.d.mts. A clean now waits until every
in-flight build for that directory has recorded its outputs, then
removes only files none of them emitted again.
Rolldown's incremental watch removes a shared outDir between passes, so
tsdown --watch can leave dist empty. Watch the project and run a normal
build instead.

This branch has not been deployed

No deployments
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