visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

Switch to rollup for the build #454

Closed matthewp closed 6 years ago

matthewp commented 6 years ago

This switches to using rollup for the build. This fixes #444 among other things.

matthewp commented 6 years ago

Shaves about 2k off of the bundle size.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 91.429% when pulling 809be4d9df517cd23f6374e3d68d39d6a26cd601 on build into 6f3fbb9010d56e8a63ad6de6f3980baf30f27585 on master.

matthewp commented 6 years ago

cc @paulocoghi

paulocoghi commented 6 years ago

Excellent!

Also, these removed kbs can make room for any new features without leaving the library larger than usual.

paulocoghi commented 6 years ago

I have only one suggestion. In my opinion, it would be interesting to offer a minified version, page.min.js, using rollup-plugin-uglify, this way:

import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import { minify } from 'uglify-es';

export default {
  input: 'index.js',
  output: {
    file: 'page.min.js',
    format: 'umd',
    name: 'page'
  },
  plugins: [
    nodeResolve({
      jsnext: true,
      main: true
    }),
    commonjs({
      include: ['node_modules/**', '**']
    }),
    uglify( {}, minify )
  ]
};
paulocoghi commented 6 years ago

The code above (for minified version) can reside in a new (additional) file rollup.config-min.js, and in package.json, you can change the "make" line to:

"make": "rollup -c rollup.config.js && rollup -c rollup.config-min.js"
matthewp commented 6 years ago

@paulocoghi Let's discuss the minify idea in a new issue. I'd like to take some time to discuss it a bit and see what other libraries are doing these days (not sure if most are including a minified version or not. Does any include a gzipped version too?), and I don't want that to block this PR since it fixes issues like #458

vagran commented 6 years ago

BTW I opened #444 because it was not fully minified and I included page.js among other scripts for minification by closure compiler.