Skip to content

Source maps

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

A source map traces obfuscated output back to its source, so estrogen writes none by default, and an edge rule backs that up.

Default: no map, comments stripped

With no --sourcemap flag (CLI) and no sourcemap option (Node), estrogen:

  • writes no source map next to the served build, and
  • strips any //# sourceMappingURL and //@ sourceMappingURL comment from every chunk it processes.

The bundler's own maps point at the pre-obfuscation source and must never ship. Stripping the comment is part of estrogen's job; it takes over the comment-stripping the site scripts did before.

Private debug maps: --sourcemap dir

A build that wants a map for private debugging passes a directory:

estrogen --sourcemap .estrogen-maps dist

or in the Node options:

await obfuscate({ dirs: ['dist'], sourcemap: '.estrogen-maps' });

estrogen writes one V3 map per processed file into that directory, at the file's path under it, so dist/app.js becomes <dir>/app.js.map. The directory must be outside the served tree. That directory stays private. Do not publish it, and do not point it at dist or any path the site serves.

The served build does not change. estrogen writes the chunk with no map beside it and adds no sourceMappingURL comment pointing at the private map, so nothing in the served output reveals that a map exists. The map is built from the byte-range edits estrogen made, with the original chunk embedded in sourcesContent, so it is self-contained. It traces the obfuscated output back to the chunk estrogen read; it does not chain through an incoming bundler map, so it points at estrogen's input, not the pre-bundle source.

Edge backstop: 403 for maps

The default and the private directory are not the whole guard. Every consumer host returns 403 for *.map and for any sourceMappingURL target, so a map that reaches a published directory by accident is still never served.

This rule lives in the edge config (the infra repo's edge role, and amph's OpenResty), not in estrogen. It is a required integration step and a config-parity item. Setting up a site to use estrogen means confirming the edge 403 rule is in place as well.

Clone this wiki locally