Add `_dist.ts`

For help with releases
main
idylls 2 years ago
parent ffb617d4ff
commit dd9a2f4283
Signed by: idylls
GPG Key ID: 8A7167CBC2CC9F0F

1
.gitignore vendored

@ -1,2 +1,3 @@
build/*
dist/*
config.json

@ -1,12 +1,14 @@
import { fs, emit } from "./build_deps.ts";
import { bundle } from "./build_deps/emit.ts";
import { ensureDir } from "./build_deps/fs.ts";
export const build = async (sourceMap = false) => {
const bundle = await emit.bundle("frontend/main.ts", {
const b = await bundle("frontend/main.ts", {
compilerOptions: {
inlineSourceMap: sourceMap,
},
});
await fs.ensureDir("./build");
await Deno.writeTextFile("./build/frontend.ts", `export const frontend = ${JSON.stringify(bundle.code)};`);
await ensureDir("./build");
await Deno.writeTextFile("./build/frontend.ts", `export const frontend = ${JSON.stringify(b.code)};`);
await Deno.writeTextFile("./build/style.ts", `export const style = ${JSON.stringify(await Deno.readTextFile("frontend/style.css"))}`)
};

@ -1,4 +1,4 @@
import { build } from "./build.ts";
import { build } from "./_build.ts";
await build(true);
await Deno.run({

@ -0,0 +1,35 @@
/// <reference lib="deno.unstable" />
import { bundle } from "./build_deps/emit.ts";
import { ensureDir } from "./build_deps/fs.ts";
import { build } from "./_build.ts";
export const dist = async () => {
await build(true);
await ensureDir("./dist");
const b = bundle("backend/main.ts", {
compilerOptions: {
inlineSourceMap: true,
},
});
const exe = Deno.run({ cmd: [
"deno",
"compile",
"--output",
"dist/statue",
"backend/main.ts",
], });
const [b_, exe_] = await Promise.all([b, exe.status()]);
if (!exe_.success) {
console.error("Failed to build executable");
throw new Error(`${exe_.code}`);
}
await Deno.writeTextFile("dist/statue.js", b_.code);
};
if (import.meta.main) {
await dist();
}

@ -1,2 +0,0 @@
export * as fs from "https://deno.land/std@0.149.0/fs/mod.ts";
export * as emit from "https://deno.land/x/emit@0.4.0/mod.ts";

@ -0,0 +1 @@
export * from "https://deno.land/x/emit@0.4.0/mod.ts";

@ -0,0 +1 @@
export * from "https://deno.land/std@0.149.0/fs/mod.ts";
Loading…
Cancel
Save