use node builtins in browser with rollup
Last updated 4 years ago by warrenseymour .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @warrenseymour/rollup-plugin-node-builtins 
SYNC missed versions from official npm registry.


npm install --save-dev rollup-plugin-node-builtins

Allows the node builtins to be required/imported. Doing so gives the proper shims to support modules that were designed for Browserify.

You almost certainly need to be using this in conjunction with rollup-plugin-commonjs, rollup-plugin-node-resolve, rollup-plugin-json and rollup-plugin-node-globals.

There's no config per se, but you need to add node_modules/rollup-plugin-node-globals/** to the commonjs excludes and make sure you set browser to be true in nodeResolve. Also it should come before nodeResolve and globals should come after commonjs. For example:

import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import builtins from 'rollup-plugin-node-builtins';
import json from 'rollup-plugin-json';
  entry: 'main.js',
  plugins: [
    nodeResolve({ jsnext: true, main: true, browser: true }),
      ignoreGlobal: true

The following modules include ES6 specific version which allow you to do named imports in addition to the default import. These definitely work

  • process
  • events
  • stream
  • util
  • path
  • buffer
  • querystring

Crypto does not work at the moment

Current Tags

  • 1.0.6                                ...           latest (4 years ago)

2 Versions

  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 0
Dev Dependencies (3)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |