babel 7-如何防止添加“严格模式" [英] babel 7 - how to prevent adding of "strict mode"

查看:201
本文介绍了babel 7-如何防止添加“严格模式"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了很多帖子,但仍然无法使它起作用:(

I looked at many posts but still cannot get this to work :(

我有.babelrc

I have .babelrc

{
  "comments": false,
  "presets": [
    ["@babel/env", {
      "targets": {
        "browsers": ["ios 7"]
      }
    }],
    ["minify"]
  ]
}

我想告诉babel (在任何地方)添加"use strict"

I want to tell babel to not add "use strict" (anywhere)

这是怎么做的?

推荐答案

Babel默认情况下假设要转换的文件是ES模块.由于情况并非如此,因此,您需要说明这一点.您可以签出 "sourceType"选项的文档,但实际上您想添加:

Babel assumes by default that files being transformed are ES modules. Since that is not the case for you, you'll want to tell it that. You can check out the docs for the "sourceType" option, but essentially you want to add:

"sourceType": "script"

在您的Babel选项中.

in your Babel options.

这篇关于babel 7-如何防止添加“严格模式"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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