parcel: Uncaught ReferenceError: regeneratorRuntime is not defined

๐Ÿ› bug report

When I started using generators in my code. I got the error message when running : Uncaught ReferenceError: regeneratorRuntime is not defined.

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

{
  "plugins": [
    ["@babel/plugin-transform-runtime", {
      "corejs": 2
    }]
  ]
}
  "devDependencies": {
    "babel-cli": "^7.0.0-beta.3",
    "babel-core": "^7.0.0-beta.3",
    "babel-plugin-transform-class-properties": "^7.0.0-beta.3",
    "babel-plugin-transform-object-assign": "^7.0.0-beta.3",
    "babel-plugin-transform-runtime": "^7.0.0-beta.3",
    "babel-preset-es2015": "^7.0.0-beta.3",
    "babel-preset-react": "^7.0.0-beta.3",
    "babel-preset-stage-0": "^7.0.0-beta.3",
    "babel-runtime": "^7.0.0-beta.3",
    "babelify": "^7.3.0",
    "parcel-bundler": "^1.10.3",
    "qunitjs": "^1.20.0"
  },
  "dependencies": {
    "babel-polyfill": "^7.0.0-beta.3"
  }

๐Ÿค” Expected Behavior

generator should just work.

๐Ÿ˜ฏ Current Behavior

Uncaught ReferenceError: regeneratorRuntime is not defined
    at Object.parcelRequire.../src/index.js../helpers (index.js:4)
    at newRequire (test.e31bb0bc.js:49)
    at localRequire (test.e31bb0bc.js:55)
    at Object.parcelRequire.graph-edge-traversal.specs.js.qunitjs (graph-edge-traversal.specs.js:2)
    at newRequire (test.e31bb0bc.js:49)
    at localRequire (test.e31bb0bc.js:55)
    at Object.parcelRequire.index.js../graph-edge-traversal.specs (index.js:1)
    at newRequire (test.e31bb0bc.js:49)
    at parcelRequire.../node_modules/process/browser.js (test.e31bb0bc.js:81)
    at test.e31bb0bc.js:107

๐Ÿ’ Possible Solution

This is related to #1762. However, adding import "babel-polyfill" in my index.js made it work. I however cannot do that, I bundle with rollup and that breaks my rollup bundle.

๐Ÿ”ฆ Context

๐Ÿ’ป Code Sample

Cf. test directory Cf. package.json

๐ŸŒ Your Environment

    "babel-runtime": "^7.0.0-beta.3",
    "parcel-bundler": "^1.10.3",
Software Version(s)
Parcel 1.10.3
Node 8.2.0
npm/Yarn npm
Operating System windows 10

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 20
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

how to solve ?

If you are targeting modern browsers, a simple solution is to add the browserslist property to your package.json file

{
    "name": "my-app",
    ...
    "browserslist": [
        "last 1 Chrome versions"
    ],
    ...
}

Note: you can change last 1 to last 2 or 3 or however far back you decide to go

Closing as itโ€™s a duplicate

how to solve ?

how to solve ?

If you are targeting modern browsers, a simple solution is to add the browserslist property to your package.json file

{
    "name": "my-app",
    ...
    "browserslist": [
        "last 1 Chrome versions"
    ],
    ...
}

Note: you can change last 1 to last 2 or 3 or however far back you decide to go

Hey! I did it, but still the issue.

Iโ€™ve had the same issue. Downgrading to parcel@1.9 solved it.

Add to your package.json "browserslist": [ "last 2 Chrome versions" ]

you can change the browser youโ€™re using, It doesnโ€™t have to be only chrome

 "browserslist": [
        "last 1 Chrome versions"
    ],

does not solve the issue if you need to debug for safari

"browserslist": [
        "last 1 Chrome versions"
    ],

this solved problem for me. @felipemullen thank you!

It doesnโ€™t appear to be documented within on the parcel website, but looking at the npm package it appears to depend on babel, and babel in turn has a dependency on the browserslist package, which uses that configuration.

You can read more about it and how to configure properly here: https://github.com/browserslist/browserslist