Skip to content

fix(clean): only list the output directory when cleaning it - #1092

Open
lifeiscontent wants to merge 3 commits into
rolldown:mainfrom
lifeiscontent:fix/clean-within-outdir
Open

lifeiscontent wants to merge 3 commits into
rolldown:mainfrom
lifeiscontent:fix/clean-within-outdir

Conversation

@lifeiscontent

@lifeiscontent lifeiscontent commented Oct 2, 2026 •

Copy link
Copy Markdown

Some build tools fingerprint every file and directory a process reads, including directory listings, to decide when a build needs to rerun. With the default clean: true, tsdown globs the absolute outDir path from the project root, so the glob reads the root directory to find it. Every sibling of dist then looks like a build input, and adding or changing an unrelated file next to it invalidates the build.

When a clean entry is a literal path to outDir, this globs the contents of outDir directly. The same files are removed. Other patterns and configs with negated patterns still use the existing glob from cwd. The new test checks which directories are read for a default, nested and missing outDir, and that custom and negated patterns still work.

The second commit fixes a Windows bug the new negation test exposed: glob results use forward slashes but outDir has backslashes, so the output directory itself was removed, including files a negated pattern should keep.

The default clean pattern is the absolute outDir path, so the glob had to read the parent directory to match it. Tools that fingerprint directory reads then saw every sibling of the output directory as a build input. Glob the contents of outDir directly when a clean entry is exactly the output directory, and keep the combined glob for other and negated patterns.
@netlify

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit 46cacd5
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6abf63b955a8e20008dbc15e
😎 Deploy Preview https://deploy-preview-1092--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 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

tsdown

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

create-tsdown

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

@tsdown/css

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

@tsdown/exe

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

tsdown-migrate

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

commit: 46cacd5

On Windows the glob returns forward slashes and outDir has backslashes, so
the output directory itself was never skipped and got removed, along with
anything a negated pattern meant to keep.

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