dotwee_obsidian-raindropio-.../esbuild.config.mjs
Lukas Wolfsteiner c22dc1f969 build: modernize TypeScript and esbuild configuration
Set compile and bundle target to ES2021 since Obsidian runs on modern Electron.
Replace individual strict flags with strict: true and add noFallthroughCasesInSwitch, skipLibCheck and forceConsistentCasingInFileNames.
Switch module resolution to bundler, removing the need for deprecation workarounds on TypeScript 6.
Drop baseUrl, allowJs and importHelpers; tests now import sources via relative paths.
Aligns the project with the modernized obsidian-sample-plugin configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 11:20:56 +02:00

49 lines
985 B
JavaScript

import esbuild from "esbuild";
import process from "process";
import { builtinModules } from 'node:module';
const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
const prod = (process.argv[2] === "production");
const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/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",
...builtinModules],
format: "cjs",
target: "es2021",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
minify: prod,
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}