From 0e3335e1a9091c70dfb67747f880b32afcf63dfd Mon Sep 17 00:00:00 2001 From: Shmavon Gazanchyan Date: Sat, 15 Jun 2024 21:33:38 +0100 Subject: [PATCH] Fix esbuild configuration for watch mode --- esbuild.config.mjs | 76 ++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 84351f1..bf35c1b 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -3,43 +3,45 @@ import process from "process"; import builtins from 'builtin-modules' const prod = (process.argv[2] === 'production'); - -let ctx = await esbuild.context({ - entryPoints: ['src/main.ts'], - bundle: true, - external: [ - 'obsidian', - 'electron', - '@codemirror/autocomplete', - '@codemirror/closebrackets', - '@codemirror/collab', - '@codemirror/commands', - '@codemirror/comment', - '@codemirror/fold', - '@codemirror/gutter', - '@codemirror/highlight', - '@codemirror/history', - '@codemirror/language', - '@codemirror/lint', - '@codemirror/matchbrackets', - '@codemirror/panel', - '@codemirror/rangeset', - '@codemirror/rectangular-selection', - '@codemirror/search', - '@codemirror/state', - '@codemirror/stream-parser', - '@codemirror/text', - '@codemirror/tooltip', - '@codemirror/view', - ...builtins], - format: 'cjs', - target: 'es2016', - logLevel: "info", - sourcemap: prod ? false : 'inline', - treeShaking: true, - outfile: 'main.js', -}).catch(() => process.exit(1)); +const args = { + entryPoints: ['src/main.ts'], + bundle: true, + external: [ + 'obsidian', + 'electron', + '@codemirror/autocomplete', + '@codemirror/closebrackets', + '@codemirror/collab', + '@codemirror/commands', + '@codemirror/comment', + '@codemirror/fold', + '@codemirror/gutter', + '@codemirror/highlight', + '@codemirror/history', + '@codemirror/language', + '@codemirror/lint', + '@codemirror/matchbrackets', + '@codemirror/panel', + '@codemirror/rangeset', + '@codemirror/rectangular-selection', + '@codemirror/search', + '@codemirror/state', + '@codemirror/stream-parser', + '@codemirror/text', + '@codemirror/tooltip', + '@codemirror/view', + ...builtins], + format: 'cjs', + target: 'es2016', + logLevel: "info", + sourcemap: false, + treeShaking: true, + outfile: 'main.js', +} if (!prod) { - await ctx.watch() + args.sourcemap = 'inline'; + await (await esbuild.context(args)).watch() +} else { + await esbuild.build(args); }