Skip to content

Commit

Permalink
Fix an issue where astro build writes type declaration files to `ou…
Browse files Browse the repository at this point in the history
…tDir` (#10861)

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

* Add changeset
  • Loading branch information
mingjunlu committed Apr 24, 2024
1 parent a940465 commit b673bc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-humans-judge.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit b673bc8

Please sign in to comment.