A source map is a JSON file that maps positions in generated code (minified, bundled, transpiled) back to the original files, lines, columns and names. The bundle points to it with a //# sourceMappingURL= comment or a SourceMap HTTP header. DevTools and error trackers use it to show readable stack traces. For production, the usual answer is: generate full source maps, upload them to your error-monitoring tool, and don't serve them publicly ("hidden" source maps). That gives you debuggable production errors without handing out your original source.
{
"version": 3,
"file": "app.3f9a.js",
"sources": ["src/cart/Checkout.tsx", "src/utils/money.ts"],
"sourcesContent": ["export function Checkout() { … }", "…"],
"names": ["Checkout", "formatPrice", "total"],
"mappings": "AAAA,SAASA,QAAQ;AACjB,..."
}
mappings is a compact, Base64-VLQ-encoded list of segments: generated column → source index, original line, original column, and name index.sourcesContent embeds the original code. Without it, tools need access to the files at the sources paths.ignoreList let DevTools hide framework and node_modules frames.| Option | How | Trade-off |
|---|---|---|
| Public source maps | .map served next to the bundle, with sourceMappingURL | Easiest debugging for anyone, including users and attackers |
| Hidden source maps | Generate maps, omit the comment (webpack hidden-source-map, Vite build.sourcemap: 'hidden'), upload to Sentry/Datadog/etc. and delete them from the deploy artifact | Readable traces in your tooling; nothing public. Most common choice |
| Private hosting | Serve .map only on VPN or with auth, and reference them by URL | DevTools debugging for employees too |
| No maps | — | Unreadable production stack traces; slower incident response |
Error trackers match uploaded maps by release identifier and file URL, so tag each build with a release (the git SHA) in both the upload step and the client SDK. Mismatched releases are the #1 reason stack traces stay minified.
sourcesContent, and occasionally secrets mistakenly committed to client code. There have been public incidents where companies' full front-end source, including unreleased features, was reconstructed from public maps.eval-source-map-style) and full maps in production builds..map files are in the deploy artifact (if that's your policy).mappings, sources, sourcesContent, names) at a high level, and ECMA-426.Spotted a mistake or a rights concern? Report an issue