import { build } from "esbuild"; const sourcemap = process.env.SOURCEMAP === "true" || process.env.BUILD_SOURCEMAPS === "true"; const externalBarePackagesPlugin = { name: "external-bare-packages", setup(builder) { builder.onResolve({ filter: /^[^./]|^\.[^./]|^\.\.[^/]/ }, (args) => { if (args.path === "@toolctrl/queue/runtime" || args.path.startsWith("@toolctrl/queue/runtime/")) { return { path: args.path, external: true }; } if (args.path.startsWith("@toolctrl/")) { return undefined; } return { path: args.path, external: true }; }); }, }; await build({ entryPoints: ["src/index.ts", "src/health.ts", "src/jobs/plugin-sandbox-worker.ts"], outdir: "dist", bundle: true, platform: "node", format: "esm", target: "node20", sourcemap, banner: { js: 'import { createRequire as __toolctrlCreateRequire } from "node:module"; const require = __toolctrlCreateRequire(import.meta.url);', }, logLevel: "warning", plugins: [externalBarePackagesPlugin], });