Skip to content

Vendoring

David Reed edited this page Nov 20, 2026 · 1 revision

estrogen build copies files into the built tree before it obfuscates, so a site declares its vendoring in the config instead of keeping a hand-written copy script. Each [[vendor]] table is one input: where it comes from, where it lands, and whether it is obfuscated on the way in.

When to use it

A plain estrogen <dir> run obfuscates what the bundler already wrote. Some files are never bundled: a whole package from node_modules, a transport runtime, a folder of assets. estrogen build <dir> brings those in first, under stamped neutral names, then obfuscates the app chunks. This replaces the per-site copy step that each build kept by hand (SystemYA's prepare scripts are the prior art).

A vendor input

# estrogen.toml
[[vendor]]
from = 'node_modules/ruffle'   # a package dir, a folder, or a glob
to = 'assets'                  # the destination under the dist root
mode = 'verbatim'              # or 'obfuscate'
stamp = true                   # insert the per-build stamp before the extension

	[[vendor.rewrite]]         # optional: rewrite references in the copied text
	find = 'epoxy.wasm'
	to = 'ln.{stamp}.wasm'
  • from is a package directory, a folder, or a glob, relative to the working directory. A directory is copied whole; a glob copies its matches.
  • to is the destination under the dist root.
  • mode is verbatim (the default) or obfuscate. A verbatim file is copied as is, which is what a vendored transport runtime wants; an obfuscate file runs the same pass as an app chunk on the way in.
  • stamp inserts the per-build stamp before the extension, so sw.js lands as sw.<stamp>.js, a fresh URL each build. To drop a package name from a file as well, give that input a to that names a neutral file.
  • each [[vendor.rewrite]] replaces find with to in the copied file's text. {stamp} in to expands to the build stamp, so a reference points at the stamped name the file lands under.

The stamp

The stamp is a short neutral token, minted once per build and reused across every input, so a reference rewritten to a stamped name matches the file that lands under it. With --seed it is deterministic, so a build repeats byte for byte; without a seed it is drawn fresh each build. It never spells a canary, so a stamped name cannot reintroduce one.

Running it

estrogen build -c estrogen.toml dist

estrogen build vendors every [[vendor]] input into each dist, then obfuscates the rest of the tree. estrogen dist with no build stays obfuscate-only and vendors nothing. From Rust the same work is Obfuscator::build(dist), and obfuscate_dir stays obfuscate-only.

Every vendored file is canary checked, verbatim ones included, and the build fails closed if a listed literal survives. The source-map comment is stripped from the files estrogen copies, the same as the files it obfuscates. The limit is the same too: this raises the cost of reading the build, it is not secrecy. See Security and limits.

Clone this wiki locally