babel里@babel/plugin-transform-runtime没什么效果?

源代码:

let promise = new Promise(function (resolve,reject) {
    setTimeout(()=>{resolve()},1000)
})
Array.from(new Set([1, 2, 3, 2, 1])); 
[1, 2, NaN, 3, 4].findIndex(isNaN);  

先用下面的.babelrc

{
    "presets": [
        
        ["@babel/env",{
            "targets": {
              "chrome": "58",
              "ie": "10"
            },
            "useBuiltIns": "usage",
          }]
        
      ],
    "plugins": []
}

生成下面代码

"use strict";

require("core-js/modules/es6.array.find-index");

require("core-js/modules/web.dom.iterable");

require("core-js/modules/es6.array.iterator");

require("core-js/modules/es6.set");

require("core-js/modules/es6.string.iterator");

require("core-js/modules/es6.array.from");

require("core-js/modules/es6.promise");

require("core-js/modules/es6.object.to-string");

var promise = new Promise(function (resolve, reject) {
  setTimeout(function () {
    resolve();
  }, 1000);
});
Array.from(new Set([1, 2, 3, 2, 1]));
[1, 2, NaN, 3, 4].findIndex(isNaN);

然后我在plugins里面加了@babel/plugin-transform-runtime


{
    "presets": [
        
        ["@babel/env",{
            "targets": {
              "chrome": "58",
              "ie": "10"
            },
            "useBuiltIns": "usage",
          }]
        
      ],
    "plugins": [
         "@babel/plugin-transform-runtime"
      ]
}
但是最后生成的代码还是和之前一模一样的,这是咋回事呀
阅读 4k
2 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏