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.
index.js
const test = async () => {
await Promise.resolve();
}
test();
This should work without any error.
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
.babelrc
{
"plugins": ["@babel/plugin-transform-runtime"]
}
(Read description)
Here's a repository reproducing the error: https://github.com/vvo/parcel-async-await-test
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!
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.)