Skip to content

Commit

Permalink
feat(StackTracePlugin): Add sourceMaps option.
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Oct 31, 2017
1 parent 723de5b commit 3bd322e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion source/plugin/stack-trace-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ function setStackTraceRef(ref: SubscriberRef, value: StackTraceRef): StackTraceR

export class StackTracePlugin extends BasePlugin {

private sourceMaps_: boolean;

constructor({ sourceMaps = true }: { sourceMaps?: boolean } = {}) {

super();
this.sourceMaps_ = sourceMaps;
}

beforeSubscribe(ref: SubscriberRef): void {

const stackTraceRef: StackTraceRef = {
Expand All @@ -42,7 +50,7 @@ export class StackTracePlugin extends BasePlugin {
};
setStackTraceRef(ref, stackTraceRef);

if ((typeof window !== "undefined") && (window.location.protocol !== "file:")) {
if (this.sourceMaps_ && (typeof window !== "undefined") && (window.location.protocol !== "file:")) {
stackTraceRef.sourceMapsResolved = get(options()).then((stackFrames) => {
const { stackTrace } = stackTraceRef;
stackTrace.splice(0, stackTrace.length, ...stackFrames);
Expand Down
2 changes: 1 addition & 1 deletion source/spy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export function spy(options: {
plugins_ = plugins;
} else {
plugins_ = [
new StackTracePlugin(),
new StackTracePlugin(options as { [key: string]: any }),
new GraphPlugin(),
new SnapshotPlugin(options as { [key: string]: any }),
new DevToolsPlugin()
Expand Down

0 comments on commit 3bd322e

Please sign in to comment.