Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Babel includes polyfill 'core-js/modules/web.dom.iterable' to output if script contains forEach() method call. #9449
The only exception is calling forEach() for an array defined in the same visibility scope.
Also targeting Node instead of browsers omits that polyfill, which is obviously expected.
Babel Configuration (.babelrc, package.json, cli command)
Hey @zhaparoff! We really appreciate you taking the time to report an issue. The collaborators
You can use
Yes I can... Suddenly, this option works with built-ins as well as with plugins, although documentation says nothing about it... Thanks for pointing that.
Anyway, potential ability to control web-polyfills sepately from selected targets could be quite usefull as for me.
Well... Ideally, my configuration should be... no configuration at all. Suddenly, isn't it? ;-)
So, as I can imagine it, babel-typescript preset should use some plugin, which will be adding metadata to the transpiled code. It could be decorators or just comments in some fixed format, like webpack is using for example.
This metadata could be used by JS processing to optimize JS transpilation. Thus, if some parameter or method call will be marked as 'does not require polyfilling/shimming' it won't be affected by further transpilation.
Probably, these metadata descriptors can be documented and added manually to sorce JS code, for those developers who doesn't work with TS, but want to control babel transpilation more precisely.
In the final stage these metadata records can be cleaned out, to minify the output. Or left untouched for debugging purposes.
This is very highlevel, raw sketch - I'm not aware of any babel internal implementation, so can't even say if it's possible. Again, TypeScript support is new thing in Babel, so probably this is in the roadmap already. And I can't even imagine, how this could affect the performance...
But my opinion is that information defined by types should be kept until the end of transpilation flow and used during this process, as much as possible.
It's a very weird situation when there are several kilobytes of polyfills included in bundles for modern browsers if there is a