use esbuild for watch

This commit is contained in:
nin0 2025-05-16 06:20:36 -04:00
parent dcd22a9d8c
commit 740b5581e0
Signed by: nin0
SSH key fingerprint: SHA256:NOoDnFVvZNFvqfXCIhzr6oCTDImZAbTTuyAysZ8Ufk8
5 changed files with 23 additions and 375 deletions

View file

@ -1,4 +1,5 @@
import { build } from "esbuild";
import { spawn } from "child_process";
/**
* @type {esbuild.Plugin}
@ -6,7 +7,7 @@ import { build } from "esbuild";
const makeAllPackagesExternalPlugin = {
name: "make-all-packages-external",
setup(build) {
const filter = /^[^./|~]|^\.[^./]|^\.\.[^/]/; // Must not start with "/" or "./" or "../"
const filter = /(oceanic\.js|sqlite3)/; // Whitelist of dumb packages
build.onResolve({ filter }, (args) => ({
path: args.path,
external: true
@ -29,3 +30,12 @@ await build({
jsxFactory: "createElement",
jsxFragment: "Fragment"
});
setInterval(() => {}, 100);
if (process.argv.includes("start")) {
const proc = spawn("node", ["--env-file=.env", "dist/index.js"], {
stdio: "inherit"
});
proc.on("close", (code) => process.exit(code));
}