philemonchiro_obsidian-note.../esbuild.config.mjs
Philemon Chiro f0e35d868f Add TypeScript source and esbuild build pipeline
main.ts is now the canonical source; main.js is the compiled artifact
committed alongside so manual installs work without a build step. Class
signatures and the public types (KeepCardsSettings, Filter, ParsedQuery,
ColorDef, BatchState) are explicitly typed; tsconfig is lenient on
implicit any and null checks to keep the diff against the hand-authored
JS minimal for this initial port. Subsequent passes can tighten the
types incrementally.

Build: npm install && npm run build (or npm run dev for watch mode).

Addresses the reviewer note in the obsidian-releases PR about needing
the .ts source committed for transparency.
2026-04-30 12:48:00 +02:00

40 lines
820 B
JavaScript

import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
const prod = process.argv[2] === "production";
const ctx = await esbuild.context({
entryPoints: ["main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins,
],
format: "cjs",
target: "es2020",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
minify: false,
});
if (prod) {
await ctx.rebuild();
process.exit(0);
} else {
await ctx.watch();
}