我安装了 babel-preset-0 并将其包含在.babelrc
文件中,我还安装了transform-runtime
,请参阅下面的文件,但 对于 循环代码在编译时抛出错误
码
var mySet = new Set();
mySet.add(1);
mySet.add(5);
mySet.add("some text");
var myArr = [v for (v of mySet)];// throws error
Webpack.config.js
loaders: [
{ test: path.join(__dirname, 'es6'),
loader: 'babel-loader' ,
// Options to configure babel with
query: {
plugins: ['transform-runtime'],
presets: ['es2015', 'stage-0'],
cacheDirectory: true,
plugins: [
'transform-runtime',
'transform-decorators-legacy',
],
},
exclude: [
path.resolve(__dirname, "node_modules"),
]
},
.babelrc
{
"presets": ["es2015", "stage-0"],
"plugins": ["transform-decorators-legacy"]
}