"modules:auto"有什么作用?在@ babel/preset-env字段中表示什么? [英] what does the "modules:auto" means in @babel/preset-env field?

查看:801
本文介绍了"modules:auto"有什么作用?在@ babel/preset-env字段中表示什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

babel文档说,模块的默认选项是auto,auto是什么意思?是否将导入"转换为需要"? "modules:false"和"modules:auto"之间有什么区别?看来它们是相同的结果;我正在学习摇树,当我没有为@ babel/preset-env设置任何选项时,摇树成功,当我设置"modules:false"时,摇树也成功;

the babel docs say the modules default option is auto, what does the auto means? does it transform the "import" to "require" or not? what's the difference between "modules: false" and "modules: auto"? it seems they are the same result; I'm learning tree shaking, when I didn't set any options to my @babel/preset-env, tree shaking success, when I set "modules: false", the tree shaking also succeed;

  "presets": [
    [
      "@babel/preset-react"
    ],
    [
      "@babel/preset-env",{"modules": "false"}
    ]
  ],

推荐答案

auto表示default valuemodules的默认值是false.参见- https://github.com/babel/babel/pull/8485/文件#r236086742 .

auto means default value and default value of modules is false. See - https://github.com/babel/babel/pull/8485/files#r236086742.

这篇关于"modules:auto"有什么作用?在@ babel/preset-env字段中表示什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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