Source maps

This documentation is for version 6 of the BugSnag JavaScript notifier. We recommend upgrading to the latest release using our Upgrade guide. Documentation for the current release can be found here.

The BugSnag JavaScript library supports using source maps to reverse JavaScript transformations. In order for this to work, BugSnag needs access to the source map. You can either do this by hosting the source maps or by uploading them to BugSnag.

Generating source maps

Most modern bundlers, minifiers and compilers support the generation of source maps:

When generating source maps you normally have the option to include the source content within the source map or leave it in the external source files. If you leave it external BugSnag will need access to those source files to display the context of the error (without it we will just display the source file and line number in the stacktrace).

Source maps can also be encoded directly into the JavaScript file rather than linking to a external file, known as inline source maps. This is sometimes used for development purposes or in certain bundling frameworks like Browserify. BugSnag also supports source maps of this type.

You can upload your source maps to BugSnag using one of the following options:

Alternatively, you can interact with our upload API directly.

You can review a list of your uploaded maps, and delete any unneeded ones, within your dashboard: Project Settings -> Source maps.

Hosting source maps

For browser JavaScript only. For Node.js, you should upload your source maps (see above).

If you host the source map BugSnag can fetch it when an error is received. To achieve this you can include the special sourceMappingURL comment at the end of the JavaScript file or set the X-SourceMap property in the header.

Most minification tools will automatically add the sourceMappingURL to your minified JavaScript files.

When generating source maps you’ll usually have the option to include the source content within the source map or leave it in the external source files. If you have not included the source content in the source map we will also attempt to fetch the source files based on the path specified in the source map.

Access through firewall

If your server’s security policy denies access from external IP addresses and websites, you will need to allow access to BugSnag’s IP addresses below.