import esbuild from 'esbuild'; import process from 'process'; import fs from 'fs'; import builtins from 'builtin-modules'; const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD */ `; const prod = process.argv[2] === 'production'; const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); const manifest = JSON.parse(fs.readFileSync('./manifest.json', 'utf8')); manifest.version = pkg.version; fs.writeFileSync('./manifest.json', JSON.stringify(manifest, null, '\t') + '\n'); esbuild .build({ 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', ...builtins, ], format: 'cjs', target: 'es2018', logLevel: 'info', sourcemap: prod ? false : 'inline', treeShaking: true, outfile: 'main.js', }) .catch(() => process.exit(1));