plugins: @rollup/plugin-babel: babelHelpers option error

  • Rollup Plugin Name: @rollup/plugin-babel
  • Rollup Plugin Version: 5.0.0
  • Rollup Version: 1.13.0
  • Operating System (or Browser): macOS
  • Node Version: v11.15.0

How Do We Reproduce?

https://github.com/canvg/canvg/pull/1046#discussion_r423445163

Expected Behavior

Lookup @babel/plugin-transform-runtime over babelrc and presets.

Actual Behavior

With babelHelpers: 'runtime' @rollup/plugin-babel lookup @babel/plugin-transform-runtime only in plugin options, but plugin-transform-runtime is included in preset (or in babelrc).

src/index.ts → lib/index.js, lib/index.es.js...
[!] (plugin babel) Error: You must use the `@babel/plugin-transform-runtime` plugin when `babelHelpers` is "runtime".

node_modules/regenerator-runtime/runtime.js
Error: You must use the `@babel/plugin-transform-runtime` plugin when `babelHelpers` is "runtime".

    at error (/Users/dangreen/github/canvg/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at throwPluginError (/Users/dangreen/github/canvg/node_modules/rollup/dist/shared/node-entry.js:11878:12)
    at Object.error (/Users/dangreen/github/canvg/node_modules/rollup/dist/shared/node-entry.js:12912:24)
    at Object.error (/Users/dangreen/github/canvg/node_modules/rollup/dist/shared/node-entry.js:12081:38)
    at preflightCheck (/Users/dangreen/github/canvg/node_modules/@rollup/plugin-babel/dist/index.js:188:11)

error Command failed with exit code 1.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 20
  • Comments: 24

Most upvoted comments

I found a configuration method to avoid this error

babel({
    babelHelpers: 'runtime',
    skipPreflightCheck: true
})

but how do you compile the dependencies of babel runtime to a file? 😦

add exclude to config, it works for me

babel({    
  babelHelpers: 'runtime',
  exclude: '**/node_modules/**',
}),

Hey folks. This issue hasn’t received any traction for 60 days, so we’re going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we’ll consider reopening it. ⓘ

add exclude to config, it works for me

babel({    
  babelHelpers: 'runtime',
  exclude: '**/node_modules/**',
}),

If it doesn’t work, use this one:

    babel({
        babelHelpers: 'runtime',
        exclude: /^(.+\/)?node_modules\/.+$/
    })

I’m still getting this.

I got the same error in pnpm workspaces

and solve it with skipPreflightCheck: 'true'

babel({
        babelHelpers: 'runtime',
        skipPreflightCheck: 'true',
        extensions: [...DEFAULT_EXTENSIONS, '.ts'],
        exclude: /^(.+\/)?node_modules\/.+$/,
      }),

@shellscape looks like @dangreen provided a reproduction. Does that suffice? Is there anything else you need from us?