Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add opt for sourcemap URL transform #39

jakelauer opened this issue Aug 9, 2019 · 0 comments


Copy link

commented Aug 9, 2019

The problem
Often, it is preferable for developers to keep sourcemaps private in production, so users cannot browse through the source easily. However, disabling sourcemaps in production makes logging stack traces almost pointless. This library fixes that particular issue, but with the side effect of requiring public sourcemaps which the browser can read.

Proposed solution
Developers could generate sourcemaps as normal, such that .js files include the sourcemap URL, but could avoid putting the sourcemaps at the location specified. That way, the browser will not be able to find the sourcemap and users will not be able to debug the real source in the debugger.

Developers could put the sourcemaps in a different location (e.g. /sourcemaps/* Then, when the user uses mapStackTrace, then could do so like this:

try {
  // break something
} catch (e) {
  // pass e.stack to window.mapStackTrace
  window.mapStackTrace(e.stack, function(mappedStack) {
    // do what you want with mappedStack here
  }, {
    sourceMappingUrlTransform: (originalUrl) => {
        return `/sourcemaps/${originalUrl}`;

With the above code, sourceMappingUrlTransform is passed the original URL (e.g. and can return the preferred .map URL (/sourcemaps/

With the above change, developers would be able to prevent the browser from easily reading sourcemaps, while still gaining effective error logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.