63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
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: "node22",
|
|
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",
|
|
};
|
|
|
|
/** @type {import('esbuild').BuildOptions} */
|
|
const liveTurnOptions = {
|
|
entryPoints: ["src/liveTurn.ts"],
|
|
outfile: "out/liveTurn.mjs",
|
|
bundle: true,
|
|
platform: "node",
|
|
format: "esm",
|
|
target: "node22",
|
|
sourcemap: true,
|
|
external: ["vscode", "@cline/sdk"],
|
|
logLevel: "info",
|
|
};
|
|
|
|
/** @type {import('esbuild').BuildOptions} */
|
|
const previewMermaidOptions = {
|
|
entryPoints: ["media/preview-mermaid.ts"],
|
|
outfile: "out/media/preview-mermaid.js",
|
|
bundle: true,
|
|
// Task 7 (Q4): contributed via markdown.previewScripts into the BUILT-IN
|
|
// preview's webview (a browser context) — mermaid is bundled IN (and ONLY
|
|
// in) this asset so it never bloats the extension-host bundle (the
|
|
// @cline/sdk size discipline).
|
|
platform: "browser",
|
|
format: "iife",
|
|
target: "es2020",
|
|
sourcemap: true,
|
|
logLevel: "info",
|
|
};
|
|
|
|
if (watch) {
|
|
const ctx = await context(options);
|
|
const ctxLive = await context(liveTurnOptions);
|
|
const ctxPreviewMermaid = await context(previewMermaidOptions);
|
|
await Promise.all([ctx.watch(), ctxLive.watch(), ctxPreviewMermaid.watch()]);
|
|
console.log("esbuild: watching…");
|
|
} else {
|
|
await build(options);
|
|
await build(liveTurnOptions);
|
|
await build(previewMermaidOptions);
|
|
console.log(
|
|
"esbuild: build complete → out/extension.cjs + out/liveTurn.mjs + out/media/preview-mermaid.js",
|
|
);
|
|
}
|