// Builds the vendored CodeMirror 6 bundle consumed by the page editor.
//
// Output is an IIFE that assigns the CM primitives the editor scripts need
// onto window.CM (see entry.js). The editor JS is loaded as plain global
// scripts, not ES modules, so there is no runtime module loader.
//
// Run via `make editor` (or `npm run build` here) after changing CM versions.
// The committed artifact at assets/editor/vendor/codemirror.bundle.js is the
// only thing `go build` ever sees.
import * as esbuild from "esbuild";

await esbuild.build({
    entryPoints: ["entry.js"],
    bundle: true,
    format: "iife",
    minify: true,
    target: ["es2018"],
    legalComments: "none",
    outfile: "../assets/editor/vendor/codemirror.bundle.js",
});

console.log("built assets/editor/vendor/codemirror.bundle.js");
