Registry / devops / esbuild-plugin-transform

esbuild-plugin-transform

JSON →
library0.5.0jsnpmunverified

A plugin for esbuild that enables piping through transformation plugins, compatible with existing esbuild plugins. Version 0.5.0 is current, released in early 2024. It addresses a gap in esbuild's plugin system (issue #1902) by allowing chaining of transforms similar to pipe operations. Key differentiator from alternatives like esbuild-plugin-pipe is TypeScript support and simpler API. Requires Node >=16.14.0. Active development with weekly releases.

npm install esbuild-plugin-transform
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-TRA
E
esbuild-plugin-transform
devopsjavascriptv0.5.0
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.

Transform
import { Transform } from 'esbuild-plugin-transform'
const Transform = require('esbuild-plugin-transform')
ESM-only. CommonJS require is not supported.
Transform
import Transform from 'esbuild-plugin-transform'
import { default as Transform } from 'esbuild-plugin-transform'
Default export is the same as named export; both work but named is preferred.
type TransformOptions
import type { TransformOptions } from 'esbuild-plugin-transform'
TypeScript users should use type import for options type.

Demonstrates using the Transform plugin to wrap an esbuild plugin that logs each transformed file.

import { build } from 'esbuild' import { Transform } from 'esbuild-plugin-transform' build({ entryPoints: ['src/index.ts'], bundle: true, outfile: 'dist/index.js', plugins: [ Transform({ plugins: [ { name: 'log-transform', setup(build) { build.onLoad({ filter: /\.ts$/ }, async (args) => { console.log('Transforming:', args.path) return undefined }) }, }, ], }), ], }).catch(() => process.exit(1))
Debug
Known issues
breakingThe plugin only supports ESM imports. Using require() will fail with 'ERR_REQUIRE_ESM'.
fix
Use import statements or dynamic import('/path/to/package').
affects: >=0.1.0
breakingesbuild must be installed as a dependency with version ^0.17.0 or higher.
fix
Install esbuild: npm install esbuild@^0.17.0
affects: >=0.3.0
gotchaThe Transform callback receives an options object, not individual arguments. Using old signature will cause undefined errors.
fix
Use Transform({ plugins: [...] }) not Transform(plugins).
affects: >=0.5.0
gotchaPlugins inside Transform must have `setup` function; others will be silently ignored.
fix
Ensure each plugin object has a setup method.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'esbuild-plugin-transform'
Package not installed or missing from node_modules.
fix
Run npm install esbuild-plugin-transform
Transform is not a function
Using default import in CommonJS context.
fix
Use import { Transform } from 'esbuild-plugin-transform' instead of require.
TypeError: Cannot destructure property 'plugins' of 'undefined' or 'null'
Calling Transform() without arguments or with incorrect signature.
fix
Use Transform({ plugins: [] }) with an object containing plugins array.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency; esbuild is required for the plugin to work.
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-transform — npm install esbuild-plugin-transform · libregistry