- rollup
- @rollup/plugin-node-resolve:解析第三方库依赖(即 node_module 内的依赖)
- @rollup/plugin-commonjs:识别 commonjs 格式依赖
- rollup-plugin-typescript2: Rollup 支持ts编译
- @rollup/plugin-babel:rollup babel 插件
- @rollup/plugin-terser:(可选)代码压缩
npm i @rollup/plugin-node-resolve @rollup/plugin-commonjs @rollup/plugin-terser --save-dev
- 安装 babel
npm i @rollup/plugin-babel @babel/preset-env @babel/plugin-transform-runtime --save-dev
- 安装 typescript
npm i typescript rollup-plugin-typescript2
-
编译 rollup.config.js
-
编译 tsconfig.json 及类型编译配置 tsconfig.types.json
-
编译 .babel.config.js
-
package.json
-
"main": "./dist/index.js" : rollup.config.js 使用,commonjs 模式打包文件
-
"module": “./dist/index.esm.js": rollup.config.js 使用,es module 模式打包文件
-
"umd": "./dist/index.umd.js": rollup.config.js 使用,umd 模式打包文件
-
"types": "./dist/types/index.d.ts" : 类型声明文件入口
-
"script"
- "dev": "rollup --config rollup.config.js --watch",
- "build": "npm run build:types && rollup --config rollup.config.js",
- "build:types": "npm run clean:dist && tsc -b ./tsconfig.types.json",
- "clean:dist": "rimraf dist",