【问题标题】:Babelify "use strict" issue with gulp and jsx使用 gulp 和 jsx 对“使用严格”问题进行 Babelify
【发布时间】:2016-02-23 07:53:23
【问题描述】:

我想从 gulp 制作的普通 js 中删除严格模式,即“使用严格”。

我试过了

browserify({
            debug: true,
            entries: ['src/Components/Main.jsx']
        })
        //.transform(["babelify",{presets: ["stage-0", "stage-1", "es2015", "react"],  blacklist: [ 'useStrict' ]}])
        .transform(babelify.configure({
          presets: ["stage-0", "stage-1", "es2015", "react", "transform-strict-mode"],
        }))
        .bundle()

但出现此错误

错误:找不到相对于目录的预设“transform-strict-mode”。我安装了它

npm install babel-plugin-transform-strict-mode

它安装在安装其他预设的同一目录中。

我也试过了

.transform(["babelify",{presets: ["stage-0", "stage-1", "es2015", "react"],  blacklist: [ 'useStrict' ]}])

但不工作..

谁能帮我解决这个问题。

我无法评论堆栈溢出。堆栈溢出不允许我在任何地方发表评论,所以我无法回复评论。

编辑:

.transform( 'babelify', {
  presets: [ 'stage-0', 'react', ],
  plugins: [ 'transform-strict-mode' ]
})

正在工作,但我想删除严格模式。所以我正在尝试这样的选项:

.transform(babelify.configure({
          presets: ["stage-0",  "react"],
          plugins: ["transform-strict-mode", {"strict": false}]
        }))

它给出了这个错误

Plugin 1 specified in "base" provided an invalid property of "strict" while parsing

【问题讨论】:

标签: reactjs gulp babeljs


【解决方案1】:

当它是插件时,您将其添加为预设

类似下面的东西应该可以解决它

.transform( 'babelify', {
  presets: [ 'stage-0', 'react', ],
  plugins: [ 'transform-strict-mode' ]
})

另外,您不需要包含 stage-1es2015 预设,它们包含在 stage-0 中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    相关资源
    最近更新 更多