# Legacy build & compatibility guide (Vite / Webpack) Purpose - This document explains how to use legacy builds to improve compatibility with older browsers (for example older iOS / Safari) and when you should instead fix issues in source code. Key reminder - Some problems (notably RegExp engine-level syntax like lookbehind `(?= 11'], additionalLegacyPolyfills: ['regenerator-runtime/runtime'], renderLegacyChunks: true, }) ] }) ``` Notes - `targets` controls which transforms/polyfills are applied. Set to your minimum supported browsers. - `additionalLegacyPolyfills` injects runtime libraries into the legacy bundle. - `renderLegacyChunks` enables differential chunks served via `type="module"` / `nomodule`. - Important: plugin-legacy cannot rewrite engine-level RegExp syntax (lookbehind). Keep incompatible regex out of literal module scope or rewrite them. Webpack Webpack does not provide a single plugin equivalent to Vite's plugin-legacy. Common approach: build two bundles with Babel (modern + legacy) and serve them with `type="module"` / `nomodule`. Key deps: ```bash pnpm add -D @babel/core babel-loader @babel/preset-env core-js regenerator-runtime webpack webpack-cli ``` Example approach - Create a `babel.config.js` that supports `BABEL_ENV=legacy` to enable `useBuiltIns: 'usage'` and a legacy `targets` set. Run two webpack builds: one modern, one legacy. Serve modern bundle with `