esbuild
The esbuild plugin gives every package that builds with esbuild a build task, from an esbuild config or from a build script that runs the esbuild command.
Add it
Section titled “Add it”axle add esbuildThis writes it into the root axle.toml:
[plugins.esbuild]source = "npm:@axle-rs/plugin-esbuild@0.1.0"hash = "sha256-…"esbuild has no config file of its own, so a package uses it in one of two ways, and the plugin reads both:
| Package has | Task | Command | Settings |
|---|---|---|---|
an esbuild.config.js, .mjs, .cjs, .ts or .mts that calls build |
build |
node esbuild.config.js |
outputs the outdir folder or outfile |
a build script that runs esbuild, such as esbuild src/index.ts --bundle |
build |
the script’s command | outputs the --outdir folder or --outfile |
A config runs with Node.js, through Yarn in a Yarn repository so that Plug’n’Play works. A config in TypeScript needs a Node.js version that runs TypeScript files, 22.18 or later. The esbuild command runs through the repository’s package manager, such as pnpm exec esbuild src/index.ts --bundle --outdir=dist, so it uses the version the package installs.
The outputs are read without running anything: outdir and outfile as plain strings in the config, or --outdir and --outfile in the script. When one is set to something else, such as a variable, or to different values in two places, the plugin leaves outputs out and Axle finds the outputs the build writes itself.
Scripts the repository already has
Section titled “Scripts the repository already has”A package’s own script wins. With a config, a build script that runs anything other than node esbuild.config.js keeps the task. Without one, only a build script that runs esbuild alone becomes the plugin’s task, with the same command and its outputs; a script that chains commands, such as tsc && esbuild src/index.ts, is left as it is. The repository’s axle.toml changes a task as it would any other, and wins over the plugin.
Settings
Section titled “Settings”| Setting | Default | Meaning |
|---|---|---|
build |
"build" |
the name of the build task, or false to leave it out |
The plugin’s answers are kept until an esbuild.config.*, a package.json, pnpm-workspace.yaml or a lockfile changes.