Reputation: 59355
I created a boilerplate to use babel's async
/await
and you need a polyfill to use it.
Here's the repo https://github.com/reggi/esnext-boilerplate
Here's an example:
import "babel-polyfill"
async function five() {
return 5
}
async function helloWorld() {
var numb = await five()
console.log(numb)
}
helloWorld() // logs `5`
Is there any way for babel to automatically compile with babel-polyfill
so I don't need to explicitly import it?
Upvotes: 2
Views: 235
Reputation: 59355
babel-polyfll
can be preloaded with webpack if you set your entry to both the babel-polyfll
module and the root of your bundle.
entry: ["babel-polyfill", "src/index.js"]
Upvotes: 2