Babel Config “strict mode”

2019-05-28 17:03发布

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条回答
神经病院院长
2楼-- · 2019-05-28 17:33

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.

查看更多
登录 后发表回答