-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.js
36 lines (26 loc) · 1.02 KB
/
build.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
const rollup = require('rollup');
const rollupOptions = require('./rollup.config.js');
/**
* format
amd – 异步模块定义,用于像RequireJS这样的模块加载器
cjs – CommonJS,适用于 Node 和 Browserify/Webpack
esm – 将软件包保存为 ES 模块文件,在现代浏览器中可以通过 <script type=module> 标签引入
iife – 一个自动执行的功能,适合作为<script>标签。(如果要为应用程序创建一个捆绑包,您可能想要使用它,因为它会使文件大小变小。)
umd – 通用模块定义,以amd,cjs 和 iife 为一体
system - SystemJS 加载器格式
*/
async function build(format = 'cjs') {
const bundle = await rollup.rollup(rollupOptions);
const outputOptions = Object.assign(rollupOptions.output, {
file: `./dist/jmchart.${format}.js`,
format
})
const { code, map } = await bundle.generate(rollupOptions.output);
await bundle.write(outputOptions);
}
build('cjs');
build('esm');
build('iife');
build('amd');
//build('umd');
build('system');