Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Karma support source map files?

Tags:

karma-runner

Is it possible to configure Karma to use source map files for stacktraces? I see that there are a few issues on GitHub which appear to have been closed? I can't however find any example of doing so.

If this is supported can someone illustrate an example config?

like image 890
cirrus Avatar asked Mar 06 '14 13:03

cirrus


People also ask

How do source map files work?

A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.

What are TypeScript source maps?

Explanation: TypeScript Map files are source map files that let tools map between the emitted JavaScript code and the TypeScript source files that created it. And these Source Map files will then help to debug the Typescript file instead of debugging the emitted JavaScript file.


2 Answers

In your karma.config.js file add

config.set({
files: [{
        pattern: '**/*.js.map',
        included: false
      },
...
});

This has worked for me, and files are now served by karma.

like image 81
Mihai Lazar Avatar answered Sep 26 '22 20:09

Mihai Lazar


You need a preprocessor to look at source maps in karma: have a look at karma-sourcemap-loader to preprocess your data and locate the source map files. A limitation of the library is that the source maps must be in the same folder as the js files, with the same name - but different extension of course.

like image 32
MarcoL Avatar answered Sep 24 '22 20:09

MarcoL