-
Option name:
"sourceMap" -
Option values:
true/false/Object
What Source Maps Are For
Source maps let you map obfuscated output back to your original source code. This is useful during development so stack traces and debuggers reference meaningful line numbers and variable names instead of the obfuscated output. Obfuscation can break stack traces. Transformations like control flow flattening, variable renaming, and string concealing shift code locations significantly. Without a source map, a thrown error may point to a line in the obfuscated file that has no clear relationship to the original code.Security Warning
A source map contains your entire original source code. Never ship source maps to production or expose them publicly; this would completely defeat the purpose of obfuscation. Keep source map files server-side, away from any reverse engineers.External Source Maps
The source map is written to a separate .map file. The obfuscated file references it via a comment at the bottom. This is the recommended approach for source maps.External Source Map
Inline Source Maps
The source map is base64-encoded and embedded directly in the output file. Convenient for quick testing, but the source is exposed to anyone with the file.Inline Source Map
Source Map Options
You may providetrue or an Object of type SourceMapOptions for the option sourceMap in your obfuscator settings. The field fileName will be set to "script.js" if not provided.
Usage Example
The provided code example will obfuscate the filedev.input.js and write the output to a file named dev.output.js with a source map file named dev.output.js.map.
Example Usage
Testing Source Maps in Chrome DevTools
- Open Chrome DevTools (
F12) and go to the Sources tab. - Load your obfuscated file in the browser.
- If the source map is detected, DevTools will show your original source file in the file tree under the Sources panel.
- Set breakpoints, step through code, and inspect variables as if the obfuscation never happened.
- If the original source is not appearing, check that the sourceMappingURL comment at the bottom of your output file points to the correct .map file path, and that the .map file is being served.
--enable-source-maps when running your script:
Node.js Source Maps