forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-cli.js
More file actions
56 lines (53 loc) · 1.38 KB
/
build-cli.js
File metadata and controls
56 lines (53 loc) · 1.38 KB
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
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-require-imports */
const esbuild = require('esbuild');
const ignorePlugin = require('esbuild-plugin-ignore');
// 执行脚本
(async () => {
try {
console.log('building...');
const result = await esbuild.build({
entryPoints: ['src/cli/index.ts'],
outfile: 'dist/cli.js',
bundle: true,
platform: 'node',
target: ['node10'],
format: 'cjs',
sourcemap: true,
sourcesContent: true,
plugins: [
ignorePlugin([
// @alilc/lowcode-types 中误依赖了 react,这里忽略下
{
resourceRegExp: /^react$/,
contextRegExp: /./,
},
{
resourceRegExp: /setter-config/,
contextRegExp: /lowcode-types/,
},
]),
],
define: {},
treeShaking: true,
minify: false,
minifyWhitespace: false,
minifyIdentifiers: false,
minifySyntax: false,
legalComments: 'external',
external: Object.keys(require('../package.json').dependencies),
});
if (result.errors.length > 0) {
throw result.errors;
}
if (result.warnings.length > 0) {
result.warnings.forEach((warnings) => {
console.warn(warnings);
});
}
console.log('done');
} catch (e) {
console.error(e);
process.exit(1);
}
})();