Babel Config “strict mode”

折月煮酒 提交于 2019-12-10 10:53:34

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/34778980/babel-config-strict-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!