Parcel: Should async await work out of the box?

Created on 20 Dec 2018  路  3Comments  路  Source: parcel-bundler/parcel

馃檵 feature request

I would like to be able to use async await without having to configure anything. Just like the parceljs website says it: Blazing fast, zero configuration web application bundler.

I understand the "zero configuration" part is marketing-ish and that ultimately you always endup configuring parcel a bit in case of exotic usage. Though a lot less than webpack in my experience for sure!

When I first tried to use parcel yesterday, out of three hours of setup I spent 80% of my time struggling with making async/await expressions work. While I believe they are nowadays the "new" norm (and so, not exotic) on how to write asynchronous code and even what we teach to new JavaScript developers. Thus I believe async/await should work out of the box using parcel and that's not the case today.

馃 Expected Behavior

index.js

const test = async () => {
  await Promise.resolve();
}

test();

This should work without any error.

馃槸 Current Behavior

This triggers an error in console.

Uncaught ReferenceError: regeneratorRuntime is not defined
    at parcel-example.e31bb0bc.js:117
    at Object.parcelRequire.index.js (parcel-example.e31bb0bc.js:136)
    at newRequire (parcel-example.e31bb0bc.js:49)
    at parcel-example.e31bb0bc.js:81
    at parcel-example.e31bb0bc.js:107

馃拋 Possible Solution

.babelrc

{
  "plugins": ["@babel/plugin-transform-runtime"]
}

馃敠 Context

(Read description)

馃捇 Examples

Here's a repository reproducing the error: https://github.com/vvo/parcel-async-await-test

Most helpful comment

A duplicate of #1762. But zero configuration is a good point. Can't babel determine by itself if the runtime is needed? (If not, there should at least be a more helpful warning.)

All 3 comments

A duplicate of #1762. But zero configuration is a good point. Can't babel determine by itself if the runtime is needed? (If not, there should at least be a more helpful warning.)

There have been a couple issues about this.
Any help with adding a more helpfull error message for this is very welcome :)

Having the same trouble, if you get here for the same reason, just go here https://babeljs.io/docs/en/babel-plugin-transform-runtime you'll be able to solve this issue!

Was this page helpful?
0 / 5 - 0 ratings