{"library":"rollup-plugin-node-polyfills","title":"Rollup Plugin for Node.js Polyfills (Legacy)","description":"The `rollup-plugin-node-polyfills` package, currently at version `0.2.1` and last published over 7 years ago, is an abandoned Rollup plugin designed to provide browser-compatible polyfills or shims for Node.js built-in modules. Its primary function was to allow Rollup to bundle code containing `require()` or `import` statements for Node.js core modules (such as `events`, `path`, `buffer`, `http`, and `util`) when targeting a browser environment. The plugin leverages ES6 ports of Browserify modules for its polyfills, enabling both named and default imports for many modules. However, due to its inactive maintenance, developers are strongly advised to use modern, actively maintained alternatives like `rollup-plugin-polyfill-node` to ensure compatibility, security, and access to up-to-date polyfills. This legacy plugin has known limitations, including incomplete shims for certain modules, issues with tree-shaking for complex modules like `stream` and `http` due to circular references, and modules that only return mock objects instead of functional polyfills.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install rollup-plugin-node-polyfills"],"cli":null},"imports":["import nodePolyfills from 'rollup-plugin-node-polyfills';","import EventEmitter from 'events';","import { inherits } from 'util';","import { Buffer } from 'buffer';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import nodePolyfills from 'rollup-plugin-node-polyfills';\nimport EventEmitter from 'events';\nimport { inherits } from 'util';\nimport { Buffer } from 'buffer';\n\nconst eventEmitter = new EventEmitter();\nconsole.log(eventEmitter instanceof EventEmitter);\n\nclass MyClass {}\ninherits(MyClass, EventEmitter);\nconst myInstance = new MyClass();\nconsole.log(myInstance instanceof EventEmitter);\n\nconst buf = Buffer.from('hello');\nconsole.log(buf.toString());\n\nexport default {\n  input: 'main.js',\n  output: {\n    file: 'bundle.js',\n    format: 'esm'\n  },\n  plugins: [\n    nodePolyfills()\n  ]\n};","lang":"javascript","description":"Demonstrates a basic Rollup configuration using the `nodePolyfills` plugin and shows how to import and use a few polyfilled Node.js built-in modules like `events`, `util`, and `buffer` in the `main.js` entry point.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}