Repository navigation
Node API
The package @sysce/estrogen ships the native binary as a per-target optional
dependency and a thin launcher that runs the right one. Its entry points are the
main module, the esbuild, rsbuild, Vite and Rollup plugins, and the Astro
integration. Each runs that binary over a built directory.
import { obfuscate } from '@sysce/estrogen';
const report = await obfuscate({ dirs: ['dist'] });obfuscate(options): Promise<Report> runs the whole pass over one or more
directories and resolves with a Report. It rejects if any file fails,
the same fail-closed rule as the CLI: no partial output for a failing file, and
the error names the file and the reason.
import estrogen from '@sysce/estrogen/esbuild';
// plugins: [estrogen()]The default export of @sysce/estrogen/esbuild is estrogen(options?): esbuild.Plugin. It runs after the build finishes, over the build's output
directory (outdir, or the directory of outfile). Pass options to override
the inferred settings. If a file fails, the build fails. See esbuild.
import { pluginEstrogen } from '@sysce/estrogen/rsbuild';
// plugins: [pluginEstrogen()]pluginEstrogen(options?): RsbuildPlugin is a named export of
@sysce/estrogen/rsbuild. It runs after the build finishes, over the resolved
dist path. A failing file fails the build. See rsbuild.
import { pluginEstrogen } from '@sysce/estrogen/vite';
// plugins: [pluginEstrogen()]pluginEstrogen(options?): Plugin is a named export (and the default export) of
@sysce/estrogen/vite. It sets apply: 'build' and enforce: 'post', so it runs
after vite build writes the output, over build.outDir, and stays out of
vite serve. A failing file fails the build. See Vite.
import { pluginEstrogen } from '@sysce/estrogen/rollup';
// plugins: [pluginEstrogen()]pluginEstrogen(options?): Plugin is a named export (and the default export) of
@sysce/estrogen/rollup. It runs in writeBundle, over output.dir or the
directory of output.file. A failing file fails the build. See Rollup.
import estrogen from '@sysce/estrogen/astro';
// integrations: [estrogen()]The default export of @sysce/estrogen/astro is estrogen(options?): AstroIntegration. It runs on the astro:build:done hook, over the final static
output directory; for an SSR build it rewrites the client output directory. A
failing file fails the build. See Astro.
The same options object is accepted by obfuscate() and, as overrides, by the
esbuild, rsbuild, Vite and Rollup plugins and the Astro integration. Every field
is optional for the plugins, which infer dirs from the build. obfuscate()
needs at least dirs.
-
dirs: string[]: the built directories to process. -
config?: string: path to a TOML config file. Fields set on the options object override the file. -
canary?: string: path to the canary list (JSON). -
names?: string: path to the name map. -
sourcemap?: string: write maps into this directory, outside the build. Omitted means no map and strippedsourceMappingURLcomments. -
seed?: string: fixed hex seed for deterministic output. Tests only. -
jobs?: number: maximum files in parallel. Default is the CPU count. -
check?: boolean: run the passes and the canary check without writing. -
quiet?: boolean: suppress progress output. -
verbose?: boolean: emit per-file detail.
See Configuration for the config file and Source maps for
the sourcemap behavior.
obfuscate() runs the estrogen binary over the directories and resolves with a
Report of that run:
interface Report {
ok: boolean; // true when estrogen exited 0
exitCode: number; // the process exit code
dirs: string[]; // the directories passed
binaryPath: string; // the per-target binary that ran
args: string[]; // the arguments it was given
stdout: string; // captured stdout
stderr: string; // captured stderr
durationMs: number; // wall-clock time for the run
details?: unknown; // parsed per-file detail when estrogen emits it
}When estrogen exits nonzero (a parse error, a surviving canary, a store name
outside the allow-list), obfuscate() rejects with an error that carries the
Report, and stderr names the file and the reason. estrogen writes no partial
output for a failing file.
The package ships type declarations for every entry point. Options and
Report are exported from @sysce/estrogen.
@sysce/estrogen ·
Fracital/estrogen · ISC · by David Reed.
estrogen raises the cost of reading a build; it does not make it secret.