Is there any practical difference between using babel-runtime and the babel-polyfill when *not* developing a library? (e.g. web application)

后端 未结 1 348
耶瑟儿~
耶瑟儿~ 2020-12-24 13:11

It\'s all in the title, really.

In the Babel documentation, there is the following line on the page describing babel-runtime

Another purpose o

相关标签:
1条回答
  • 2020-12-24 13:39

    If you don't care about polluting global scope, the polyfill is the better option: the runtime does not work with instance methods such as [0, 1, 2].includes(1), while the polyfill will.

    The main difference between the two is that the polyfill pollutes global scope, and works with instance methods, while the runtime does not pollute global scope and does not work with instance methods.

    The polyfill also will not allow you to include two separate versions of itself into your code. This is only a problem if two separate polyfills are being required/imported somewhere in your code.

    0 讨论(0)
提交回复
热议问题