Closed IngwiePhoenix closed 5 years ago
You need to prefix your class method with async
if you want to use await
.
class Foo {
async init() {
try {
let a = await someFunction();
let b = await someFunction();
console.log("Math:" + (a+b))
} catch(e) throw e;
}
}
@mauricecruz is right. Babel strictly enforces await
inside async
only.
nodent
allows you to use await
outside of async
, but this is a non-standard extension. See https://github.com/MatAtBread/nodent#differences-from-the-es7-specification for more information
I will get right to the point:
.babelrc
:Error:
Versions:
What I am trying to do is, to test various transformer plugins on the CLI before adding them to my WebPack build. I wanted to test
fast-async
to see if it transformsasync
andawait
in the way that I want.While I am at it: How do I tell the plugin to only include the NoDent runtime once for many files, so it doesn't blow up the whole build in the end?
Well, I tried removing various entries from the
.babelrc
and even tried without a.babelrc
entirely, with the plugin just specified on the CLI, and get the same error each and every time. What am I doing wrong here? :)Also, the code I am trying to transpile: