sokra / react-rollup-webpack-test

A simple React app for bundler tree-shaking comparison.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Rollup & Webpack Tree-Shaking Test

A simple app test case for tree-shaking comparison.

Current status

Bundle size (bare app and with unused Link from react-router-dom package):

Bundler Version Contents Size
rollup 0.43.0 react 15.6.1 131 kb
rollup 0.43.0 react 15.6.1 + react-router 4.1.1 170 kb
webpack 3.0.0 react 15.6.1 146 kb
webpack 3.0.0 react 15.6.1 + react-router 4.1.1 186 kb
webpack 4.0.0-alpha.2 sideEffects react 15.6.1 144 kb
webpack 4.0.0-alpha.2 sideEffects react 15.6.1 + react-router 4.1.1 144 kb

Results

  • Neither Rollup nor Webpack can't remove unused react-router-dom package.
  • Rollup bundle file is 15kb / 16kb less.
  • Webpack 3.0.0 Scope Hoisting feature reduced the file by 1kb. Yaaay

Usage

Console commands:

  • Rollup build (saved as build/rollup.js):
npm run build:rollup
  • Webpack build (saved as build/webpack.js):
npm run build:webpack
  • both builds
npm run build

About

A simple React app for bundler tree-shaking comparison.


Languages

Language:JavaScript 70.0%Language:HTML 30.0%