node package manager
It’s your turn. Help us improve JavaScript. Take the 2017 JavaScript Ecosystem Survey »



Opinionated ES6 library bundler based on rollup and buble

It's for my own modules, but maybe you can find it useful too. It changes often (but follows semver). Unannounced PRs generally not welcome, but feel free to open issues to discuss first.

It outputs the following files:

  • dist/[lib-name].js
    A file for the browser with a global called [libName]
  • dist/[lib-name].min.js
    The same file as above, but minified with UglifyJS 2
  • dist/[lib-name].common-js.js
    A file to be used with browserify or similar. Set it up with:
    "main": "dist/[lib-name].common-js.js", in package.json
  • dist/[lib-name].es-modules.js
    A file to be used with ESM-aware bundlers like rollup. Set it up with:
    "module": "dist/[lib-name].es-modules.js", in package.json


Install it in your project:

npm install --save-dev bfred-npm-bundler 

Add the references to the generated files and the build step in your package.json:

    "main": "dist/lib-name.common-js.js",
    "module": "dist/",
    "jsnext:main": "dist/",
    "scripts": {
        "build": "bfred-npm-bundler lib-name libName",
        "prepublish": "npm run build"


If your lib only makes sense inside node/browserify, you can skip the browser file creation by not passing the second argument:

bfred-npm-bundler lib-name instead of bfred-npm-bundler lib-name libName


The browser file is useful to be used for byte-counting via gzip-size-cli or with badges. If your package is node-only, you can pass the option --byte-count and a dist/[lib-name].size-measuring-only.js file will be created.


rollup-babel-lib-bundler is more configurable


MIT © Federico Brigante