Files
vscode-cowriting-plugin/esbuild.mjs
T
BenStullsBets 17fc01e8d8 feat: authorship + change annotations in the built-in Markdown preview (D3/D21, PUC-3); cowriting.annotations toggle
Task 7 of the native-surfaces migration plan. Pure previewAnnotations.ts
(annotateSource + cowritingMarkdownItPlugin) reuses trackChangesModel.ts's
sentinel discipline (#33/#47), generalized to a 3-way ins-claude/ins-human/del
tag (exported injectSentinels/sentinelsToSpans, colorByAuthor unaffected,
84/84 existing tests pass unmodified). Host hook in extension.ts wires
registry/diffView/attribution/proposals/config into the plugin, exposed via
CowritingApi.extendMarkdownIt + a previewAnnotationHost test seam.
cowriting.annotations setting + toggleAnnotations command/menu. Q4 mermaid
(previewScripts + options.highlight fence override) implemented per the
proven bierner.markdown-mermaid pattern; intra-diagram diff augmentation
scoped out (unverifiable via the structural E2E harness) — see
task-7-report.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 14:23:11 -07:00

79 lines
2.4 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 previewOptions = {
entryPoints: ["media/preview.ts"],
outfile: "out/media/preview.js",
bundle: true,
// The webview is 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). No externals — everything is shipped to the sealed webview.
platform: "browser",
format: "iife",
target: "es2020",
sourcemap: true,
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 — same browser/IIFE shape as previewOptions above, and
// the same reason mermaid is bundled here (never in the host bundle).
platform: "browser",
format: "iife",
target: "es2020",
sourcemap: true,
logLevel: "info",
};
if (watch) {
const ctx = await context(options);
const ctxLive = await context(liveTurnOptions);
const ctxPreview = await context(previewOptions);
const ctxPreviewMermaid = await context(previewMermaidOptions);
await Promise.all([ctx.watch(), ctxLive.watch(), ctxPreview.watch(), ctxPreviewMermaid.watch()]);
console.log("esbuild: watching…");
} else {
await build(options);
await build(liveTurnOptions);
await build(previewOptions);
await build(previewMermaidOptions);
console.log(
"esbuild: build complete → out/extension.cjs + out/liveTurn.mjs + out/media/preview.js + out/media/preview-mermaid.js",
);
}