Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Browserify transform to apply Rollup (UNMAINTAINED)

License

NotificationsYou must be signed in to change notification settings

nolanlawson/rollupify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

⚠️Maintenance notice: This repo is unmaintained. I consider it largely a hack for migrating existing Browserify/CommonJS projects to Rollup/ESM. Probably you should just use Rollup instead, with plugins likerollup-plugin-commonjs androllup-plugin-node-resolve, or manually runrollup beforebrowserify.

Usage

npm install rollupify

Then:

browserify -t rollupify index.js > output.js

Or in yourpackage.json:

"browserify":{"transform":["rollupify"]}

Example

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]);

Using alongside other transforms

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"]}

Details

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.

Customising rollup

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

Stars

Watchers

Forks

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp