Babel 6对JSX变换器做出反应 - 禁用严格 [英] Babel 6 react JSX transformer - disable strict

查看:195
本文介绍了Babel 6对JSX变换器做出反应 - 禁用严格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用babel 6进行反应JSX转换。但是我没有使用反应预设,我只使用'transform-react-jsx'插件(并尝试严格模式禁用选项),这是我的.babelrc

I'm using babel 6 for react JSX transforms. However I'm not using the react preset, I am ONLY using the 'transform-react-jsx' plugin (and trying strict-mode disable option), here is my .babelrc

{
  "plugins": [
    ["transform-react-jsx"]
  ],
  "sourceMaps": true,
  "strictMode": false
}

但是我需要第三方使用'with'(我的控制之外)发出以下错误的javascript:
[SyntaxError:foo.js:'在严格模式下'..'

However I have required a thirdparty javascript that uses 'with' (out of my control) which emits following error: [SyntaxError: foo.js: 'with' in strict mode .. ]

所以我需要禁用严格模式,这与此问题相同,但我是不使用es6 / es2015的东西,只有jsx转换。

So I need to disable strict mode, This is same problem as this issue however I am NOT using es6/es2015 stuff, only jsx transforms.

对于babel 6,没有黑名单,我只指定了一个插件,所以我怀疑没有办法禁用。

With babel 6 there is no blacklist and I've only specified ONE plugin, so I'm suspect there is no way to disable.

推荐答案

根据这一行,确实解析了 strictMode 选项。

According to this line, the strictMode option is indeed parsed.

我不明白你用于。为什么是数组?

I don't understand the syntax you used for your .babelrc, though. Why an array?

试试这个:

{
  "plugins": [
    ["transform-react-jsx"]
  ],
  "sourceMaps": true,
  "strictMode": false
}

这篇关于Babel 6对JSX变换器做出反应 - 禁用严格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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