@yohs/esbuild-utils
v0.2.7
Published
Reusable esbuild plugins, runners, and CLI helpers
Downloads
367
Readme
@yohs/esbuild-utils
Reusable esbuild helpers that make it easier to bootstrap local dev flows:
- Opinionated runners that keep long-lived processes in sync with esbuild outputs
- Quality-of-life plugins (clear console, custom logging, persistent spinner)
- Runtime-artifact helpers for bundled Node services that need generated deploy manifests
Quick start
pnpm add -D @yohs/esbuild-utilsimport { clearConsolePlugin, runFunctionsPlugin } from '@yohs/esbuild-utils'
export default {
plugins: [
clearConsolePlugin,
runFunctionsPlugin({
target: 'handler',
signatureType: 'cloudevent',
port: 5012,
}),
],
}ℹ️ Console / CLI helpers (
animation,args-serialize,run-npx) now live in@yohs/node-utilsand are no longer re-exported from this package. Import them directly from@yohs/node-utils/*if you still need them alongside these plugins.
⚠️ The
runFunctionsPlugindepends on@yohs/gcp-utilsfor its Functions Framework runner. Install it alongside this package when you need that plugin.
Available entry-points
@yohs/esbuild-utils– re-exports everything in this package@yohs/esbuild-utils/plugins– bundled access to every plugin helper
Runtime artifact helpers
Bundled Node services often need a deploy artifact whose package.json is narrower than the source package manifest. The runtime-artifact helpers support that shape:
- registry dependencies are externalized and copied into the generated deploy manifest;
workspace:*dependencies are treated as source dependencies and bundled;- registry dependencies discovered from bundled workspace importers are added to the deploy manifest from the importer package's own dependency spec;
- undeclared third-party bare imports fail during esbuild resolution.
import { createRuntimeDependencyBoundaryContext, deployPackageManifestPlugin, readPackageJson, runtimeDependencyBoundaryPlugin } from '@yohs/esbuild-utils/plugins'
const packageJson = await readPackageJson('package.json')
const boundary = createRuntimeDependencyBoundaryContext({
workspaceRootPath: process.cwd(),
packageJson,
internalPackageScopes: ['@muse'],
errorPackageJsonPath: 'services/my-service/package.json',
})
export default {
entryPoints: ['src/main.ts'],
bundle: true,
platform: 'node',
format: 'esm',
outfile: '.build/main.js',
plugins: [
runtimeDependencyBoundaryPlugin(boundary),
deployPackageManifestPlugin({
outputPath: '.build/package.json',
packageJson,
runtimeDependencies: boundary.runtimeDependencies,
main: 'main.js',
}),
],
}Scripts
pnpm build– emits ESM modules and d.ts files via tsdownpnpm test– runs the vitest suitepnpm lint/pnpm typecheck– local validation helpers
