{"id":21243,"library":"esbuild-plugin-es5","title":"esbuild-plugin-es5","description":"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.","status":"active","version":"2.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/noyobo/esbuild-plugin-es5","tags":["javascript","esbuild-plugin","esbuild","es5","typescript"],"install":[{"cmd":"npm install esbuild-plugin-es5","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-es5","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-es5","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin interfaces with esbuild's build system.","package":"esbuild","optional":true},{"reason":"Runtime helpers for ES5 transformation; must be installed separately.","package":"@swc/helpers","optional":false}],"imports":[{"note":"Package is ESM-first. If using CommonJS, use dynamic import or named require after transpilation.","wrong":"const es5Plugin = require('esbuild-plugin-es5').es5Plugin","symbol":"es5Plugin","correct":"import { es5Plugin } from 'esbuild-plugin-es5'"},{"note":"Es5Plugin is a TypeScript type for the plugin instance; not a runtime value.","wrong":"import { Es5Plugin } from 'esbuild-plugin-es5' (if used as value, not type)","symbol":"Es5Plugin","correct":"import type { Es5Plugin } from 'esbuild-plugin-es5'"},{"note":"SWCOptions is a possibly exported type; verify via your IDE.","wrong":"import { SWCOptions } from 'esbuild-plugin-es5' (same type-only caution)","symbol":"SWCOptions","correct":"import type { SWCOptions } from 'esbuild-plugin-es5'"}],"quickstart":{"code":"import { es5Plugin } from 'esbuild-plugin-es5';\nimport path from 'path';\n\nawait require('esbuild').build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/index.js',\n  plugins: [es5Plugin()],\n  target: ['es5'],\n  alias: {\n    '@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json')),\n  },\n});","lang":"typescript","description":"Shows how to configure esbuild with esbuild-plugin-es5: import plugin, set target to 'es5', and alias @swc/helpers for correct resolution."},"warnings":[{"fix":"Ensure @swc/core and @swc/helpers are updated to compatible versions.","message":"The package uses @swc/core which has major version changes; verify compatibility with peerdep esbuild.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Add alias as shown in Quickstart: '@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json'))","message":"Must set alias for @swc/helpers to relative path of @swc/helpers/package.json; otherwise SWC fails to resolve helpers at runtime.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `import { es5Plugin } from 'esbuild-plugin-es5'` instead of `import es5Plugin from ...`","message":"Version 2.x changed the default export to named export 'es5Plugin'. Old 'default' import breaks.","severity":"breaking","affected_versions":"2.0.0"},{"fix":"Provide `filter` option: `es5Plugin({ filter: /\\.m?[jt]sx?$/ })`","message":"Plugin only transforms code that passes the default filter (JS/TS extensions). If using custom extensions, must specify filter.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install via npm using 'esbuild-plugin-es5'.","message":"The package name in npm is 'esbuild-plugin-es5' but the repository and README may reference 'esbuild-build-es5' (typo).","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install @swc/helpers -D` and add the alias configuration shown in Quickstart.","cause":"@swc/helpers not installed or alias misconfigured.","error":"Cannot find module '@swc/helpers'"},{"fix":"Use `import { es5Plugin } from 'esbuild-plugin-es5'`.","cause":"Importing default instead of named export in version 2.x.","error":"TypeError: es5Plugin is not a function"},{"fix":"Update esbuild to latest stable version (>=0.14.0).","cause":"Outdated version of esbuild not compatible with plugin's return format.","error":"Error: The plugin 'es5Plugin' returned a 'name' property that is not a string."},{"fix":"These are non-blocking; suppress via esbuild's logLevel or logOverride.","cause":"SWC transform may produce warnings about 'this' outside functions.","error":"warnings: [ {\"text\":\"Top-level 'this' is replaced...\"} ]"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}