import { build, context } from "esbuild"; const watch = process.argv.includes("--watch"); /** @type {import('esbuild').BuildOptions} */ const options = { entryPoints: ["src/extension.ts"], outfile: "out/extension.cjs", bundle: true, platform: "node", format: "cjs", target: "node20", sourcemap: true, // vscode is provided by the host; @cline/sdk is ESM-only and is loaded at // runtime via dynamic import() from node_modules, so keep both external. external: ["vscode", "@cline/sdk"], logLevel: "info", }; if (watch) { const ctx = await context(options); await ctx.watch(); console.log("esbuild: watching…"); } else { await build(options); console.log("esbuild: build complete → out/extension.cjs"); }