Gathering detailed insights and metrics for sx-sourcemapped-stacktrace
Gathering detailed insights and metrics for sx-sourcemapped-stacktrace
Gathering detailed insights and metrics for sx-sourcemapped-stacktrace
Gathering detailed insights and metrics for sx-sourcemapped-stacktrace
apply sourcemaps to js stack traces
npm install sx-sourcemapped-stacktrace
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
BSD-3-Clause License
195 Stars
78 Commits
43 Forks
6 Watchers
2 Branches
11 Contributors
Updated on Apr 27, 2025
Latest Version
1.1.7
Package Id
sx-sourcemapped-stacktrace@1.1.7
Unpacked Size
194.00 kB
Size
47.42 kB
File Count
24
NPM Version
8.19.3
Node Version
16.19.1
Published on
Jul 29, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
5
This is a simple module for applying source maps to JS stack traces in the browser.
You have Error.stack() in JS (maybe you're logging a trace, or you're looking at traces in Jasmine or Mocha), and you need to apply a sourcemap so you can understand whats happening because you're using some fancy compiled-to-js thing like coffeescript or traceur. Unfortunately, the browser only applies sourcemaps when the trace is viewed in its console, not to the underlying stack object, so you're out of luck.
http://novocaine.github.io/sourcemapped-stacktrace-demo/public_html/smst.html
npm install sourcemapped-stacktrace
https://www.npmjs.com/package/sourcemapped-stacktrace
The npm bundle contains dist/sourcemapped-stacktrace.js, if that's what you're after. The built product is not held in this repo.
Include sourcemapped-stacktrace.js into your page using either an AMD module loader or a plain old script include. As an AMD module it exposes the method 'mapStackTrace'. If an AMD loader is not found this function will be set on window.sourceMappedStackTrace.mapStackTrace.
Re-map entries in a stacktrace using sourcemaps if available.
Arguments:
stack: Array of strings from the browser's stack representation.
done: Callback invoked with the transformed stacktrace (an Array of Strings) passed as the first argument
opts: Optional options object containing:
true
, sourcemaps are cached across multiple mapStackTrace()
calls,
allowing for better performance if called repeatedly, or when browser's cache is disabled.
Defaults to false
.Supported browsers
1try { 2 // break something 3 bork(); 4} catch (e) { 5 // pass e.stack to window.mapStackTrace 6 window.mapStackTrace(e.stack, function(mappedStack) { 7 // do what you want with mappedStack here 8 console.log(mappedStack.join("\n")); 9 }, { 10 filter: function (line) { 11 // process only sources containing `spec.js` 12 return /(spec\.js)/.test(line); 13 } 14 }); 15}
Several modern browsers support sourcemaps when viewing stack traces from errors in their native console, but as of the time of writing there is no support for applying a sourcemap to the (highly non-standardised) Error.prototype.stack. Error.prototype.stack can be used for logging errors and for displaying errors in test frameworks, and it is not very convenient to have unmapped traces in either of those use cases.
This module fetches all the scripts referenced by the stack trace, determines whether they have an applicable sourcemap, fetches the sourcemap from the server, then uses the Mozilla source-map library to do the mapping. Browsers that support sourcemaps don't offer a standardised sourcemap API, so we have to do all that work ourselves.
The nice part about doing it ourselves is that the library could be extended to work in browsers that don't support sourcemaps, which could be good for logging and debugging problems. Currently, only Chrome and Firefox are supported, but it would be easy to support those formats by ripping off stacktrace.js.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 8/21 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More