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

Created on 12 May 2020  Ā·  9Comments  Ā·  Source: rollup/plugins

  • 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.
c³ ā‹… PR welcome x⁷ ā‹… stale šŸ”Œ plugin-babel

Most helpful comment

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? :(

All 9 comments

I encountered the same problem

rollup.config.js

import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'

export default {
  input: './index.js',
  output: {
    format: 'umd',
    dir: 'dist'
  },
  plugins: [
    getBabelOutputPlugin({
      configFile: path.resolve(__dirname, '.babelrc'),
      allowAllFormats: true
    }),
    babel({
      babelHelpers: 'runtime'
    })
  ]
}

.babelrc

{
  "presets": [
    "@babel/preset-env"
  ],
  "plugins": [
    [
      "@babel/plugin-proposal-class-properties",
      { "loose": true }
    ],
    [
      "@babel/plugin-transform-runtime",
      { "corejs": 2 }
    ]
  ]
}
./index.js → dist...
[!] (plugin babel) Error: You must use the `@babel/plugin-transform-runtime` plugin when `babelHelpers` is "runtime".

node_modules/@babel/runtime-corejs2/core-js/promise.js

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? :(

@dangreen A link to a PR is not a proper reproduction.

Citing the issue template:

Issues without minimal reproductions will be closed! Please provide one by:

  1. Using the REPL.it plugin reproduction template at https://repl.it/@rollup/rollup-plugin-repro
  2. Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
    These may take more time to triage than the other options.
  3. Using the REPL at https://rollupjs.org/repl/

Please add a reproduction and we'll be happy to triage further. Given there's a workaround already posted, we'll leave this open, but the rollup team won't triage this until a proper repro is added.

Ran into this too while updating dependencies. Happy to push the WIP branch if it helps

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

A PR would be amazing. I'm not the sole contributor here and I haven't worked on the Babel plugin.

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. ā“˜

I'm still getting this.

Was this page helpful?
0 / 5 - 0 ratings