Skip to content

Commit 543cafd

Browse files
committed
feat: added rollup bundler
Added rollup bundler to build CommonJS and ES modules
1 parent 605f869 commit 543cafd

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

saofile.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ module.exports = {
4444
contributors: [],
4545
repository: "",
4646
license: "MIT",
47-
scripts: [
48-
{ build: "rm -rf ./lib/** && tsx" },
49-
{ watch: "tsc -- --watch" }
50-
],
47+
scripts: [{ build: "rollup -c" }, { watch: "rollup -cw" }],
5148
dependencies: [],
5249
devDependencies: [
5350
{ "@babel/cli": "^7.2.3" },
@@ -67,7 +64,14 @@ module.exports = {
6764
{ "tslint-react": "^3.6.0" },
6865
{ typescript: "^3.3.3333" },
6966
{ react: "*" },
70-
{ "react-dom": "*" }
67+
{ "react-dom": "*" },
68+
{ rollup: "^1.27.5" },
69+
{ "rollup-plugin-babel-minify": "^9.1.1" },
70+
{ "rollup-plugin-cleanup": "^3.1.1" },
71+
{ "rollup-plugin-commonjs": "^10.1.0" },
72+
{ "rollup-plugin-delete": "^1.1.0" },
73+
{ "rollup-plugin-progress": "^1.1.1" },
74+
{ "rollup-plugin-typescript2": "^0.25.2" }
7175
],
7276
peerDependencies: [{ react: "*" }, { "react-dom": "*" }]
7377
};
@@ -184,6 +188,7 @@ module.exports = {
184188
babelrc: ".babelrc",
185189
travis_yml: ".travis.yml",
186190
jest_config_js: "jest.config.js",
191+
rollup_config_js: "rollup.config.js",
187192
releaserc: ".releaserc",
188193
_package_json: "package.json",
189194
_tsconfig_json: "tsconfig.json",

templates/rollup_config_js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import typescript from "rollup-plugin-typescript2";
2+
import commonjs from "rollup-plugin-commonjs";
3+
import progress from "rollup-plugin-progress";
4+
import minify from "rollup-plugin-babel-minify";
5+
import cleanup from "rollup-plugin-cleanup";
6+
import del from "rollup-plugin-delete";
7+
import pkg from "./package.json";
8+
9+
export default {
10+
input: "./src/index.tsx",
11+
output: [
12+
{
13+
file: pkg.main,
14+
format: "cjs"
15+
},
16+
{
17+
file: pkg.module,
18+
format: "es"
19+
}
20+
],
21+
plugins: [
22+
progress({ clearLine: false }),
23+
del({
24+
targets: ["lib/*"]
25+
}),
26+
commonjs({
27+
namedExports: {}
28+
}),
29+
typescript(),
30+
minify(),
31+
cleanup()
32+
],
33+
external: [
34+
...Object.keys(pkg.dependencies || {}),
35+
...Object.keys(pkg.peerDependencies || {})
36+
]
37+
};

0 commit comments

Comments
 (0)