Ship smaller legacy bundles with Babel preset-env useBuiltIns usage
Use @babel/preset-env with useBuiltIns: "usage" to have Babel inject only the core-js polyfills your code actually uses for the browsers you target, keeping legacy bundles smaller.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use @babel/preset-env with useBuiltIns: "usage" to have Babel inject only the core-js polyfills your code actually uses for the browsers you target, keeping legacy bundles smaller.
Hardcoded Babel targets either bloat your bundle or break old browsers. Here's how browserslist-driven preset-env config, core-js injection, and the debug flag turn transpilation into an auditable decision.
Learn how to set up Babel preset-env with useBuiltIns: usage to transpile ES2015+ code while injecting only the polyfills actually needed for your target browsers.
Learn how to configure Babel’s preset‑env with browserslist targets and core‑js ‘usage’ to inject only the polyfills you need, shrink bundle size, and keep legacy browser support.
If your Babel bundle still contains arrow functions even though you target modern browsers, this guide walks you through diagnosing the mismatch, checking config files, and applying the right fixes to get pure ES5 output.
Learn how to install and configure PostCSS Preset‑Env to automatically polyfill modern CSS based on a browserslist query, with a worked example and common pitfalls.
Learn how to use Babel's preset-env to include only the transforms needed for your target browsers and Node versions, reducing bundle size while keeping builds reproducible.
Polyfill Inclusion in Unspecified Environments Babel's @babel/preset-env utilizes the useBuiltIns option to manage core-js polyfills. When set to usage , Babel analyzes the code to include only the necessary polyfills based on the defined target environment. However, uncertainty arises when no specific target environment (such as a browserslist configuration
Goal For a low‑traffic application, the primary objective is to shrink the JavaScript bundle and speed up the build by eliminating polyfills and syntax transformations that are unnecessary for the browsers actually used. Constraints & Uncertainty The targets option in @babel/preset‑env is evaluated at compile time; any change requires a full rebuild. Cho