Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Tool:esbuild

From ReverseEngineering.wiki
Tool
On this wiki Facts · Code · Notes · Topics

esbuild (MIT) bundles and minifies JavaScript; its output is recognisable by injected runtime helpers (__commonJS, __esm, __toESM, __export) and by frequency-free, sequential short names from the alphabet abc...XYZ_$ under --minify.

Runtime helpers

esbuild injects a runtime (internal/runtime/runtime.go) only for the features used. Helper names that survive in unminified and in minified output when not tree-shaken: __commonJS (wrapper for a CommonJS module: var require_foo = __commonJS({ "path/foo.js"(exports, module) {...} }), the key is the file path), __esm (lazy ESM wrapper with init_foo), __toESM, __toCommonJS, __export, __reExport, __copyProps, __publicField, __privateGet/Set/Add, __spreadValues, __require (a shim for require in ESM output), __name (keeps function names under --keep-names), __decorateClass.

Unminified output keeps // path/to/file.js comments before each file's code; those and the path keys of __commonJS give the source layout. With --minify the helper names are renamed too (the Min variants __commonJSMin and __esmMin exist) but keys in the object remain strings.

Identifier minification

Names come from internal/ast/ast.go (DefaultNameMinifierJS): first character from abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$, later characters additionally digits. Names are assigned in order of how often a symbol is used (Unverified from reading renamer.go only partly). Property names are not mangled unless --mangle-props is used.

Source maps

--sourcemap writes a v3 map (see Format:Source map (v3)); internal/sourcemap holds the generator.

See Technique:Reversing bundled JavaScript, Technique:JavaScript minifier name mangling.

Code & repositories