forked from gitkraken/vscode-gitlens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
73 lines (66 loc) · 1.97 KB
/
esbuild.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const esbuild = require('esbuild');
const path = require('path');
const args = process.argv.slice(2);
let index = args.indexOf('--mode');
const mode = (index >= 0 ? args[index + 1] : undefined) || 'none';
index = args.indexOf('--target');
const target = (index >= 0 ? args[index + 1] : undefined) || 'node';
const watch = args.includes('--watch');
const check = !args.includes('--no-check');
let plugins = [];
let TypeCheckerPlugin;
if (check) {
({ EsbuildPlugin: TypeCheckerPlugin } = require('vite-esbuild-typescript-checker'));
plugins.push(
TypeCheckerPlugin({
checker: {
async: false,
eslint: {
enabled: true,
files: 'src/**/*.ts',
options: {
// cache: true,
cacheLocation: path.join(
__dirname,
target === 'webworker' ? '.eslintcache.browser' : '.eslintcache',
),
overrideConfigFile: path.join(
__dirname,
target === 'webworker' ? '.eslintrc.browser.json' : '.eslintrc.json',
),
},
},
formatter: 'basic',
typescript: {
configFile: target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.json',
},
},
}),
);
}
esbuild
.build({
bundle: true,
entryPoints: ['src/extension.ts'],
entryNames: '[dir]/gitlens',
external:
target === 'webworker'
? ['vscode', 'child_process', 'crypto', 'fs', 'stream', 'os', 'src/env/node/*']
: ['vscode', 'src/env/browser/*'],
format: 'cjs',
keepNames: true,
logLevel: 'info',
mainFields: target === 'webworker' ? ['browser', 'module', 'main'] : ['module', 'main'],
minify: mode === 'production' ? true : false,
outdir: target === 'webworker' ? 'dist/browser' : 'dist',
// outfile: 'dist/gitlens.js',
platform: target === 'webworker' ? 'browser' : target,
sourcemap: true,
// splitting: true,
target: ['es2020', 'chrome91', 'node14.16'],
treeShaking: true,
tsconfig: target === 'webworker' ? 'tsconfig.browser.json' : 'tsconfig.json',
watch: watch,
plugins: plugins,
})
.catch(() => process.exit(1));