Skip to content

Commit

Permalink
chore: bundle UMD with rollup (#449)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
TrySound authored and jquense committed Feb 13, 2019
1 parent e88f48a commit ac15233
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 1,367 deletions.
12 changes: 12 additions & 0 deletions .size-snapshot.json
@@ -0,0 +1,12 @@
{
"./lib/dist/react-transition-group.js": {
"bundled": 79410,
"minified": 22589,
"gzipped": 6905
},
"./lib/dist/react-transition-group.min.js": {
"bundled": 46139,
"minified": 14975,
"gzipped": 4685
}
}
23 changes: 10 additions & 13 deletions package.json
Expand Up @@ -9,7 +9,7 @@
"tdd": "jest --watch",
"build": "babel src --out-dir lib --delete-dir-on-start && npm run build:dist && cp README.md LICENSE ./lib",
"build:docs": "npm -C www run build",
"build:dist": "webpack --mode production",
"build:dist": "cross-env BABEL_ENV=esm yarn rollup -c",
"bootstrap": "yarn && yarn --cwd www",
"lint": "eslint src test",
"release": "release",
Expand All @@ -21,13 +21,6 @@
"travis-deploy-once": "travis-deploy-once",
"semantic-release": "semantic-release"
},
"size-limit": [
{
"gzip": false,
"path": "lib/index.js",
"limit": "16.66 KB"
}
],
"repository": {
"type": "git",
"url": "https://github.com/reactjs/react-transition-group.git"
Expand Down Expand Up @@ -81,6 +74,7 @@
"babel-loader": "^8.0.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
"babel-preset-jason": "^6.0.1",
"cross-env": "^5.2.0",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"eslint": "^5.6.0",
Expand All @@ -98,14 +92,17 @@
"react-test-renderer": "^16.5.2",
"release-script": "^1.0.2",
"rimraf": "^2.6.1",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.3.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-size-snapshot": "^0.8.0",
"rollup-plugin-terser": "^4.0.2",
"semantic-release": "^15.9.16",
"semantic-release-alt-publish-dir": "^2.1.1",
"sinon": "^6.3.4",
"size-limit": "^0.21.1",
"travis-deploy-once": "^5.0.8",
"webpack": "^4.19.1",
"webpack-atoms": "^8.0.0",
"webpack-cli": "^3.1.1"
"travis-deploy-once": "^5.0.8"
},
"release": {
"pkgRoot": "lib",
Expand Down
64 changes: 64 additions & 0 deletions rollup.config.js
@@ -0,0 +1,64 @@
import nodeResolve from "rollup-plugin-node-resolve";
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
import replace from "rollup-plugin-replace";
import { sizeSnapshot } from "rollup-plugin-size-snapshot";
import { terser } from "rollup-plugin-terser";

const input = "./src/umd.js";
const name = "ReactTransitionGroup";
const globals = {
react: "React",
"react-dom": "ReactDOM"
};

const babelOptions = {
exclude: /node_modules/,
runtimeHelpers: true
}

const commonjsOptions = {
include: /node_modules/,
namedExports: {
"prop-types": ["object", "oneOfType", "element", "bool", "func"]
}
};

export default [
{
input,
output: {
file: "./lib/dist/react-transition-group.js",
format: "umd",
name,
globals
},
external: Object.keys(globals),
plugins: [
nodeResolve(),
babel(babelOptions),
commonjs(commonjsOptions),
replace({ "process.env.NODE_ENV": JSON.stringify("development") }),
sizeSnapshot()
]
},

{
input,
output: {
file: "./lib/dist/react-transition-group.min.js",
format: "umd",
name,
globals
},
external: Object.keys(globals),
plugins: [
nodeResolve(),
babel(babelOptions),
commonjs(commonjsOptions),
replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
sizeSnapshot(),
terser()
]
}
];
4 changes: 4 additions & 0 deletions src/umd.js
@@ -0,0 +1,4 @@
export { default as CSSTransition } from './CSSTransition';
export { default as ReplaceTransition } from './ReplaceTransition';
export { default as TransitionGroup } from './TransitionGroup';
export { default as Transition } from './Transition';
35 changes: 0 additions & 35 deletions webpack.config.js

This file was deleted.

0 comments on commit ac15233

Please sign in to comment.