Registry / devops / rollup-packages-polyfill-core

rollup-packages-polyfill-core

JSON →
library0.13.4jsnpmunverified

A Rollup plugin that provides browser polyfills for Node.js built-in modules (e.g., 'buffer', 'process', 'events', 'stream', 'util', 'path', 'crypto', 'fs') in bundles. Current stable version is 0.13.4. Community-maintained fork of ionic-team/rollup-plugin-node-polyfills with updated support for Rollup v1–v4 and TypeScript types. Key differentiator: it leverages ES6 named imports for tree-shakable polyfills, targeting node_modules by default. Not all modules are fully shimmed—some are empty or partial (e.g., http, https, crypto, fs). Active development.

npm install rollup-packages-polyfill-core
INSTALL
IMPORT
SIG · ROLLUP-PACKAGES-PO
R
rollup-packages-polyfill-core
devopsjavascriptv0.13.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nodePolyfills
✓ import nodePolyfills from 'rollup-plugin-polyfill-node';
✗ const nodePolyfills = require('rollup-plugin-polyfill-node');
Default import – library is ESM-first. CommonJS require works but is not recommended.
options
✓ nodePolyfills({ include: ['**/*.js'] })
✗ nodePolyfills({ includes: ['**/*.js'] })
Options: 'include', 'exclude', 'sourceMap'. Note 'include' not 'includes'. Default include is node_modules/**/*.js.
buffer
✓ import { Buffer } from 'buffer';
✗ const { Buffer } = require('buffer');
Named import works with this plugin; supports ES6 modules. Default import also works.

Shows basic setup: import the plugin, configure options (include all files, enable source maps), and use Buffer and process polyfills.

// Install: npm install --save-dev rollup-plugin-polyfill-node // rollup.config.js import nodePolyfills from 'rollup-plugin-polyfill-node'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'iife' }, plugins: [ nodePolyfills({ include: null, // transform all files (including source) sourceMap: true }) ] }; // src/main.js (example usage) import { Buffer } from 'buffer'; import process from 'process'; console.log(Buffer.from('hello').toString()); console.log(process.version);
Debug
Known issues
breakingSome modules (e.g., http, https, fs, crypto) are only partially shimmed or return stubs—expect bugs.
fix
Avoid relying on these polyfills for critical logic; test thoroughly.
affects: >=0.0.0
deprecatedThe module 'punycode' is deprecated in Node.js and the polyfill may be removed in future versions.
fix
Use a modern URL parser instead of punycode.
affects: >=0.0.0
breakingStream polyfill is large and may bloat bundle; tree-shaking is ineffective due to circular references.
fix
If only small parts are needed, consider manual polyfills or tree-shaking with named imports.
affects: >=0.0.0
gotchaDefault include only transforms node_modules. To polyfill source files, set include: null or specify patterns.
fix
Explicitly set include: null to cover all files.
affects: >=0.0.0
deprecatedThe options 'include' and 'exclude' are being standardized; check Rollup plugin conventions.
fix
Continue using include/exclude as documented.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Could not resolve 'buffer' (or other Node built-in) from ...
Plugin not installed or not added to Rollup config's plugins array.
fix
Install rollup-plugin-polyfill-node and add it to your rollup.config.js plugins list.
TypeError: Buffer is not a constructor
Using the global Buffer from Node.js rather than the polyfilled version; polyfill not applied.
fix
Import explicitly: import { Buffer } from 'buffer';
Error: 'require' of ES Module not supported
Using CommonJS require() to import the plugin in an ESM context.
fix
Use import statement: import nodePolyfills from 'rollup-plugin-polyfill-node';
Module not found: Can't resolve 'crypto' (or other partially shimmed module)
Requiring a module that returns an empty stub or mock.
fix
Check the support table; if polyfill is partial, consider using a different approach or avoid importing that module.
Upgrade
Version history
0.13.4latest on npm
Audit
Dependencies
rolluprequiredpeer dependency: requires Rollup ^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-packages-polyfill-core — npm install rollup-packages-polyfill-core · libregistry