Babel Config“严格模式” [英] Babel Config "strict mode"

查看:554
本文介绍了Babel Config“严格模式”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我得到这个错误: SyntaxError:< FILENAME> 'with'in strict mode


(其中< FILENAME> code>是一个实际存在的文件名)

失败的行是> 130928 | with(locals || {}){(function(){
,并抱怨带有。请记住,这文件不在我的控制范围之内。



我的 .babelrc 文件具有此配置。

  {
compact:true,
plugins:[
transform-runtime,
未声明变量检查
],
预设:[
es2015,
stage-0
]
}

我使用babel 6,我知道一般意识是使用版本5,但没有运气

解决方案

不知道为什么这个问题还没有得到解答。



es2015预设(以及我的理解,每个babel预设)都会启用严格模式。请查看 MDN关于严格模式的文章,特别是标题部分简化变量使用。 在严格模式下是非法的。


For some strange reason I can't for the life of me compile "vendor" libraries with my build process.

Im getting this error: SyntaxError: <FILENAME> 'with' in strict mode.

(where <FILENAME> is an actual existing filename)

The line that's failing is > 130928 | with (locals || {}) { (function(){ and its complaining about that with. Bear in mind that this file is outside my control.

My .babelrc file has this config.

{
    "compact": true,
    "plugins": [
        "transform-runtime",
        "undeclared-variables-check"
    ],
    "presets": [
        "es2015",
        "stage-0"
    ]
}

I'm using babel 6, I know the general conscious is to use version 5, but no luck there either.

解决方案

Not sure why this hasn't been answered already.

The es2015 preset (and, to my understanding, every babel preset) enables strict mode. Check out MDN's article on strict mode, specifically the section with header "Simplifying variable uses". with is illegal in strict mode.

这篇关于Babel Config“严格模式”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆