qiuyuntao
qiuyuntao

Reputation: 2394

When I use babel to compile js, Proxy is not defined

When I use babel to compile js, the 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]
};

My entry js is just console.log(new Proxy());, in chrome will call an error Uncaught ReferenceError: Proxy is not defined.

I'm sure js has been compiled, but why Proxy is not defined after babel compiling?

Upvotes: 4

Views: 2896

Answers (2)

Venkat.R
Venkat.R

Reputation: 7746

Try experimental Node Module babel-plugin-proxy.

npm install babel-plugin-proxy --save-dev

Note: It is not suitable for production environments because performance impact is huge.

Reference:
https://www.npmjs.com/package/babel-plugin-proxy
https://github.com/krzkaczor/babel-plugin-proxy

Upvotes: 1

rossipedia
rossipedia

Reputation: 59397

Proxies are currently unsupported by babeljs.

From their website:

Unsupported feature
Due to the limitations of ES5, Proxies cannot be transpiled or polyfilled. See support in various JavaScript engines.

Upvotes: 3

Related Questions