Is there any type of list of what features the babel-polyfill supports? We just started using babel and i'm wondering if some of the dependencies we currently rely on can be eliminated like es6-promises
& whatwg-fetch
. If babel-polyfill
supported promises of course there would be no need to include es6-promises
.
Babel Polyfill adds support to the web browsers for features, which are not available. Babel compiles the code from recent ecma version to the one, which we want. It changes the syntax as per the preset, but cannot do anything for the objects or methods used.
Babel includes a polyfill that includes a custom regenerator runtime and core-js. This will emulate a full ES2015+ environment (no < Stage 4 proposals) and is intended to be used in an application rather than a library/tool. (this polyfill is automatically loaded when using babel-node ).
So long story short, just using babel is not enough for your application to work because all the latest Javascript features are not supported in all browsers. So to fix this problem, we need to use a polyfill.
babel-loader exposes a loader-builder utility that allows users to add custom handling of Babel's configuration for each file that it processes. .
I think after some research i figured it out. Babel-Polyfill is pretty much core.js + Regenerator Runtime . Look at those projects individually to see what features will be polyfilled. For example, at the time of this writing core.js:
Fetch:
window.fetch is not a cross-platform feature, in some environments it makes no sense. For this reason, I don't think it should be in core-js. Looking at a large number of requests it may be added in the future. Now you can use, for example, this polyfill.
Promises:
Modular standard library for JavaScript. Includes polyfills for ECMAScript 5, ECMAScript 6: promises, symbols, collections, iterators, typed arrays, ECMAScript 7+ proposals, setImmediate, etc.
So i need whatwg-fetch
but i don't need es6-promises
. Tested in IE11 (which doesn't have promises) so it appears to be working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With