{"id":19125,"library":"babel-plugin-polyfill-es-shims","title":"babel-plugin-polyfill-es-shims","description":"A Babel plugin that automatically injects imports for es-shims polyfills based on target environments. Version 0.10.11, stable release part of the babel-polyfills monorepo. Key differentiator: modular approach to polyfilling ECMAScript built-ins, compatible with `core-js` and custom shims. Integrates with `@babel/preset-env` and supports `useBuiltIns: 'usage'` style. Active development, follows Babel releases.","status":"active","version":"0.10.11","language":"javascript","source_language":"en","source_url":"https://github.com/babel/babel-polyfills","tags":["javascript","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-polyfill-es-shims","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-polyfill-es-shims","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-polyfill-es-shims","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core helper for configuring polyfill providers","package":"@babel/helper-define-polyfill-provider","optional":false}],"imports":[{"note":"CommonJS require works, but avoid .default in ESM contexts","wrong":"const plugin = require('babel-plugin-polyfill-es-shims').default","symbol":"default","correct":"import plugin from 'babel-plugin-polyfill-es-shims'"},{"note":"Only default export is available; named exports are not provided","wrong":"","symbol":"plugin as named export","correct":"import { default as plugin } from 'babel-plugin-polyfill-es-shims'"},{"note":"method 'usage' is deprecated; use 'usage-global' or 'usage-pure' since v0.10","wrong":"['polyfill-es-shims', { targets: { ie: '11' }, method: 'usage' }]","symbol":"insert parameters","correct":"['polyfill-es-shims', { targets: { ie: '11' }, method: 'usage-global' }]"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  presets: [\n    ['@babel/preset-env', {\n      targets: '> 0.25%, not dead',\n      useBuiltIns: false // Let the polyfill plugin handle it\n    }]\n  ],\n  plugins: [\n    ['babel-plugin-polyfill-es-shims', {\n      method: 'usage-global', // 'usage-pure' or 'usage-global'\n      targets: { browsers: '> 0.25%, not dead' },\n      shouldInjectPolyfill: (name) => name.startsWith('es.'), // Optional filter\n      exclude: ['es.array.iterator'] // Optional exclude specific polyfills\n    }]\n  ]\n};","lang":"javascript","description":"Configures Babel to inject imports for ES shims based on target browsers, using the usage-global method."},"warnings":[{"fix":"Use method: 'usage-global' or method: 'usage-pure'","message":"Deprecated method 'usage' replaced by 'usage-global' and 'usage-pure'","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Update @babel/core to latest 7.x or pre-release 8.x","message":"Requires @babel/core ^7.4.0 || ^8.0.0-0 <8.0.0","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Ensure @babel/preset-env is configured with `useBuiltIns: false` and plugin targets are aligned","message":"Polyfill injection may not work with custom targets if not using @babel/preset-env's built-in support","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Use `method: 'usage-global'` for global polyfills or ensure tree-shaking is configured correctly","message":"When using `method: 'usage-pure'`, imported polyfills are added as pure expressions and may affect tree-shaking","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Consider migrating to babel-plugin-polyfill-corejs3 for better maintenance and compatibility","message":"The `es-shims` package may not be actively maintained; users may prefer `core-js` via babel-plugin-polyfill-corejs3","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install babel-plugin-polyfill-es-shims --save-dev","cause":"Package not installed or not in node_modules","error":"Cannot find module 'babel-plugin-polyfill-es-shims'"},{"fix":"Change method to 'usage-global' or 'usage-pure' in plugin options","cause":"Using deprecated 'usage' method string","error":"Error: Invalid method. Expected one of: \"usage-global\", \"usage-pure\""},{"fix":"Ensure the needed polyfill is included in your es-shims dependency or use core-js polyfills with babel-plugin-polyfill-corejs3","cause":"The es-shims package does not include every ES shim; some are provided by other packages","error":"Polyfill \"es.string.trim\" is not available. Available polyfills: ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}