Skip to content

Commit

Permalink
Run terser
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 12, 2018
1 parent e63ab6f commit 0095db0
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 22,747 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -10,25 +10,25 @@ Example implementation of `tree-shaking` and `dead code elimination` of
file size
------------------ ---------
parcel/lodash-es 19.28 KB
rollup/lodash-es 495.34 KB
rollup/lodash-es 117.79 KB
webpack/lodash-es 20.74 KB
parcel/lodash 91.13 KB
rollup/lodash 526.79 KB
rollup/lodash 69.1 KB
webpack/lodash 70.57 KB
parcel/remeda 1.9 KB
rollup/remeda 20.55 KB
rollup/remeda 8.46 KB
webpack/remeda 2.74 KB
parcel/ramda 6.36 KB
rollup/ramda 88.74 KB
rollup/ramda 20.91 KB
webpack/ramda 7.16 KB
parcel/ramdaBabel 6.72 KB
rollup/ramdaBabel 23.09 KB
rollup/ramdaBabel 8.27 KB
webpack/ramdaBabel 8.39 KB
parcel/rambda 9.81 KB
rollup/rambda 787 B
rollup/rambda 682 B
webpack/rambda 2 KB
parcel/rambdax 25.57 KB
rollup/rambdax 20.77 KB
rollup/rambdax 6.03 KB
webpack/rambdax 5.09 KB
```

Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -25,6 +25,8 @@
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^3.0.0",
"terser-webpack-plugin": "^1.1.0",
"webpack": "^4.21.0",
"webpack-cli": "^3.1.2"
},
Expand Down
4 changes: 3 additions & 1 deletion rollup.config.js
@@ -1,6 +1,7 @@
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import { terser } from "rollup-plugin-terser";

const libName = process.env.LIB;

Expand All @@ -13,7 +14,8 @@ export default [
babel({
exclude: "node_modules/**"
}),
commonjs()
commonjs(),
terser({ sourcemap: false })
],
output: [{ file: `rollup/${libName}.js`, format: "cjs" }]
}
Expand Down

1 comment on commit 0095db0

@kzc
Copy link

@kzc kzc commented on 0095db0 Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mischnic You'd get better Rollup results with the following patch:

--- a/rollup.config.js
+++ b/rollup.config.js
@@ -17,3 +17,6 @@ export default [
                        commonjs(),
-                       terser({ sourcemap: false })
+                       terser({
+                               toplevel: true,
+                               sourcemap: false,
+                       })
                ],
file                size    
------------------  --------
parcel/lodash-es    19.28 KB
rollup/lodash-es    81.08 KB
webpack/lodash-es   20.74 KB
parcel/lodash       91.13 KB
rollup/lodash       68.95 KB
webpack/lodash      70.57 KB
parcel/remeda       1.9 KB  
rollup/remeda       6.63 KB 
webpack/remeda      2.74 KB 
parcel/ramda        6.36 KB 
rollup/ramda        6.68 KB 
webpack/ramda       7.16 KB 
parcel/ramdaBabel   6.72 KB 
rollup/ramdaBabel   6.35 KB 
webpack/ramdaBabel  8.39 KB 
parcel/rambda       9.81 KB 
rollup/rambda       589 B   
webpack/rambda      2 KB    
parcel/rambdax      25.57 KB
rollup/rambdax      3.83 KB 
webpack/rambdax     5.09 KB 

The anomalous results for rollup/lodash-es and rollup/remeda is due to Rollup not yet supporting sideEffects.

Please sign in to comment.