3 回答
TA贡献1783条经验 获得超5个赞
babel-polyfill
npm i -D babel-core babel-polyfill babel-preset-es2015 babel-preset-stage-0 babel-loader
"devDependencies": {
"babel-core": "^6.0.20",
"babel-polyfill": "^6.0.16",
"babel-preset-es2015": "^6.0.15",
"babel-preset-stage-0": "^6.0.15"}{
"presets": [ "es2015", "stage-0" ]}"use strict";export default async function foo() {
var s = await bar();
console.log(s);}function bar() {
return "bar";}require("babel-core/register");require("babel-polyfill");entrywebpack.config.js
module.exports = {
entry: ['babel-polyfill', './test.js'],
output: {
filename: 'bundle.js'
},
module: {
loaders: [
{ test: /\.jsx?$/, loader: 'babel', }
]
}};mocha --compilers js:babel-core/register --require babel-polyfill
TA贡献1934条经验 获得超2个赞
外部化对帮助者和构建器的引用,自动填充代码而不污染全局。这到底是什么意思?基本上,您可以使用内置的,如承诺,集,符号等,以及使用所有的巴贝尔功能,需要一个完整的填充,没有全球性的污染,使它非常适合图书馆。
$ npm install --save-dev babel-plugin-transform-runtime
.babelrc
{
"plugins": [
["transform-runtime", {
"regenerator": true
}]
]}TA贡献1946条经验 获得超3个赞
babel-preset-env.
import 'babel-polyfill'
babel-polyfill
entry: {
index: ['babel-polyfill', './index.js']}我相信我找到了最新的最佳做法。
yarn add --dev babel-preset-env
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 Chrome versions"]
}
}]
]}告诉我什么,别告诉我怎么做。
babel-preset-env
async awaitbabel-preset-env
添加回答
举报
