Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--experimental-dts not working well with --clean flag #1040

Closed
0x-jerry opened this issue Nov 20, 2023 · 1 comment · Fixed by #1041
Closed

--experimental-dts not working well with --clean flag #1040

0x-jerry opened this issue Nov 20, 2023 · 1 comment · Fixed by #1041

Comments

@0x-jerry
Copy link

Reproduce: https://stackblitz.com/edit/vitejs-vite-q3cget?file=package.json

When run pnpm run build (tsup src/main.ts --experimental-dts main --format esm), it works well. The generate result is:
image

But when run pnpm run build-with-clean (tsup src/main.ts --experimental-dts main --format esm --clean), it will not generate dts files. The generate result is:
image

@0x-jerry
Copy link
Author

0x-jerry commented Nov 20, 2023

I have took a look at the source code, it seems the dts task executed before main task, but the main task only checked dts option.

tsup/src/index.ts

Lines 294 to 306 in d8a203c

if (options.clean) {
const extraPatterns = Array.isArray(options.clean)
? options.clean
: []
// .d.ts files are removed in the `dtsTask` instead
// `dtsTask` is a separate process, which might start before `mainTasks`
if (options.dts) {
extraPatterns.unshift('!**/*.d.{ts,cts,mts}')
}
await removeFiles(['**/*', ...extraPatterns], options.outDir)
logger.info('CLI', 'Cleaning output folder')
}

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 a pull request may close this issue.

1 participant