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?
babel-polyfll
可以用的WebPack预加载如果您将进入两个babel-polyfll
模块和捆绑软件的根。
entry: ["babel-polyfill", "src/index.js"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.