Skip to content

Use source maps for stacktraces #594

Closed
@pluma

Description

Currently the stacktraces returned by karma are pretty much useless if any source code transformation or bundling is taking place. This impacts workflows using bundlers (e.g. browserify, component) and transpilers (e.g. CoffeeScript, LiveScript, TypeScript, Dart) alike.

As karma seems to be able to print stacktraces from the browser to the console, it should be possible to run a function on them in between.

Mozilla provides a library at mozilla/source-map for parsing sourcemaps and translating generated source positions to original source positions and filenames.

From what I can see this would require the following steps:

  1. When a source file is loaded, try to find source map comments.
  2. Parse any inlined source maps (needs to support base64-encoded data URLs)
  3. When a browser returns a stacktrace, try to find any file/line/col references.
  4. Translate per-file line/col references via mozilla/source-map.

This should probably be optional because of the overhead involved in finding, parsing and applying the source maps.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions