Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
rollup-plugin-node-builtins
Advanced tools
npm install --save-dev rollup-plugin-node-builtins
Allows the node builtins to be require
d/import
ed. 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.
* 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()
]
})
MIT except ES6 ports of browserify modules which are whatever the original library was.
FAQs
use node builtins in browser with rollup
The npm package rollup-plugin-node-builtins receives a total of 86,226 weekly downloads. As such, rollup-plugin-node-builtins popularity was classified as popular.
We found that rollup-plugin-node-builtins demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.