Skip to content

Commit ac15233

Browse files
TrySoundjquense
authored andcommitted
chore: bundle UMD with rollup (#449)
* Bundle UMD with rollup ```diff -Webpack production bundle is 18407b (no gzip) +Rollup production bundle is 14975b (no gzip) ``` * Fix lint * Compile to lib/dist * Build for production instead * Uncomment terser
1 parent e88f48a commit ac15233

File tree

6 files changed

+301
-1367
lines changed

6 files changed

+301
-1367
lines changed

.size-snapshot.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"./lib/dist/react-transition-group.js": {
3+
"bundled": 79410,
4+
"minified": 22589,
5+
"gzipped": 6905
6+
},
7+
"./lib/dist/react-transition-group.min.js": {
8+
"bundled": 46139,
9+
"minified": 14975,
10+
"gzipped": 4685
11+
}
12+
}

package.json

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"tdd": "jest --watch",
1010
"build": "babel src --out-dir lib --delete-dir-on-start && npm run build:dist && cp README.md LICENSE ./lib",
1111
"build:docs": "npm -C www run build",
12-
"build:dist": "webpack --mode production",
12+
"build:dist": "cross-env BABEL_ENV=esm yarn rollup -c",
1313
"bootstrap": "yarn && yarn --cwd www",
1414
"lint": "eslint src test",
1515
"release": "release",
@@ -21,13 +21,6 @@
2121
"travis-deploy-once": "travis-deploy-once",
2222
"semantic-release": "semantic-release"
2323
},
24-
"size-limit": [
25-
{
26-
"gzip": false,
27-
"path": "lib/index.js",
28-
"limit": "16.66 KB"
29-
}
30-
],
3124
"repository": {
3225
"type": "git",
3326
"url": "https://github.com/reactjs/react-transition-group.git"
@@ -81,6 +74,7 @@
8174
"babel-loader": "^8.0.2",
8275
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
8376
"babel-preset-jason": "^6.0.1",
77+
"cross-env": "^5.2.0",
8478
"enzyme": "^3.6.0",
8579
"enzyme-adapter-react-16": "^1.5.0",
8680
"eslint": "^5.6.0",
@@ -98,14 +92,17 @@
9892
"react-test-renderer": "^16.5.2",
9993
"release-script": "^1.0.2",
10094
"rimraf": "^2.6.1",
95+
"rollup": "^1.1.0",
96+
"rollup-plugin-babel": "^4.3.0",
97+
"rollup-plugin-commonjs": "^9.2.0",
98+
"rollup-plugin-node-resolve": "^4.0.0",
99+
"rollup-plugin-replace": "^2.1.0",
100+
"rollup-plugin-size-snapshot": "^0.8.0",
101+
"rollup-plugin-terser": "^4.0.2",
101102
"semantic-release": "^15.9.16",
102103
"semantic-release-alt-publish-dir": "^2.1.1",
103104
"sinon": "^6.3.4",
104-
"size-limit": "^0.21.1",
105-
"travis-deploy-once": "^5.0.8",
106-
"webpack": "^4.19.1",
107-
"webpack-atoms": "^8.0.0",
108-
"webpack-cli": "^3.1.1"
105+
"travis-deploy-once": "^5.0.8"
109106
},
110107
"release": {
111108
"pkgRoot": "lib",

rollup.config.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import nodeResolve from "rollup-plugin-node-resolve";
2+
import babel from "rollup-plugin-babel";
3+
import commonjs from "rollup-plugin-commonjs";
4+
import replace from "rollup-plugin-replace";
5+
import { sizeSnapshot } from "rollup-plugin-size-snapshot";
6+
import { terser } from "rollup-plugin-terser";
7+
8+
const input = "./src/umd.js";
9+
const name = "ReactTransitionGroup";
10+
const globals = {
11+
react: "React",
12+
"react-dom": "ReactDOM"
13+
};
14+
15+
const babelOptions = {
16+
exclude: /node_modules/,
17+
runtimeHelpers: true
18+
}
19+
20+
const commonjsOptions = {
21+
include: /node_modules/,
22+
namedExports: {
23+
"prop-types": ["object", "oneOfType", "element", "bool", "func"]
24+
}
25+
};
26+
27+
export default [
28+
{
29+
input,
30+
output: {
31+
file: "./lib/dist/react-transition-group.js",
32+
format: "umd",
33+
name,
34+
globals
35+
},
36+
external: Object.keys(globals),
37+
plugins: [
38+
nodeResolve(),
39+
babel(babelOptions),
40+
commonjs(commonjsOptions),
41+
replace({ "process.env.NODE_ENV": JSON.stringify("development") }),
42+
sizeSnapshot()
43+
]
44+
},
45+
46+
{
47+
input,
48+
output: {
49+
file: "./lib/dist/react-transition-group.min.js",
50+
format: "umd",
51+
name,
52+
globals
53+
},
54+
external: Object.keys(globals),
55+
plugins: [
56+
nodeResolve(),
57+
babel(babelOptions),
58+
commonjs(commonjsOptions),
59+
replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
60+
sizeSnapshot(),
61+
terser()
62+
]
63+
}
64+
];

src/umd.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { default as CSSTransition } from './CSSTransition';
2+
export { default as ReplaceTransition } from './ReplaceTransition';
3+
export { default as TransitionGroup } from './TransitionGroup';
4+
export { default as Transition } from './Transition';

webpack.config.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)