- Notifications
You must be signed in to change notification settings - Fork16
Browserify transform to apply Rollup (UNMAINTAINED)
License
nolanlawson/rollupify
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Browserify transform to applyRollup, converting ES6/ES2015 modulesinto one big CommonJS module.
This tends to result in smaller bundle sizes, due to Rollup'stree-shaking andscope-hoisting capabilities.
rollup-plugin-commonjs
androllup-plugin-node-resolve
, or manually runrollup
beforebrowserify
.
npm install rollupify
Then:
browserify -t rollupify index.js > output.js
Or in yourpackage.json
:
"browserify":{"transform":["rollupify"]}
Input:
// index.jsimporthellofrom'./hello';console.log(hello);exportdefaulthello;
// hello.jsexportdefault"hello world";
Output:
(functione(t,n,r){functions(o,u){if(!n[o]){if(!t[o]){vara=typeofrequire=="function"&&require;if(!u&&a)returna(o,!0);if(i)returni(o,!0);varf=newError("Cannot find module '"+o+"'");throwf.code="MODULE_NOT_FOUND",f}varl=n[o]={exports:{}};t[o][0].call(l.exports,function(e){varn=t[o][1][e];returns(n?n:e)},l,l.exports,e,t,n,r)}returnn[o].exports}vari=typeofrequire=="function"&&require;for(varo=0;o<r.length;o++)s(r[o]);returns})({1:[function(require,module,exports){'use strict';varhello="hello world";console.log(hello);module.exports=hello;},{}]},{},[1]);
If you are using other transforms likebabelify
, make sure you applythe transforms in the right order.rollupify
should apply beforebabelify
:
browserify -t rollupify -t babelify index.js > output.js
Or when configuring:
"browserify":{"transform":["rollupify","babelify"]}
rollupify
only works on ES6/ES2015 modules. Anyrequire()
statements willbe left untouched, and passed on to Browserify like normal.
Sourcemaps are supported, assuming you pass--debug
or{debug: true}
into Browserify.
Need more evidence that Rollup and ES6 modules are awesome? Seerollup-comparisonandA better build system with Rollup.
Need to get started converting your CommonJS codebase into ES6? Trycjs-to-es6.
Given arollup.config.js
like:
module.exports={plugins:[require('rollup-plugin-babel')({exclude:'node_modules/**'})]}
Use it through the command line:
browserify -t [ rollupify --config rollup.config.js ] index.js > output.js
Or in yourpackage.json
:
"browserify":{"transform":["rollupify",{"config":"rollup.config.js"}]}
If you are using Browserify in JavaScript, you can also pass in theconfig
object directly:
varb=browserify('./').transform('rollupify',{config:{/* your rollup config goes here */}}).bundle();
About
Browserify transform to apply Rollup (UNMAINTAINED)
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.