Repository navigation
feat: delete stale outputs after emit - #1100
Open
edimitchel wants to merge 4 commits into
Open
edimitchel wants to merge 4 commits into
edimitchel wants to merge 4 commits into
Conversation
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.
✅ Deploy Preview for tsdown-main ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
tsdown
create-tsdown
@tsdown/css
@tsdown/exe
tsdown-migrate
commit: |
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
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
cleanused to delete the previous output before writing the new one. In watch mode that happened on everySTART, so anything readingoutDir(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
copyruns. 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)tsdown --watchnext to a consumer that importsdist, edit a source file, and confirm the consumer no longer fails whiledistis being rewrittenunbundle/ hashed output and confirm the orphan is removed only after the rebuild succeeds