-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
32 lines (29 loc) · 941 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* webpack-espower-loader - Power Assert instrumentor for webpack.
*
* https://github.com/power-assert-js/webpack-espower-loader
*
* Copyright (c) 2015- Kenta Mori
* Licensed under the MIT license.
* https://github.com/power-assert-js/webpack-espower-loader/blob/master/LICENSE
*/
'use strict';
var convert = require('convert-source-map');
var espower = require('espower-source');
var extend = require('xtend');
var loaderUtils = require('loader-utils');
module.exports = function(jsCode, inMap) {
var filepath = this.resourcePath;
var options = loaderUtils.getOptions(this) || {};
if (inMap) {
options = extend(options, {
sourceMap: inMap
});
}
if (this.cacheable) {
this.cacheable();
}
var poweredCodeWithMap = espower(jsCode, filepath, options);
var outMap = convert.fromSource(poweredCodeWithMap);
this.callback(null, convert.removeComments(poweredCodeWithMap), outMap.toObject());
};