Registry / devops / rollup-plugin-corejs

rollup-plugin-corejs

JSON →
library1.0.2jsnpmunverified

A Rollup plugin that injects core-js polyfills based on browserslist configuration. Current stable version is 1.0.2, supporting Rollup 3 and 4. It acts as a wrapper around core-js-builder, enabling polyfill injection without Babel. Key differentiator: similar to Babel's useBuiltIns: 'usage' option, it can detect which APIs are used in your code and include only those polyfills, reducing bundle size. Enforces Node >=20. ESM-only module, ships TypeScript types. Release cadence is low, with occasional dependency updates.

npm install rollup-plugin-corejs
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-CORE
R
rollup-plugin-corejs
devopsjavascriptv1.0.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

corejsPlugin
✓ import { corejsPlugin } from 'rollup-plugin-corejs'
✗ const corejsPlugin = require('rollup-plugin-corejs')
Package is ESM-only; CommonJS require is not supported.
corejsPlugin
✓ const { corejsPlugin } = await import('rollup-plugin-corejs')
✗ const { corejsPlugin } = require('rollup-plugin-corejs')
In dynamic import scenarios, use await import.
corejsPlugin (type import)
✓ import type { Options } from 'rollup-plugin-corejs'
✗ import { Options } from 'rollup-plugin-corejs'
Options type is not exported as a value, only type.

Shows basic Rollup configuration using the plugin with core-js/es modules and usage-based polyfill detection.

import { corejsPlugin } from 'rollup-plugin-corejs'; import { defineConfig } from 'rollup'; export default defineConfig({ input: 'src/index.js', plugins: [ corejsPlugin({ // Use polyfills for ES features only modules: 'core-js/es', // Only include polyfills for APIs used in your code usage: true, // Optionally specify targets (defaults to browserslist) targets: '> 0.5%, not dead' }) ], output: { file: 'dist/bundle.js', format: 'es' } });
Debug
Known issues
gotchaUsage-based polyfill detection only analyzes your own code, not third-party dependencies.
fix
If third-party polyfills are needed, consider adding them separately or using a different strategy.
affects: >=1.0.0
breakingv1.0.0 removed the 'summary' option. Using it will throw an error.
fix
Remove the summary option from plugin configuration.
affects: >=1.0.0
deprecatedRollup 3 support is deprecated; future versions may only support Rollup 4.
fix
Upgrade to Rollup 4 as soon as possible.
affects: >=1.0.0
gotchaNode.js version must be >=20.0.0. Older versions will fail to load the plugin.
fix
Upgrade Node.js to version 20 or later.
affects: >=1.0.0
gotchaThe package is ESM-only. If your Rollup config uses CommonJS, you must migrate to ESM or use dynamic import.
fix
Rename rollup.config.js to rollup.config.mjs or use top-level await with dynamic import.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module from rollup-plugin-corejs not supported.
The package is ESM-only but imported using require() in a CommonJS context.
fix
Use import { corejsPlugin } from 'rollup-plugin-corejs' in your Rollup config, or rename the file to .mjs.
TypeError: corejsPlugin is not a function
Improper import or destructuring, e.g., const corejsPlugin = require('rollup-plugin-corejs') returns the module object, not the function directly.
fix
Use destructuring: const { corejsPlugin } = await import('rollup-plugin-corejs') or ESM import.
Error: Cannot find module 'core-js-builder'
core-js-builder is a dependency of the plugin, but it may fail to resolve in some environments.
fix
Ensure core-js is installed as a dev dependency: npm install -D core-js
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
rolluprequiredpeer dependency, required as the plugin host
Agent activity
5 hits · last 30 days
node
4
Resources
rollup-plugin-corejs — npm install rollup-plugin-corejs · libregistry