简体   繁体   English

Babel 为 IE11 添加了不必要的 core-js polyfills

[英]Babel adding unnecessary core-js polyfills for IE11

In my app, I have configured Babel to add Core-JS polyfills, but it seems to be adding unnecessary polyfills.在我的应用程序中,我已将 Babel 配置为添加 Core-JS polyfill,但它似乎添加了不必要的 polyfill。

Im using browserlist > 1% and it's including require("core-js/modules/es.array.concat");我使用browserlist > 1%并且它包括require("core-js/modules/es.array.concat"); among other Core-JS imports that don't seem necessary.在其他似乎没有必要的 Core-JS 导入中。 I checked and it's because of IE11, but IE11 does support string concatenation with + , so this import doesn't seem necessary.我查了一下,这是因为 IE11,但 IE11 确实支持与+的字符串连接,所以这个导入似乎没有必要。

Is there a way to not allow adding these polyfills while still supporting at least IE11?有没有办法在至少支持 IE11 的同时不允许添加这些 polyfill?

Assuming you are using preset-env you can exclude them directly with an array of excluded modules.假设您使用的是 preset-env ,您可以使用一组排除模块直接排除它们。

    ...

    "targets" : "browserlist > 1%",
    "exclude": [
        "es.array.concat",
    ],

    ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM