# HG changeset patch # User Ludovic Chabant # Date 1696265453 25200 # Node ID bdaa6e2c18d6100ca9e60aa49805977136a91e42 # Parent 8e8019698f1632c143d1280462428b86d3da981d Update build script to newest esbuild APIs. diff -r 8e8019698f16 -r bdaa6e2c18d6 esbuild.config.mjs --- a/esbuild.config.mjs Wed Sep 20 23:31:06 2023 -0700 +++ b/esbuild.config.mjs Mon Oct 02 09:50:53 2023 -0700 @@ -5,10 +5,11 @@ const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD -if you want to view the source, please visit one of the following: -https://hg.bolt80.com/obsidian-remember-file-state -https://hg.sr.ht/~ludovicchabant/obsidian-remember-file-state -https://github.com/ludovicchabant/obsidian-remember-file-state + +If you want to view the source, please visit one of the following: +- https://hg.bolt80.com/obsidian-remember-file-state +- https://hg.sr.ht/~ludovicchabant/obsidian-remember-file-state +- https://github.com/ludovicchabant/obsidian-remember-file-state */ `; @@ -26,7 +27,7 @@ const outfile = outdir + 'main.js'; -esbuild.build({ +const context = await esbuild.context({ banner: { js: banner, }, @@ -58,10 +59,17 @@ '@codemirror/view', ...builtins], format: 'cjs', - watch: !prod, - target: 'es2016', + target: 'es2018', logLevel: "info", sourcemap: prod ? false : 'inline', treeShaking: true, outfile: outfile, -}).catch(() => process.exit(1)); +}); + +if (prod) { + await context.rebuild(); + process.exit(0); +} else { + await context.watch(); +} +