MCPcopy Index your code
hub / github.com/calvinmetcalf/rollup-plugin-node-builtins

github.com/calvinmetcalf/rollup-plugin-node-builtins @v2.1.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1.2 ↗ · + Follow
381 symbols 847 edges 59 files 9 documented · 2% 19 cross-repo links updated 5y ago★ 13828 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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, some modules require rollup-plugin-node-globals.

The following modules include ES6 specific version which allow you to do named imports in addition to the default import and should work fine if you only use this plugin.

  • process*
  • events
  • stream*
  • util*
  • path
  • buffer*
  • querystring
  • url*
  • string_decoder*
  • punycode
  • http*†
  • https*†
  • os*
  • assert*
  • constants
  • timers*
  • console*‡
  • vm*§
  • zlib*
  • tty
  • domain
  • dns∆
  • dgram∆
  • child_process∆
  • cluster∆
  • module∆
  • net∆
  • readline∆
  • repl∆
  • tls∆
  • fs˚
  • crypto˚

* requires node-globals plugin

† the http and https modules are actually the same and don't differentiate based on protocol

‡ default export only, because it's console, seriously just use the global

§ vm does not have all corner cases and has less of them in a web worker

∆ not shimmed, just returns mock

˚ optional, add option to enable browserified shim

Crypto is not shimmed and and we just provide the commonjs one from browserify and it will likely not work, if you really want it please pass {crypto: true} as an option.

Not all included modules rollup equally, streams (and by extension anything that requires it like http) are a mess of circular references that are pretty much impossible to tree-shake out, similarly url methods are actually a shortcut to a url object so those methods don't tree shake out very well, punycode, path, querystring, events, util, and process tree shake very well especially if you do named imports.

config for using this with something simple like events or querystring

import builtins from 'rollup-plugin-node-builtins';
rollup({
  entry: 'main.js',
  plugins: [
    builtins()
  ]
})

and now if main contains this, it should just work

import EventEmitter from 'events';
import {inherits} from 'util';

// etc

Config for something more complicated like http

import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
rollup({
  entry: 'main.js',
  plugins: [
    globals(),
    builtins()
  ]
})

License

MIT except ES6 ports of browserify modules which are whatever the original library was.

Core symbols most depended-on inside this repo

done
called by 32
src/es6/readable-stream/transform.js
put_byte
called by 32
src/es6/zlib-lib/deflate.js
join
called by 24
src/es6/path.js
crc32
called by 18
src/es6/zlib-lib/crc32.js
flush_block_only
called by 17
src/es6/zlib-lib/deflate.js
send_bits
called by 14
src/es6/zlib-lib/trees.js
fail
called by 12
src/es6/assert.js
send_code
called by 10
src/es6/zlib-lib/trees.js

Shape

Function 381

Languages

TypeScript100%

Modules by API surface

src/es6/zlib.js36 symbols
src/es6/util.js35 symbols
src/es6/readable-stream/readable.js35 symbols
src/es6/zlib-lib/trees.js29 symbols
src/es6/assert.js29 symbols
src/es6/zlib-lib/deflate.js26 symbols
src/es6/readable-stream/writable.js20 symbols
src/es6/events.js16 symbols
src/es6/vm.js14 symbols
src/es6/os.js14 symbols
src/es6/zlib-lib/inflate.js13 symbols
src/es6/punycode.js12 symbols

For agents

$ claude mcp add rollup-plugin-node-builtins \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact