From 6caa1ff500ec1e3c71d146b804afff0f699375b5 Mon Sep 17 00:00:00 2001 From: Sergey Shevchenko Date: Fri, 23 Dec 2016 18:23:20 +0200 Subject: [PATCH] Support inline source maps (#36) :heavy_plus_sign: inline source maps (fix #35) --- index.js | 7 +++++++ package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/index.js b/index.js index ba2e6a8..f6f24eb 100644 --- a/index.js +++ b/index.js @@ -3,8 +3,15 @@ var istanbulLibInstrument = require('istanbul-lib-instrument'); var loaderUtils = require('loader-utils'); var assign = require('object-assign'); +var convert = require('convert-source-map'); module.exports = function(source, sourceMap) { + // use inline source map, if any + var inlineSourceMap = convert.fromSource(source); + if (!sourceMap && inlineSourceMap) { + sourceMap = inlineSourceMap.sourcemap; + } + var userOptions = loaderUtils.parseQuery(this.query); var instrumenter = istanbulLibInstrument.createInstrumenter( assign({ produceSourceMap: this.sourceMap }, userOptions) diff --git a/package.json b/package.json index 04131f2..f237470 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "index.js" ], "dependencies": { + "convert-source-map": "^1.3.0", "istanbul-lib-instrument": "^1.1.3", "loader-utils": "^0.2.16", "object-assign": "^4.1.0"