commit 0b5e5a2f6e0425f75a55666f2fb7fb8f704b53be
parent 49fba8aa1f47cae33526443d3798015ded6d517c
Author: Tim Rogers <timrogers@github.com>
Date: Wed, 25 Jan 2023 18:49:50 +0000
Upgrade esbuild to v0.17.x (#47)
Diffstat:
2 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/esbuild.config.mjs b/esbuild.config.mjs
@@ -1,6 +1,6 @@
import esbuild from "esbuild";
import process from "process";
-import builtins from 'builtin-modules'
+import builtins from "builtin-modules";
const banner =
`/*
@@ -9,34 +9,40 @@ if you want to view the source, please visit the github repository of this plugi
*/
`;
-const prod = (process.argv[2] === 'production');
+const prod = (process.argv[2] === "production");
-esbuild.build({
+const context = await esbuild.context({
banner: {
js: banner,
},
- entryPoints: ['main.ts'],
+ 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',
+ "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',
- watch: !prod,
- target: 'es2018',
+ format: "cjs",
+ target: "es2018",
logLevel: "info",
- sourcemap: prod ? false : 'inline',
+ sourcemap: prod ? false : "inline",
treeShaking: true,
- outfile: 'main.js',
-}).catch(() => process.exit(1));
+ outfile: "main.js",
+});
+
+if (prod) {
+ await context.rebuild();
+ process.exit(0);
+} else {
+ await context.watch();
+}
+\ No newline at end of file
diff --git a/package.json b/package.json
@@ -16,7 +16,7 @@
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
- "esbuild": "0.14.47",
+ "esbuild": "0.17.3",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"