An esbuild plugin that uses @swc/core to transform JavaScript/TypeScript to ES5, enabling compatibility with older browsers and devices. Version 2.1.1 supports tree shaking, code sharing (async generators), source maps, custom swc options, and custom filter. It is a peer dependency of esbuild and requires @swc/helpers at runtime. Compared to alternatives like Babel-based plugins, it leverages the faster SWC transform, though it adds ~130ms overhead (e.g., three.js build from 50ms to 180ms). The plugin is actively maintained with TypeScript types included. Use in production builds only, as development can use esbuild's native targets for speed.
npm install esbuild-plugin-es5Verified import paths — ran on the pinned version, not inferred.
Shows how to configure esbuild with esbuild-plugin-es5: import plugin, set target to 'es5', and alias @swc/helpers for correct resolution.
Ensure @swc/core and @swc/helpers are updated to compatible versions.
Add alias as shown in Quickstart: '@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json'))Use `import { es5Plugin } from 'esbuild-plugin-es5'` instead of `import es5Plugin from ...`Provide `filter` option: `es5Plugin({ filter: /\.m?[jt]sx?$/ })`Install via npm using 'esbuild-plugin-es5'.
Run `npm install @swc/helpers -D` and add the alias configuration shown in Quickstart.
Use `import { es5Plugin } from 'esbuild-plugin-es5'`.Update esbuild to latest stable version (>=0.14.0).
These are non-blocking; suppress via esbuild's logLevel or logOverride.