🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

karma-sourcemap-loader

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-sourcemap-loader - npm Package Compare versions

Comparing version

to
0.1.1

48

index.js

@@ -1,2 +0,1 @@

//var coffee = require('coffee-script');
var fs = require('fs');

@@ -7,4 +6,2 @@ var createSourceMapLocatorPreprocessor = function(args, logger, helper) {

return function(content, file, done) {
//console.log('Processing "%s".', file.originalPath);
log.debug('Processing "%s".', file.originalPath);
var mapPath = file.path+".map";

@@ -23,47 +20,2 @@ fs.exists(mapPath, function(exists) {

};
/*
config = config || {};
var log = logger.create('preprocessor.coffee');
var defaultOptions = {
bare: true,
sourceMap: false
};
var options = helper.merge(defaultOptions, args.options || {}, config.options || {});
var transformPath = args.transformPath || config.transformPath || function(filepath) {
return filepath.replace(/\.coffee$/, '.js');
};
return function(content, file, done) {
var result = null;
var map;
var datauri;
log.debug('Processing "%s".', file.originalPath);
file.path = transformPath(file.originalPath);
// Clone the options because coffee.compile mutates them
var opts = helper._.clone(options)
try {
result = coffee.compile(content, opts);
} catch (e) {
log.error('%s\n at %s:%d', e.message, file.originalPath, e.location.first_line);
return;
}
if (result.v3SourceMap) {
map = JSON.parse(result.v3SourceMap)
map.sources[0] = path.basename(file.originalPath)
map.sourcesContent = [content]
map.file = path.basename(file.path)
file.sourceMap = map;
datauri = 'data:application/json;charset=utf-8;base64,' + new Buffer(JSON.stringify(map)).toString('base64')
done(result.js + '\n//@ sourceMappingURL=' + datauri + '\n');
} else {
done(result.js || result)
}
};
*/
};

@@ -70,0 +22,0 @@

8

package.json
{
"name": "karma-sourcemap-loader",
"version": "0.1.0",
"version": "0.1.1",
"description": "Karma plugin that locates and loads existing javascript source map files.",

@@ -10,2 +10,8 @@ "main": "index.js",

},
"keywords": [
"karma-plugin",
"karma-preprocessor",
"source-maps",
"javascript"
],
"author": {

@@ -12,0 +18,0 @@ "name": "Gabriele Genta",

@@ -5,2 +5,19 @@ # karma-sourcemap-loader

## Why
When you use karma not in isolation but as part of a build process (e.g. using grunt
or gulp) it is often the case that the compilation/transpilation is done on a previous
step of the process and not handled by karma preprocessors. In these cases source maps
don't get loaded by karma and you lose the advantages of having them.
## How it works
Right now source maps are located via this rule: the preprocessors appends
".map" to the file name, and if that file exists it loads and includes it.
So if for example you have Hello.js, the preprocessor will try to load source map from
Hello.js.map.
This is very simple but should work in the majority of cases for standard usage (e.g. with typescript).
## Installation

@@ -24,3 +41,3 @@

The code below shows the sample configuration of the preprocessor.
The code below shows a sample configuration of the preprocessor.
```js

@@ -27,0 +44,0 @@ // karma.conf.js