Skip to content

Node API

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

The package @sysce/estrogen has three entry points: the main module, an esbuild plugin, and an rsbuild plugin. All three run the native binary over a built directory.

obfuscate

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.

esbuild plugin

import estrogen from '@sysce/estrogen/esbuild';

// plugins: [estrogen()]

The default export is estrogen(options?): esbuild.Plugin. It runs after the build over the output directory. See esbuild.

rsbuild plugin

import { pluginEstrogen } from '@sysce/estrogen/rsbuild';

// plugins: [pluginEstrogen()]

pluginEstrogen(options?): RsbuildPlugin runs after the build over the dist path. See rsbuild.

Options

The same options object is accepted by obfuscate() and, as overrides, by both plugins. 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 stripped sourceMappingURL comments.
  • 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.

Report

obfuscate() resolves with a Report. The shape is stable; the numbers are the files obfuscated, vendored and skipped.

interface Report {
	formatVersion: number;
	dirs: string[];
	filesProcessed: number;
	filesSkipped: number;
	durationMs: number;
	check: boolean;
}

filesSkipped counts files estrogen left untouched (a .map, an already-processed file, a vendored transport asset). check is true when the run wrote nothing. A failing file rejects the promise with an Error that names the file and the reason; estrogen does not resolve with a partial report.

The package ships type declarations for all three entry points. Options and Report are exported from @sysce/estrogen.

Clone this wiki locally