Registry / devops / esbuild-utils

esbuild-utils

JSON →
library1.0.0-next.9jsnpmunverified

esbuild-utils is a utility library providing plugins and helpers for esbuild, currently at v1.0.0-next.9. It includes fixClassNamesPlugin (converts class expressions to declarations and strips @internal comments), livereloadServerPlugin (WebSocket-based live reload), esbuildRunPlugin (nodemon-like process runner), and a logTime helper for timing builds. The package ships TypeScript types and offers a frontend subpath import for live reload on the client. It is designed for Node.js and browser projects using esbuild. Being in pre-release, APIs are subject to change; notably, fixClassNamesPlugin does not support source maps and uses fs for output rewriting, which may change in future versions.

npm install esbuild-utils
INSTALL
IMPORT
SIG · ESBUILD-UTILS
E
esbuild-utils
devopsjavascriptv1.0.0-next.9
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.

fixClassNamesPlugin
import { fixClassNamesPlugin } from 'esbuild-utils'
const { fixClassNamesPlugin } = require('esbuild-utils')
ESM-only; CommonJS require not supported.
livereloadServerPlugin
import { livereloadServerPlugin } from 'esbuild-utils'
import livereloadServerPlugin from 'esbuild-utils'
Named export, not default.
setupWSLiveReload
import { setupWSLiveReload } from 'esbuild-utils/frontend'
import { setupWSLiveReload } from 'esbuild-utils'
Frontend helper is in a subpath export; not available from main entry.
esbuildRunPlugin
import { esbuildRunPlugin } from 'esbuild-utils'
Named export; accepts an options object with active, cmd, env, onexit.
logTime
import { logTime } from 'esbuild-utils'
Named export; async utility wrapping esbuild build timing.

Shows usage of fixClassNamesPlugin, livereloadServerPlugin, and frontend live reload setup with esbuild.

import { fixClassNamesPlugin, livereloadServerPlugin, setupWSLiveReload } from 'esbuild-utils'; import esbuild from 'esbuild'; // Build with plugins await esbuild.build({ entryPoints: ['./src/index.ts'], bundle: true, outfile: 'dist/index.js', format: 'esm', plugins: [ fixClassNamesPlugin(), livereloadServerPlugin(true, 'ts files', 35000), ], }); // In frontend code (only in dev) if (process.env.NODE_ENV === 'development') { setupWSLiveReload(35000, location.hostname, 'ws', 10); }
Debug
Known issues
breakingfixClassNamesPlugin does not generate source maps; disabled automatically if sourceMap is present.
fix
Avoid using sourceMap with fixClassNamesPlugin, or manually remap after build.
affects: >=1.0.0-next.1
deprecatedThe plugin uses fs to rewrite output files; future versions may change integration with esbuild.
fix
Monitor releases; no action needed yet.
affects: >=1.0.0-next.1
gotchalivereloadServerPlugin does not import ws when not activated; but if multiple instances share same port, they share same WebSocket server.
fix
Ensure port conflicts are avoided or managed.
affects: >=1.0.0-next.1
gotchaesbuildRunPlugin uses child_process.spawn; ensure the command path is correct and that onexit properly closes processes.
fix
Use absolute paths or ensure command is in PATH; implement proper cleanup in onexit.
affects: >=1.0.0-next.1
deprecatedPackage is in pre-release (next.9); breaking changes may occur without major version bump.
fix
Pin exact version in package.json.
affects: >=1.0.0-next.0
Errors
Common errors & fixes
Cannot find module 'esbuild-utils/frontend'
Missing subpath export or wrong import path. The frontend entry is a separate export.
fix
Use correct import: import { setupWSLiveReload } from 'esbuild-utils/frontend';
Module not found: Error: Can't resolve 'ws'
ws is an optional dependency but is not installed. Required when livereloadServerPlugin is active.
fix
Run npm install ws, or ensure the plugin is disabled when not in use.
TypeError: fixClassNamesPlugin is not a function
Incorrect import style; likely tried default import instead of named import.
fix
Use import { fixClassNamesPlugin } from 'esbuild-utils';
Error: [esbuild] Build failed with 1 error: sourceMap is not supported with fixClassNamesPlugin
sourceMap option enabled while using fixClassNamesPlugin.
fix
Disable sourceMap or remove fixClassNamesPlugin.
Upgrade
Version history
1.0.0-next.9latest on npm
Audit
Dependencies
wsoptionalWebSocket server for livereload plugin
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-utils — npm install esbuild-utils · libregistry