A source map is a file that maps positions in minified, bundled, or transpiled output back to positions in the original source, so a production stack trace can be rendered with the real filename, line number, and function name. Build tools emit them as .map files alongside the bundle.
Without a source map, a frontend stack trace points at column 48,211 of main.a3f9c2.js, which tells you nothing about which component failed.
Example
Before the source map is applied:
TypeError: t.email is undefined
at main.a3f9c2.js:1:48211
After:
TypeError: t.email is undefined
at renderProfile (src/components/Profile.jsx:42:19)
What Rollbar does with source maps
Rollbar applies uploaded source maps so stack traces contain the original source filename, line number, method name, and code coordinates, and so error grouping stays resilient to code changes. Rollbar matches a source map to a frame by comparing the frame’s filename against the minified_url the map was uploaded with, keyed on the code_version you set in your SDK config. Rollbar accepts maps through an API upload, the Rollbar CLI, or automatic download from the sourceMappingURL comment, with the upload path recommended for production because a downloaded map is not yet in place for the first errors after a deploy.
One constraint worth planning around: Rollbar processes source maps going forward only. Occurrences that arrived before the map was uploaded are not reprocessed.
Related terms
Read the source map setup docs.
Sources
- Rollbar Docs, Source Maps: https://docs.rollbar.com/docs/source-maps