How does source mapping help when debugging minified or transpiled code?
Short answer
A source map is a file that maps positions in generated (minified/transpiled) code back to the original source, so browser DevTools can show you readable original code and correct line numbers even though the browser is actually running the bundled output.
Advertisement
AModel answer
A source map is a file that maps positions in generated (minified/transpiled) code back to the original source, so browser DevTools can show you readable original code and correct line numbers even though the browser is actually running the bundled output.
//# sourceMappingURL=app.min.js.map
// tells DevTools where to find the mapping fileReal-world example
Debugging a production error stack trace that points to original TypeScript source, not the minified bundle.
Likely follow-ups
- Why should source maps typically not be publicly exposed on production servers?
Related topics