Skip to content

Commit 263edf3

Browse files
committed
improve bundle script
1 parent 1091e9b commit 263edf3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

bundle.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ const DESTINATION = "./main.js";
66

77
const url = new URL(SOURCE, import.meta.url);
88

9-
if (Deno.args[0] === "build") {
10-
const result = await emit.bundle(url, { minify: true });
9+
async function build(options: emit.BundleOptions): Promise<void> {
10+
const result = await emit.bundle(url, options);
1111
const { code } = result;
1212
await Deno.writeTextFile(DESTINATION, code);
13+
}
14+
if (Deno.args[0] === "build") {
15+
await build({ minify: true });
1316
} else if (Deno.args[0] === "watch") {
1417
const builder = debounce.debounce(async () => {
1518
console.log("Starting to build...");
16-
const result = await emit.bundle(url, {
17-
compilerOptions: { inlineSourceMap: true },
18-
});
19-
const { code } = result;
20-
await Deno.writeTextFile(DESTINATION, code);
19+
await build({ compilerOptions: { inlineSourceMap: true } });
2120
console.log("Building done!");
2221
}, 500);
2322
const watcher = Deno.watchFs("./src/");

0 commit comments

Comments
 (0)