Technique:Reversing bundled JavaScript
| On this wiki | Facts · Code · Notes · Topics |
|---|
How to take apart the JavaScript that Electron, browser-extension and React Native apps ship: recognise the bundler (webpack, esbuild, Rollup, Vite, Parcel), recover names from source maps, understand minifier mangling, and know which markers survive.
Method
- Get the JavaScript out of its container without running the app: Format:ASAR archive (Electron) for Library:Electron, a ZIP inside Format:Chrome extension package (CRX3),
index.android.bundlefor React Native (text, or Format:Hermes bytecode (HBC)), see also Technique:Bundled-runtime applications. - Look for a source map first: a trailing
//# sourceMappingURL=comment or a sibling.mapfile. A map withsourcesContentgives original files and names (Format:Source map (v3)). - Identify the bundler from its wrapper and helpers (table below).
- Split the bundle into modules (the module map or factory list), then read the modules, not the file.
- Check whether the identifiers are minified (Technique:JavaScript minifier name mangling) or obfuscated (Technique:Recognizing code obfuscation/JavaScript obfuscator output); they look different.
- Beyond the bundle: look for Tool:Bytenode
.jscfiles (Format:V8 code cache), a Format:Node.js single executable application blob, V8 snapshots (Format:V8 startup snapshot) and WebAssembly modules with their glue (Tool:Wasm-bindgen, Tool:Emscripten, Format:WebAssembly binary format); source and code are not always readable text.
Recognising the bundler
| Bundler | Markers | Page |
|---|---|---|
| webpack | __webpack_require__, __webpack_modules__, webpackChunk<name> global array, __webpack_require__.r/.d/.n/.o helpers |
Tool:webpack |
| esbuild | helper functions __commonJS, __esm, __toESM, __export, __toCommonJS, __publicField, __name |
Tool:esbuild |
| Rollup / Vite | Unverified: ES-module or IIFE output with no runtime, modules concatenated (scope-hoisted) and renamed; chunk files named like index-<hash>.js and dynamic import() between chunks |
- |
| Parcel | Unverified: a parcelRequire function and a module map keyed by short hash ids |
- |
Scope-hoisting bundlers (esbuild and Rollup in ESM mode, webpack concatenated modules) leave no module boundaries to split on; esbuild inserts // path/to/file.js comments between files unless minified.
What survives minification
Property names, string literals, quoted keys, import/export names of entry points, license comments (/*! ... */), error and log messages and URL strings survive; local and (in non-module scripts) top-level names do not. See Technique:JavaScript minifier name mangling.
Pitfalls
- Never run or build downloaded bundles; beautify and read.
- A source map can describe a different build than the bundle next to it; compare the
//# debugId=comment with the map'sdebugIdwhen present. - Unverified: some stores strip
sourcesContentor the map entirely; names may still be recoverable from thenamesarray.
Code & repositories
See the linked repositories on Tool:webpack, Tool:esbuild, Tool:Terser and Format:Source map (v3).
- https://github.com/webpack/webpack @
e1c10dc15e8df3a7efa16ff0ddb3a2ad84381600· license: MIT (read from LICENSE; GitHub's API was busy)
Bundler; runtime templates in lib/runtime and bundle template in lib/javascript.
Tested on: source read, not run: read only · checked 2026-10-18