0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix an issue where astro build writes type declaration files to outDir (#10861)

* Fix an issue where `astro build` also writes type declaration files to `outDir`

* Add changeset
This commit is contained in:
Ming-jun Lu 2024-04-24 19:01:51 +08:00 committed by GitHub
parent a94046588c
commit b673bc8505
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Fixes an issue where `astro build` writes type declaration files to `outDir` when it's outside of root directory.

View file

@ -442,6 +442,13 @@ async function cleanServerOutput(
// Clean out directly if the outDir is outside of root
if (out.toString() !== opts.settings.config.outDir.toString()) {
// Remove .d.ts files
const fileNames = await fs.promises.readdir(out);
await Promise.all(
fileNames
.filter((fileName) => fileName.endsWith('.d.ts'))
.map((fileName) => fs.promises.rm(new URL(fileName, out)))
);
// Copy assets before cleaning directory if outside root
await copyFiles(out, opts.settings.config.outDir, true);
await fs.promises.rm(out, { recursive: true });