{"id":25370,"library":"esbuild-plugin-merge","title":"esbuild-plugin-merge","description":"Merge esbuild plugins and provide Rollup-like features (watchChange, transform, enforce, pre). Current stable version 1.0.7. No active maintenance; incompatible with esbuild >=0.17. Designed for projects that need plugin ordering (enforce), transform hooks similar to Rollup/Vite, and watch updates. Key differentiator: adds `onTransform` and `onUpdate` hooks to esbuild's standard onResolve/onLoad.","status":"deprecated","version":"1.0.7","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install esbuild-plugin-merge","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-merge","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-merge","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency. Only works with esbuild <0.17.0. Not compatible with esbuild 0.17+ due to breaking changes in plugin API.","package":"esbuild","optional":false}],"imports":[{"note":"ESM-only; does not support CommonJS require.","wrong":"const { merge } = require('esbuild-plugin-merge')","symbol":"merge","correct":"import { merge } from 'esbuild-plugin-merge'"},{"note":"pre wraps a standard esbuild plugin to add sorting support.","wrong":"const pre = require('esbuild-plugin-merge').pre","symbol":"pre","correct":"import { pre } from 'esbuild-plugin-merge'"},{"note":"ProPlugin is a TypeScript type, not a runtime value. Use type import.","wrong":"import { ProPlugin } from 'esbuild-plugin-merge'","symbol":"ProPlugin","correct":"import type { ProPlugin } from 'esbuild-plugin-merge'"}],"quickstart":{"code":"import { merge, pre, ProPlugin } from 'esbuild-plugin-merge';\nimport * as esbuild from 'esbuild';\n\nconst pluginA: ProPlugin = {\n  name: 'pluginA',\n  enforce: 'post',\n  setup(build) {\n    build.onTransform({ filter: /\\.css/ }, (loadres, args) => {\n      // transform hook like Rollup\n      loadres.code = loadres.code.replace(/\\/\\*.*?\\*\\//g, '');\n      return loadres;\n    });\n  },\n};\n\nconst pluginB: esbuild.Plugin = {\n  name: 'pluginB',\n  setup(build) {\n    build.onResolve({ filter: /\\.svg/ }, (args) => ({ path: args.path }));\n  },\n};\n\nasync function main() {\n  const result = await esbuild.build({\n    entryPoints: ['src/index.ts'],\n    bundle: true,\n    outfile: 'dist/out.js',\n    plugins: [merge([pluginA, pre(pluginB)])],\n  });\n  console.log('Build succeeded');\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows how to use merge() to combine plugins, pre() for ordering, and ProPlugin for transform hook."},"warnings":[{"fix":"Downgrade esbuild to 0.16.x or switch to another plugin merging approach.","message":"Incompatible with esbuild >=0.17.0. The plugin API changed; `onTransform` and `onUpdate` rely on removed internal hooks.","severity":"breaking","affected_versions":"<0.17.0"},{"fix":"Only use `pre()` on esbuild.Plugin objects, not on ProPlugin.","message":"`pre` wrapper expects a standard esbuild Plugin, not a ProPlugin. Wrapping a ProPlugin with `pre` may cause unexpected behavior.","severity":"gotcha","affected_versions":"*"},{"fix":"Do not return a new object from onTransform; mutate `loadres` directly.","message":"`onTransform` returns undefined; the returned object from the hook is ignored. Mutation of `loadres` is the intended use.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider using esbuild's native plugin capabilities or other community plugins.","message":"Package is unmaintained. Last update 2022. No support for esbuild 0.17+ or later.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install esbuild-plugin-merge","cause":"Package not installed or not installed in the project.","error":"Error: Cannot find module 'esbuild-plugin-merge'"},{"fix":"Use `import { merge } from 'esbuild-plugin-merge'` in an ESM context.","cause":"Using CommonJS require() instead of ESM import.","error":"TypeError: merge is not a function"},{"fix":"Downgrade esbuild to 0.16.x or use alternative plugin.","cause":"esbuild version >=0.17.0; hooks removed.","error":"Error: Build failed with 1 error: error: Invalid plugin: onTransform or onUpdate hooks are not supported in esbuild >= 0.17.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}