rollup-regenerator-runtime

raw JSON →
6.23.1 verified Mon Apr 27 auth: no javascript

Provides the regenerator runtime as a self-contained module for bundling with Rollup. Version 6.23.1 is the latest stable release. It replaces the default babel-runtime regenerator import with a local copy, avoiding external dependencies when using async/await and generators in libraries compiled with Rollup. Key differentiator: allows bundling regenerator runtime without requiring the full babel-runtime package, reducing bundle size and avoiding issues with Rollup's module resolution.

error Module not found: Can't resolve 'regenerator-runtime' in ...
cause Babel transforms async/await but still imports from default 'regenerator-runtime' instead of 'rollup-regenerator-runtime'.
fix
Set moduleName to 'rollup-regenerator-runtime' in transform-runtime options and import 'rollup-regenerator-runtime' in your entry file.
error regeneratorRuntime is not defined
cause The global regeneratorRuntime may not have been registered before async/await code runs.
fix
Ensure import 'rollup-regenerator-runtime'; is placed at the top of your entry file, before any async functions.
gotcha The module must be imported (or required) as a side effect; it does not export anything. CommonJS require returns an empty object.
fix Use `import 'rollup-regenerator-runtime';` or `require('rollup-regenerator-runtime');` without assigning to a variable.
gotcha This package only works when used as the regenerator moduleName in babel-plugin-transform-runtime. It does not function standalone.
fix Ensure Babel configuration includes the plugins as shown in quickstart.
npm install rollup-regenerator-runtime
yarn add rollup-regenerator-runtime
pnpm add rollup-regenerator-runtime

Shows Babel configuration to replace babel-runtime regenerator with rollup-regenerator-runtime, and the import needed in the entry file.

// .babelrc
{
  "plugins": [
    "transform-regenerator",
    ["transform-runtime", {
      "helpers": false,
      "polyfill": false,
      "regenerator": true,
      "moduleName": "rollup-regenerator-runtime"
    }]
  ]
}

// In your entry file (must be imported before any async/await or generators)
import 'rollup-regenerator-runtime';