|
|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
const { build } = require("esbuild");
|
|
|
|
|
const glob = require("tiny-glob");
|
|
|
|
|
const { promises: fs } = require("node:fs");
|
|
|
|
|
const { extname, resolve, relative } = require("node:path");
|
|
|
|
|
import * as esbuild from "esbuild";
|
|
|
|
|
import { default as glob } from "tiny-glob";
|
|
|
|
|
import { promises as fs } from "node:fs";
|
|
|
|
|
import { extname, resolve, relative, dirname } from "node:path";
|
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
|
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
|
|
|
const __dirname = dirname(__filename);
|
|
|
|
|
|
|
|
|
|
const watch = process.argv.at(-1) === "--watch";
|
|
|
|
|
|
|
|
|
|
@ -40,15 +44,24 @@ const handle_absolute_paths = (project_dir) => ({
|
|
|
|
|
let entryPoints = Object.fromEntries(
|
|
|
|
|
(await glob("./src/**/*.ts")).map((e) => [e.replace(/\.ts$/, ""), e])
|
|
|
|
|
);
|
|
|
|
|
build({
|
|
|
|
|
|
|
|
|
|
const buildOptions = {
|
|
|
|
|
entryPoints,
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
bundle: false,
|
|
|
|
|
outdir: "./lib",
|
|
|
|
|
logLevel: "info",
|
|
|
|
|
platform: "node",
|
|
|
|
|
watch,
|
|
|
|
|
target: "node16",
|
|
|
|
|
target: "es2022",
|
|
|
|
|
format: "esm",
|
|
|
|
|
plugins: [handle_absolute_paths(__dirname)],
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (watch) {
|
|
|
|
|
const context = await esbuild.context(buildOptions);
|
|
|
|
|
await context.watch();
|
|
|
|
|
} else {
|
|
|
|
|
await esbuild.build(buildOptions);
|
|
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
|