Registry / devops / esbuild-extra

esbuild-extra

JSON →
library0.4.2jsnpmunverified

A lightweight utility library (0.4.2) that extends esbuild plugins with onTransform, onResolved, load, emitChunk, emitFile, and resolveLocallyFirst features. It is ~6x smaller than @chialab/esbuild-rna and provides TypeScript types. Key differentiators: cooperative onTransform with sourcemap support, namespace-aware hook ordering, and minimal footprint. Suitable for plugin authors wanting extra build hooks without heavy dependencies. Compatible with esbuild >=0.15. Version 0.4 released 2023.

npm install esbuild-extra
INSTALL
IMPORT
SIG · ESBUILD-EXTRA
E
esbuild-extra
devopsjavascriptv0.4.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

wrapPlugins
import { wrapPlugins } from 'esbuild-extra'
import wrapPlugins from 'esbuild-extra'
wrapPlugins is a named export, not default.
getBuildExtensions
import { getBuildExtensions } from 'esbuild-extra'
const { getBuildExtensions } = require('esbuild-extra')
CommonJS require works but TypeScript may need esModuleInterop.
Types PluginBuild extensions
import 'esbuild-extra/global'
import { global } from 'esbuild-extra'
Side-effect import in .d.ts file to augment PluginBuild types; no need to import from package.

Shows how to use wrapPlugins to enable extended features for all plugins.

import { wrapPlugins } from 'esbuild-extra'; import * as esbuild from 'esbuild'; async function build() { let plugins = []; // your plugins let options = { entryPoints: ['app.ts'], bundle: true, outdir: 'dist', plugins: plugins, }; options = wrapPlugins(options); await esbuild.build(options); } build().catch(console.error);
Debug
Known issues
gotchaonTransform hooks apply to files matching loaders or extensions, and ordering matters. Hooks for specific extensions (e.g., .tsx) run before general ones (e.g., .js).
fix
Define hooks with most specific extension first, or use namespace to limit scope.
affects: >=0.1
gotchagetBuildExtensions must be called with a unique namespace string per plugin; using the same namespace for multiple plugins can cause conflicts.
fix
Pass a unique name (e.g., plugin name) as second argument to getBuildExtensions.
affects: >=0.1
breakingIn esbuild-extra <0.4, onTransform hooks were not applied to .jsx/.ts files after transpilation. Version 0.4 added automatic extension propagation.
fix
Update to >=0.4 or manually handle extension chains.
affects: <0.4
Errors
Common errors & fixes
Error: No matching export for import "wrapPlugins" from "esbuild-extra"
Using default import style on a named export.
fix
Use { wrapPlugins } in the import statement.
TypeError: getBuildExtensions is not a function
Possibly importing wrong symbol or using old version that didn't export it (added in 0.3).
fix
Check version: run 'npm ls esbuild-extra' and upgrade if <0.3. Use named import: import { getBuildExtensions } from 'esbuild-extra'.
Cannot find module 'esbuild-extra/global' or its corresponding type declarations.
The ambient module augmentation file is not included in tsconfig or the path is wrong.
fix
Ensure your tsconfig includes esbuild-extra types. If not, add 'esbuild-extra' to types array or install @types/esbuild-extra (though it ships its own).
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency; required to use the plugin extensions.
Agent activity
8 hits · last 30 days
node
8
Resources