当我使用babel编译js时,config.js
var webpack = require('webpack');
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js');
module.exports = {
entry: {
Index: './index.js',
Test: './test.js'
},
output: {
path: __dirname,
filename: '[name].js' // Template based on keys in entry above
},
module: {
loaders: [
{
test: /\.js(x?)$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
},
plugins: [commonsPlugin]
};
我的条目js只是console.log(new Proxy());
,在chrome中会调用错误Uncaught ReferenceError: Proxy is not defined
。
我确定已编译js
,但为什么在编译babel后未定义Proxy
?
答案 0 :(得分:2)
答案 1 :(得分:1)
尝试实验节点模块babel-plugin-proxy
。
npm install babel-plugin-proxy --save-dev
注意:它不适合生产环境,因为性能影响很大。
<强>参考:强>
https://www.npmjs.com/package/babel-plugin-proxy
https://github.com/krzkaczor/babel-plugin-proxy