/
build-node.js
29 lines (29 loc) · 986 Bytes
/
build-node.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
require('esbuild').build({
entryPoints: ['./node_modules/typescript-vue-plugin/out/index.js'],
bundle: true,
outfile: './dist/index.js',
external: [
'vscode',
'typescript', // vue-component-meta
],
format: 'cjs',
platform: 'node',
tsconfig: '../../tsconfig.build.json',
minify: process.argv.includes('--minify'),
watch: process.argv.includes('--watch'),
plugins: [{
name: 'umd2esm',
setup(build) {
build.onResolve({ filter: /(vscode-.*|estree-walker|jsonc-parser)/ }, args => {
const pathUmdMay = require.resolve(args.path, { paths: [args.resolveDir] })
const pathEsm = pathUmdMay.replace('/umd/', '/esm/')
return { path: pathEsm }
})
build.onResolve({ filter: /\@vue\/compiler-sfc/ }, args => {
const pathUmdMay = require.resolve(args.path, { paths: [args.resolveDir] })
const pathEsm = pathUmdMay.replace('compiler-sfc.cjs.js', 'compiler-sfc.esm-browser.js')
return { path: pathEsm }
})
},
}],
}).catch(() => process.exit(1))