Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should async await work out of the box? #2442

Closed
vvo opened this issue Dec 20, 2018 · 3 comments
Closed

Should async await work out of the box? #2442

vvo opened this issue Dec 20, 2018 · 3 comments

Comments

@vvo
Copy link

vvo commented Dec 20, 2018

馃檵 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

@mischnic
Copy link
Member

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.)

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Dec 21, 2018

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

@crisleo94
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants