@warrenseymour/rollup-plugin-node-builtins
use node builtins in browser with rollup
Last updated 3 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.

rollup-plugin-node-builtins

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';
rollup({
  entry: 'main.js',
  plugins: [
    builtins(),
    nodeResolve({ jsnext: true, main: true, browser: true }),
    commonjs({
      ignoreGlobal: true
    }),
    globals(),
    json()
  ]
})

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 (3 years ago)

2 Versions

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

Copyright 2014 - 2016 © taobao.org |