{"id":21969,"library":"rollup-plugin-corejs","title":"rollup-plugin-corejs","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/susnux/rollup-plugin-corejs","tags":["javascript","corejs","core-js","polyfill","polyfills","rollup","rollupplugin","rollup-plugin","browserslist","typescript"],"install":[{"cmd":"npm install rollup-plugin-corejs","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-corejs","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-corejs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required as the plugin host","package":"rollup","optional":false}],"imports":[{"note":"Package is ESM-only; CommonJS require is not supported.","wrong":"const corejsPlugin = require('rollup-plugin-corejs')","symbol":"corejsPlugin","correct":"import { corejsPlugin } from 'rollup-plugin-corejs'"},{"note":"In dynamic import scenarios, use await import.","wrong":"const { corejsPlugin } = require('rollup-plugin-corejs')","symbol":"corejsPlugin","correct":"const { corejsPlugin } = await import('rollup-plugin-corejs')"},{"note":"Options type is not exported as a value, only type.","wrong":"import { Options } from 'rollup-plugin-corejs'","symbol":"corejsPlugin (type import)","correct":"import type { Options } from 'rollup-plugin-corejs'"}],"quickstart":{"code":"import { corejsPlugin } from 'rollup-plugin-corejs';\nimport { defineConfig } from 'rollup';\n\nexport default defineConfig({\n  input: 'src/index.js',\n  plugins: [\n    corejsPlugin({\n      // Use polyfills for ES features only\n      modules: 'core-js/es',\n      // Only include polyfills for APIs used in your code\n      usage: true,\n      // Optionally specify targets (defaults to browserslist)\n      targets: '> 0.5%, not dead'\n    })\n  ],\n  output: {\n    file: 'dist/bundle.js',\n    format: 'es'\n  }\n});","lang":"typescript","description":"Shows basic Rollup configuration using the plugin with core-js/es modules and usage-based polyfill detection."},"warnings":[{"fix":"If third-party polyfills are needed, consider adding them separately or using a different strategy.","message":"Usage-based polyfill detection only analyzes your own code, not third-party dependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove the summary option from plugin configuration.","message":"v1.0.0 removed the 'summary' option. Using it will throw an error.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade to Rollup 4 as soon as possible.","message":"Rollup 3 support is deprecated; future versions may only support Rollup 4.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js to version 20 or later.","message":"Node.js version must be >=20.0.0. Older versions will fail to load the plugin.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Rename rollup.config.js to rollup.config.mjs or use top-level await with dynamic import.","message":"The package is ESM-only. If your Rollup config uses CommonJS, you must migrate to ESM or use dynamic import.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import { corejsPlugin } from 'rollup-plugin-corejs' in your Rollup config, or rename the file to .mjs.","cause":"The package is ESM-only but imported using require() in a CommonJS context.","error":"ERR_REQUIRE_ESM: require() of ES Module from rollup-plugin-corejs not supported."},{"fix":"Use destructuring: const { corejsPlugin } = await import('rollup-plugin-corejs') or ESM import.","cause":"Improper import or destructuring, e.g., const corejsPlugin = require('rollup-plugin-corejs') returns the module object, not the function directly.","error":"TypeError: corejsPlugin is not a function"},{"fix":"Ensure core-js is installed as a dev dependency: npm install -D core-js","cause":"core-js-builder is a dependency of the plugin, but it may fail to resolve in some environments.","error":"Error: Cannot find module 'core-js-builder'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}