Esbuild Plugin

Purpose

Bundles JavaScript from src/js/app.js into dist/output.js?v=7e5120dfbaf9 using esbuild. Supports minification, source maps, and dead code elimination.

Location

  • Package: @shevky/plugin-esbuild
  • Main: plugin-esbuild/main.js
  • Runtime name: shevky-esbuild

Lifecycle Hooks

HookImplemented
assets:copy

How It Works

During assets:copy:

  1. Resolves source ({root}/src/js/app.js) and output ({root}/dist/output.js?v=7e5120dfbaf9) paths.
  2. Checks source file exists (warns and skips if missing).
  3. Constructs esbuild args: --bundle --format=esm --target=es2018.
  4. When build.minify is true, adds: --minify, --drop:debugger, --drop:console, --ignore-annotations, --sourcemap.
  5. Runs via exec.executeNpx() from the plugin root directory.

Build Output Settings

SettingValue
BundleYes
FormatESM
TargetES2018
SourcemapOnly when minifying
Console/debugger removalOnly when minifying

Dependencies

  • @shevky/base - io, exec, plugin
  • esbuild ^0.27.3 - bundled as a dependency

Risks and Limitations

  • Hardcoded source path: Expects exactly src/js/app.js.
  • Runs via npx: Requires esbuild to be available in the plugin's dependency tree.
  • No custom config: Does not support esbuild plugins or user-provided configuration.

Related