Esbuild plugin (v0.2.3, 2024) that allows applying custom transformation hooks to build outputs or dependencies, not just sources. Solves gaps in esbuild's native support for polyfill injection, dynamic banners, and importable helpers. Compared to alternatives (e.g., onEnd hooks or manual post-processing), it provides a declarative hook-based API with pattern matching and rename support. Requires esbuild >=0.19.0. Ships TypeScript types. Note: still in PoC status; API may change.
npm install esbuild-plugin-transform-hookNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use the plugin to replace console.log with console.error in TypeScript files during the load phase.
Pin to exact version in package.json and test upgrades carefully.
Upgrade esbuild to >=0.19.0.
Stick to 'load' or 'end' until documentation states otherwise.
Install with `npm install esbuild-plugin-transform-hook` and use `import` instead of `require`.
Use `import { transformHookPlugin } from 'esbuild-plugin-transform-hook'` and ensure your project is configured for ESM.Run `npm install esbuild@latest` to upgrade esbuild to >=0.19.0.