Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what features does the babel polyfill support?

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.

like image 833
coding4fun Avatar asked Jul 18 '16 14:07

coding4fun


People also ask

What is the use of Babel polyfill?

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.

Does Babel have polyfill?

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 ).

Is Babel polyfill necessary?

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.

What is Babel loader used for?

babel-loader exposes a loader-builder utility that allows users to add custom handling of Babel's configuration for each file that it processes. .


1 Answers

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.

like image 126
coding4fun Avatar answered Oct 16 '22 23:10

coding4fun