Skip to content

Commit 7aebbce

Browse files
committed
dont reset build folder by default
1 parent c0a1f87 commit 7aebbce

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

build.ts

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { Glob, fileURLToPath, pathToFileURL } from "bun";
2-
import { unlink } from "node:fs/promises";
32
import { basename, join, relative } from "node:path";
43

54
function escapeRegExp(string: string) {
65
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
76
}
87

9-
function glob(
10-
path: string,
11-
pattern = "**/*.{ts,tsx,js,jsx}"
12-
): AsyncIterableIterator<string> {
13-
const glob = new Glob(pattern);
14-
return glob.scan({ cwd: path, onlyFiles: true, absolute: true });
15-
}
16-
178
export async function build({
189
baseDir,
1910
buildDir = ".build",
@@ -35,7 +26,12 @@ export async function build({
3526
}) {
3627
const entrypoints = [join(baseDir, hydrate)];
3728
const absPageDir = join(baseDir, pageDir);
38-
for await (const path of glob(absPageDir)) {
29+
const entrypointGlob = new Glob("**/*.{ts,tsx,js,jsx}");
30+
for await (const path of entrypointGlob.scan({
31+
cwd: absPageDir,
32+
onlyFiles: true,
33+
absolute: true,
34+
})) {
3935
entrypoints.push(path);
4036
}
4137
const outdir = join(baseDir, buildDir);
@@ -95,11 +91,6 @@ export async function build({
9591
],
9692
});
9793
if (result.success) {
98-
for await (const path of glob(join(baseDir, buildDir))) {
99-
if (result.outputs.every((x) => x.path !== path)) {
100-
await unlink(path);
101-
}
102-
}
10394
const hashed: Record<string, string> = {};
10495
for (const output of result.outputs) {
10596
if (output.kind === "entry-point" && output.hash) {

0 commit comments

Comments
 (0)