After updating to the latest version of Babel v6, I encountered an issue with the transform-es2015-classes
plugin in loose mode (https://github.com/bkonkle/babel-preset-es2015-loose/blob/master/index.js#L8) causing problems with async/await functions. Here is an example:
function _asyncFunc (value) {
return new Promise((resolve) => {
setTimeout(() => resolve(value), 10);
});
}
class TestActions {
async asyncAction(returnValue) {
const result = await _asyncFunc(returnValue); // exception here
return result;
}
}
This issue occurs with the use of loose mode on this line:
var result = await _asyncFunc(returnValue);
^^^^^^^^^^
SyntaxError: Unexpected identifier
The Babelrc configuration looks like this (I am also importing regenerator runtime in the entry point):
{
"presets": [
"es2015-loose",
"react",
"stage-0"
]
}
I have to use loose mode due to a specific Babel bug -
Are there any workarounds available?