Repository navigation
Conversation
`cleanOutDir` globs `clean` with `cwd: config.cwd`, but the guard that rejects a pattern pointing at the working directory resolved it against `process.cwd()`. Workspace mode sets `cwd` to the package directory, so the two differ and the guard stops matching: `clean: ['.']` in a package config deletes that package's sources instead of throwing. The same mismatch rejects a pattern that only resolves to the cwd when read from `process.cwd()`, aborting a build that asked for nothing of the kind.
✅ 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 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.
AI usage
Description
cleanOutDirglobs thecleanpatterns withcwd: config.cwd(src/features/clean.ts:28-33), butresolveCleanvalidates them withpath.resolve(item), which resolves againstprocess.cwd()(src/features/clean.ts:66). The two ends of the same option disagree about what the patterns are relative to.cwddefaults to the package directory in workspace mode (src/config/types.ts:471-477), soconfig.cwd !== process.cwd()is a normal state, and in it the guard can never match.clean: ['.']in a package config stops throwing and globs to every file under that package, each of which goes tofsRemove. The new test reproduces it: without the fix it fails with[UNRESOLVED_ENTRY] Cannot resolve entry module index.ts, because the entry was deleted before the build read it.The mismatch fires the other way too. With
cwdat<root>/pkgandclean: ['pkg'],path.resolve('pkg')equals the cwd, so the build aborts with "Cannot clean the current working directory" even though that pattern means<root>/pkg/pkgoncecleanOutDirglobs it.The fix resolves the pattern the way
cleanOutDirwill, matching theexe.outDirline just above it.Linked Issues
None open describes this.
Additional context
Per-format overrides have the same hole and I left them alone.
format: { es: { clean: ['.'] } }replaces the resolved array atsrc/config/options.ts:311-320afterresolveCleanhas already run, so the guard is skipped even whencwd === process.cwd(); I checked, andindex.tsis deleted. #920 is already movingresolveCleaninto that loop and passescwd, so it inherits this fix unchanged.