|
1 | 1 | const esbuild = require("esbuild"); |
2 | 2 |
|
3 | | -const production = process.argv.includes('--production'); |
4 | | -const watch = process.argv.includes('--watch'); |
| 3 | +const production = process.argv.includes("--production"); |
| 4 | +const watch = process.argv.includes("--watch"); |
5 | 5 |
|
6 | 6 | /** |
7 | 7 | * @type {import('esbuild').Plugin} |
8 | 8 | */ |
9 | 9 | const esbuildProblemMatcherPlugin = { |
10 | | - name: 'esbuild-problem-matcher', |
| 10 | + name: "esbuild-problem-matcher", |
11 | 11 |
|
12 | | - setup(build) { |
13 | | - build.onStart(() => { |
14 | | - console.log('[watch] build started'); |
15 | | - }); |
16 | | - build.onEnd((result) => { |
17 | | - result.errors.forEach(({ text, location }) => { |
18 | | - console.error(`✘ [ERROR] ${text}`); |
19 | | - console.error(` ${location.file}:${location.line}:${location.column}:`); |
20 | | - }); |
21 | | - console.log('[watch] build finished'); |
22 | | - }); |
23 | | - }, |
| 12 | + setup(build) { |
| 13 | + build.onStart(() => { |
| 14 | + console.log("[watch] build started"); |
| 15 | + }); |
| 16 | + build.onEnd((result) => { |
| 17 | + result.errors.forEach(({ text, location }) => { |
| 18 | + console.error(`✘ [ERROR] ${text}`); |
| 19 | + console.error( |
| 20 | + ` ${location.file}:${location.line}:${location.column}:`, |
| 21 | + ); |
| 22 | + }); |
| 23 | + console.log("[watch] build finished"); |
| 24 | + }); |
| 25 | + }, |
24 | 26 | }; |
25 | 27 |
|
26 | 28 | async function main() { |
27 | | - const ctx = await esbuild.context({ |
28 | | - entryPoints: [ |
29 | | - 'src/extension.ts' |
30 | | - ], |
31 | | - bundle: true, |
32 | | - format: 'cjs', |
33 | | - minify: production, |
34 | | - sourcemap: !production, |
35 | | - sourcesContent: false, |
36 | | - platform: 'node', |
37 | | - outfile: 'dist/extension.js', |
38 | | - external: ['vscode'], |
39 | | - logLevel: 'silent', |
40 | | - plugins: [ |
41 | | - /* add to the end of plugins array */ |
42 | | - esbuildProblemMatcherPlugin, |
43 | | - ], |
44 | | - }); |
45 | | - if (watch) { |
46 | | - await ctx.watch(); |
47 | | - } else { |
48 | | - await ctx.rebuild(); |
49 | | - await ctx.dispose(); |
50 | | - } |
| 29 | + const ctx = await esbuild.context({ |
| 30 | + entryPoints: ["src/extension.ts"], |
| 31 | + bundle: true, |
| 32 | + format: "cjs", |
| 33 | + minify: production, |
| 34 | + sourcemap: !production, |
| 35 | + sourcesContent: false, |
| 36 | + platform: "node", |
| 37 | + outfile: "dist/extension.js", |
| 38 | + external: ["vscode"], |
| 39 | + logLevel: "silent", |
| 40 | + plugins: [ |
| 41 | + /* add to the end of plugins array */ |
| 42 | + esbuildProblemMatcherPlugin, |
| 43 | + ], |
| 44 | + }); |
| 45 | + if (watch) { |
| 46 | + await ctx.watch(); |
| 47 | + } else { |
| 48 | + await ctx.rebuild(); |
| 49 | + await ctx.dispose(); |
| 50 | + } |
51 | 51 | } |
52 | 52 |
|
53 | | -main().catch(e => { |
54 | | - console.error(e); |
55 | | - process.exit(1); |
| 53 | +main().catch((e) => { |
| 54 | + console.error(e); |
| 55 | + process.exit(1); |
56 | 56 | }); |
0 commit comments