Registry / devops / esbuild-plugin-es5

esbuild-plugin-es5

JSON →
library2.1.1jsnpmunverified

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-es5
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-ES5
E
esbuild-plugin-es5
devopsjavascriptv2.1.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

es5Plugin
✓ import { es5Plugin } from 'esbuild-plugin-es5'
✗ const es5Plugin = require('esbuild-plugin-es5').es5Plugin
Package is ESM-first. If using CommonJS, use dynamic import or named require after transpilation.
Es5Plugin
✓ import type { Es5Plugin } from 'esbuild-plugin-es5'
✗ import { Es5Plugin } from 'esbuild-plugin-es5' (if used as value, not type)
Es5Plugin is a TypeScript type for the plugin instance; not a runtime value.
SWCOptions
✓ import type { SWCOptions } from 'esbuild-plugin-es5'
✗ import { SWCOptions } from 'esbuild-plugin-es5' (same type-only caution)
SWCOptions is a possibly exported type; verify via your IDE.

Shows how to configure esbuild with esbuild-plugin-es5: import plugin, set target to 'es5', and alias @swc/helpers for correct resolution.

import { es5Plugin } from 'esbuild-plugin-es5'; import path from 'path'; await require('esbuild').build({ entryPoints: ['src/index.ts'], bundle: true, outfile: 'dist/index.js', plugins: [es5Plugin()], target: ['es5'], alias: { '@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json')), }, });
Debug
Known issues
deprecatedThe package uses @swc/core which has major version changes; verify compatibility with peerdep esbuild.
fix
Ensure @swc/core and @swc/helpers are updated to compatible versions.
affects: >=2.0.0
gotchaMust set alias for @swc/helpers to relative path of @swc/helpers/package.json; otherwise SWC fails to resolve helpers at runtime.
fix
Add alias as shown in Quickstart: '@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json'))
affects: >=1.0.0
breakingVersion 2.x changed the default export to named export 'es5Plugin'. Old 'default' import breaks.
fix
Use `import { es5Plugin } from 'esbuild-plugin-es5'` instead of `import es5Plugin from ...`
affects: 2.0.0
gotchaPlugin only transforms code that passes the default filter (JS/TS extensions). If using custom extensions, must specify filter.
fix
Provide `filter` option: `es5Plugin({ filter: /\.m?[jt]sx?$/ })`
affects: >=1.0.0
deprecatedThe package name in npm is 'esbuild-plugin-es5' but the repository and README may reference 'esbuild-build-es5' (typo).
fix
Install via npm using 'esbuild-plugin-es5'.
affects: all
Errors
Common errors & fixes
Cannot find module '@swc/helpers'
@swc/helpers not installed or alias misconfigured.
fix
Run `npm install @swc/helpers -D` and add the alias configuration shown in Quickstart.
TypeError: es5Plugin is not a function
Importing default instead of named export in version 2.x.
fix
Use `import { es5Plugin } from 'esbuild-plugin-es5'`.
Error: The plugin 'es5Plugin' returned a 'name' property that is not a string.
Outdated version of esbuild not compatible with plugin's return format.
fix
Update esbuild to latest stable version (>=0.14.0).
warnings: [ {"text":"Top-level 'this' is replaced..."} ]
SWC transform may produce warnings about 'this' outside functions.
fix
These are non-blocking; suppress via esbuild's logLevel or logOverride.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
esbuildoptionalPeer dependency; plugin interfaces with esbuild's build system.
@swc/helpersrequiredRuntime helpers for ES5 transformation; must be installed separately.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
esbuild-plugin-es5 — npm install esbuild-plugin-es5 · libregistry