fix(config): clean per-format outDir when using object format#920
Open
Kyujenius wants to merge 1 commit intorolldown:mainfrom
Open
fix(config): clean per-format outDir when using object format#920Kyujenius wants to merge 1 commit intorolldown:mainfrom
Kyujenius wants to merge 1 commit intorolldown:mainfrom
Conversation
✅ 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: |
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.
Description
With
format: { esm: { outDir: 'esm' }, cjs: { outDir: 'cjs' } }andclean: true, the per-format directories are never cleaned.resolveCleanruns once against the rootoutDiratsrc/config/options.ts:150and the result is shared across every resolved config via...config— per-formatoutDiroverrides applied later in the map at L346-358 never make it into that array, socleanOutDironly globs the root directory.Deferring
resolveCleaninto the per-format loop gives each config its owncleanarray derived from that format's effectiveoutDir. A user-supplied per-formatclean(overrides?.clean) wins over the top-level one, andoverrides.outDiris resolved to an absolute path in the same place to keep override semantics consistent with the rootoutDir.Linked Issues
fixes: #843
Additional context
The new test in
tests/clean.test.tsfails without the fix and passes with it — it checks that stale files in each per-formatoutDirget removed and that the build still writes new output into the same directories. All existingcleantests still pass; if you don't use per-formatoutDiroverrides, nothing changes — each resolved config still getsresolveClean(true, outDir, cwd)against the shared rootoutDirand produces the same[slash(outDir)]as before.validateSeanever readsclean, so its parameter type is narrowed toOmit<ResolvedConfig, 'clean' | 'format'>. This keeps the intermediateconfigobject type accurate oncecleanmoves out.