Skip to content
Search

@babel/polyfill

lastmod 2022-04-07created 2022-04-063 edits

Using Babel does not mean you can use the latest JavaScript functions. Early on, I trusted babel alone, used the latest functions, and was confused to see them not work in the browser. babel only transforms syntax. A polyfill, when the program first starts, checks for functions the current browser does not support and attaches them to the prototype of each object. In other words, babel runs at compile time and babel-polyfill runs at run time.

So, to use the objects and methods newly added in ES6+ even in old browsers, you need to add @babel/polyfill as a runtime dependency.

WARNING

However... it has been deprecated since Babel 7.4.0.

Deprecated issue

$ npm install @babel/polyfill
npm WARN deprecated @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.

Install

yarn add @babel/polyfill

See also

Favorite site

author Zer0 sitemap