[英]Babelify “use strict” issue with gulp and jsx
I want to remove strict mode ie "use strict" from common js made by gulp. 我想从gulp制作的通用js中删除严格模式,即“使用严格”。
I tried 我试过了
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()
But getting this error 但是得到这个错误
Error: Couldn't find preset "transform-strict-mode" relative to directory. 错误:找不到相对于目录的预设“ transform-strict-mode”。 I installed it 我安装了
npm install babel-plugin-transform-strict-mode
and it is installed in the same directory where other preset is installed. 并将其安装在与安装其他预设相同的目录中。
I also tried 我也试过
.transform(["babelify",{presets: ["stage-0", "stage-1", "es2015", "react"], blacklist: [ 'useStrict' ]}])
But not working.. 但是不行
can anybody please help me with this. 有人可以帮我吗
I am unable to comment on stack overflow . 我无法评论堆栈溢出。 stack overflow is not letting me to comment anywhere so I will not able to reply in comment. 堆栈溢出不允许我在任何地方发表评论,因此我将无法在评论中回复。
Edit : 编辑:
.transform( 'babelify', {
presets: [ 'stage-0', 'react', ],
plugins: [ 'transform-strict-mode' ]
})
is working but I want to remove strict mode . 正在工作,但我想删除严格模式。 So I am trying it with options like this: 所以我正在尝试使用这样的选项:
.transform(babelify.configure({
presets: ["stage-0", "react"],
plugins: ["transform-strict-mode", {"strict": false}]
}))
and it is giving this error 它给出了这个错误
Plugin 1 specified in "base" provided an invalid property of "strict" while parsing
You're adding it as a preset when it is a plugin 当它是插件时,您要将其添加为预设
Something like the following should fix it 像下面这样的东西应该解决它
.transform( 'babelify', {
presets: [ 'stage-0', 'react', ],
plugins: [ 'transform-strict-mode' ]
})
Also, you dont need to include stage-1
and es2015
presets, they are included with stage-0
. 另外,您不需要包括stage-1
和es2015
预设,它们包含在stage-0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.