|
| 1 | +import builtins from 'builtin-modules'; |
| 2 | +import esbuild from 'esbuild'; |
| 3 | +import esbuildSvelte from 'esbuild-svelte'; |
| 4 | +import sveltePreprocess from 'svelte-preprocess'; |
| 5 | +import { getBuildBanner } from 'build/buildBanner'; |
| 6 | + |
| 7 | +// currently this segfaults for me, but i want to consider using bun for the build system in the future |
| 8 | +// https://github.com/oven-sh/bun/issues/12456 |
| 9 | + |
| 10 | +const banner = getBuildBanner('Release Build', version => version); |
| 11 | + |
| 12 | +const build = await Bun.build({ |
| 13 | + banner: { |
| 14 | + js: banner, |
| 15 | + }, |
| 16 | + entryPoints: ['packages/obsidian/src/main.ts'], |
| 17 | + bundle: true, |
| 18 | + external: [ |
| 19 | + 'obsidian', |
| 20 | + 'electron', |
| 21 | + '@codemirror/autocomplete', |
| 22 | + '@codemirror/collab', |
| 23 | + '@codemirror/commands', |
| 24 | + '@codemirror/language', |
| 25 | + '@codemirror/lint', |
| 26 | + '@codemirror/search', |
| 27 | + '@codemirror/state', |
| 28 | + '@codemirror/view', |
| 29 | + '@lezer/common', |
| 30 | + '@lezer/highlight', |
| 31 | + '@lezer/lr', |
| 32 | + ...builtins, |
| 33 | + ], |
| 34 | + format: 'esm', |
| 35 | + target: 'browser', |
| 36 | + logLevel: 'info', |
| 37 | + sourcemap: 'none', |
| 38 | + treeShaking: true, |
| 39 | + outfile: 'main.js', |
| 40 | + minify: true, |
| 41 | + metafile: true, |
| 42 | + define: { |
| 43 | + MB_GLOBAL_CONFIG_DEV_BUILD: 'false', |
| 44 | + }, |
| 45 | + plugins: [ |
| 46 | + // @ts-ignore |
| 47 | + esbuildSvelte({ |
| 48 | + compilerOptions: { css: 'injected', dev: false }, |
| 49 | + preprocess: sveltePreprocess(), |
| 50 | + filterWarnings: warning => { |
| 51 | + // we don't want warnings from node modules that we can do nothing about |
| 52 | + return !warning.filename?.includes('node_modules'); |
| 53 | + }, |
| 54 | + }), |
| 55 | + ], |
| 56 | +}); |
| 57 | + |
| 58 | +// const file = Bun.file('meta.txt'); |
| 59 | +// await Bun.write(file, JSON.stringify(build.metafile, null, '\t')); |
| 60 | + |
| 61 | +// process.exit(0); |
0 commit comments