Skip to content

esbuild

David Reed edited this page Nov 20, 2026 · 3 revisions

@sysce/estrogen/esbuild is an esbuild plugin that runs estrogen after the build, over the output directory.

import estrogen from '@sysce/estrogen/esbuild';
import { build } from 'esbuild';

await build({
	entryPoints: ['src/index.ts'],
	bundle: true,
	outdir: 'dist',
	plugins: [estrogen()],
});

The default export is estrogen(options?): esbuild.Plugin. It runs in the build's end phase, over outdir (or the directory of outfile). If any file fails, the build fails: estrogen fails closed and writes no partial output for a failing file.

Options

Pass the Node API options object to override what the plugin infers. It infers dirs from the build output, so you usually set only the per-site data files:

plugins: [estrogen({ config: 'estrogen.toml' })];
plugins: [
	estrogen({ names: 'estrogen.names.json', canary: 'canary-list.json' }),
];

See Configuration for the config file.

Run once

estrogen is not idempotent. The plugin runs once per build, at the end. Do not add it twice, and in watch mode confirm each rebuild writes a fresh output directory rather than reprocessing one estrogen already rewrote.

Source maps

By default estrogen writes no map and strips sourceMappingURL comments from the chunks it processes. If esbuild is set to emit maps, those bundler maps point at pre-obfuscation source and estrogen keeps them out of the served output. For a private debug map, pass sourcemap in the plugin options to write it outside the build. See Source maps.

Clone this wiki locally