Skip to content

Call to regeneratorRuntime precedes the requiring of babel-polyfill #8258

@eranikid

Description

@eranikid

Bug Report

Current Behavior
Upon transpiling a file of code with async function, babel generates the following line:

var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(// ...

regeneratorRuntime is undefined by default, from my research I found that you need to add a babel-polyfill for it to be defined:

import 'babel-polyfill';

async function test() {
  // ...
}

However in a transpiled code, call to require('babel-polyfill'); goes after the call to regeneratorRuntime, thus regeneratorRuntime is still undefined. If I manually move require('babel-polyfill'); to the top of the transpiled file, code works as expected.

Input Code
Link to an example

Expected behavior/code
Call to require('babel-polyfill'); in transpiled code precedes the first call to regeneratorRuntime

Babel Configuration (.babelrc, package.json, cli command)

"scripts": {
  "build": "babel ./ --ignore node_modules,dist -s -D -d dist --presets env"
}

Environment

  • Babel version(s): cli: 6.26.0, core: 6.26.3
  • Node/npm version: Node 8.11.3, npm 5.6.0
  • OS: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions