Registry / web-framework / complugin

complugin

JSON →
library1.1.4jsnpmunverified

Unified plugin system for multiple bundlers (Rollup, Vite, Webpack, esbuild) using a common plugin API based on Rollup's hook model. Current stable version 1.1.4. Allows writing one plugin that works across bundlers with bundler-specific adapters. Key differentiator: developers maintain one codebase instead of separate plugins per tool. Ships TypeScript types. Peer dependencies include specific versions of each bundler. Release cadence is irregular; last update August 2022. Note: esbuild requires proxyEsbuild wrapper; Webpack must avoid thread-loader; Rollup disallows as output plugin.

npm install complugin
INSTALL
IMPORT
SIG · COMPLUGIN
C
complugin
web-frameworkjavascriptv1.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

createComplugin
✓ import { createComplugin } from 'complugin'
✗ const { createComplugin } = require('complugin')
ESM-only; no default export, named import required. TypeScript types included.
proxyEsbuild
✓ import { proxyEsbuild } from 'complugin'
✗ import proxyEsbuild from 'complugin'
Named export; required for esbuild integration when using esbuild plugin.
default export from plugin
✓ import MyPlugin from './my-plugin'; MyPlugin.vite(options);
✗ const MyPlugin = require('./my-plugin').default;
Plugins created with createComplugin export a function that returns an object with .vite, .rollup, .webpack, .esbuild methods. In Webpack CJS, use .default.

Creates a simple transform plugin that prepends a prefix to JS files, then uses it in Rollup.

import { createComplugin } from 'complugin' const myPlugin = createComplugin<{ prefix?: string }>({ name: 'my-plugin', factory(options, meta) { return { transform(code, id) { if (!id.endsWith('.js')) return null return { code: `${options.prefix || ''}${code}`, map: null } } } } }) // Rollup usage import { rollup } from 'rollup' const bundle = await rollup({ input: 'src/index.js', plugins: [myPlugin.rollup({ prefix: '// prepended\n' })] })
Debug
Known issues
breakingIn Webpack, thread-loader is incompatible with complugin. Do not use thread-loader in the same compilation.
fix
Remove thread-loader from webpack configuration or avoid using it with complugin plugins.
affects: >=1.0.0
breakingIn Rollup, complugin cannot be used as an output plugin. Only input plugins are supported.
fix
Place the plugin in the plugins array of the input options, not in output.plugins.
affects: >=1.0.0
breakingIn esbuild, you must proxy esbuild via proxyEsbuild(originalEsbuild) before using complugin plugins. Using original esbuild.build() will not apply the plugins.
fix
const esbuild = proxyEsbuild(require('esbuild')); esbuild.build({ plugins: [...] })
affects: >=1.0.0
gotchaPlugin functions created by createComplugin return an object with bundler-specific methods (.vite, .rollup, .webpack, .esbuild). They are not directly passable as plugins without calling the method.
fix
Always call the appropriate method: myPlugin.vite(options) or myPlugin(options).vite
affects: >=1.0.0
Errors
Common errors & fixes
Error: [complugin] proxyEsbuild must be called before esbuild.build
Using esbuild.build() directly without calling proxyEsbuild first.
fix
Import and call proxyEsbuild: import { proxyEsbuild } from 'complugin'; const esbuild = proxyEsbuild(originalEsbuild); esbuild.build({ plugins: [...] })
TypeError: myPlugin.vite is not a function
Importing the plugin incorrectly (e.g., missing .default or using wrong import style).
fix
Use named import of the exported function and call it with options: import myPlugin from './my-plugin'; myPlugin.vite({...})
Module parse failed: Unexpected token (1:0) in webpack with thread-loader
Using thread-loader in Webpack together with complugin causes parsing errors.
fix
Remove thread-loader from webpack configuration.
Upgrade
Version history
1.1.4latest on npm
Audit
Dependencies
esbuildoptionalpeer dependency – required for esbuild integration (^0.14.44)
rollupoptionalpeer dependency – required for Rollup integration (^2.50.0)
viteoptionalpeer dependency – required for Vite integration (^2.3.0 || ^3.0.0-0)
webpackoptionalpeer dependency – required for Webpack integration (4 || 5)
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
complugin — npm install complugin · libregistry