Source-map-loader resolves relative paths into absolute even
- Now event sources with content in source map should be resolved with absolute path
This commit is contained in:
@@ -7,6 +7,8 @@ var path = require("path");
|
|||||||
var async = require("async");
|
var async = require("async");
|
||||||
var loaderUtils = require("loader-utils");
|
var loaderUtils = require("loader-utils");
|
||||||
|
|
||||||
|
var separatorRegex = /[/\\]/;
|
||||||
|
|
||||||
// Matches only the last occurrence of sourceMappingURL
|
// Matches only the last occurrence of sourceMappingURL
|
||||||
var baseRegex = "\\s*[@#]\\s*sourceMappingURL\\s*=\\s*([^\\s]*)(?![\\S\\s]*sourceMappingURL)",
|
var baseRegex = "\\s*[@#]\\s*sourceMappingURL\\s*=\\s*([^\\s]*)(?![\\S\\s]*sourceMappingURL)",
|
||||||
// Matches /* ... */ comments
|
// Matches /* ... */ comments
|
||||||
@@ -96,6 +98,12 @@ module.exports = function (input, inputMap) {
|
|||||||
if (!sourceContent) {
|
if (!sourceContent) {
|
||||||
sourcesWithoutContent.push({source: map.sources[i], index: i})
|
sourcesWithoutContent.push({source: map.sources[i], index: i})
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var source = map.sources[i];
|
||||||
|
if (separatorRegex.test(source) && !path.isAbsolute(source)) {
|
||||||
|
map.sources[i] = path.resolve(context, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sourcesWithoutContent.length == 0) {
|
if (sourcesWithoutContent.length == 0) {
|
||||||
@@ -111,7 +119,9 @@ module.exports = function (input, inputMap) {
|
|||||||
delete map.sourceRoot;
|
delete map.sourceRoot;
|
||||||
resolve(context, loaderUtils.urlToRequest(source, true), function (err, result) {
|
resolve(context, loaderUtils.urlToRequest(source, true), function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
emitWarning("Cannot find source file '" + source + "': " + err);
|
// TODO(ilgonmic): Not all JS files have sources content, and we don't extract sources from jar,
|
||||||
|
// so there is no content for these files
|
||||||
|
// emitWarning("Cannot find source file '" + source + "': " + err);
|
||||||
return callback(null, null);
|
return callback(null, null);
|
||||||
}
|
}
|
||||||
addDependency(result);
|
addDependency(result);
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
"name": "@kotlin/source-map-loader",
|
"name": "@kotlin/source-map-loader",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "Modern source-map-loader with additional features",
|
"description": "Modern source-map-loader with additional features",
|
||||||
"main": "lib/kotlin-source-map-loader.js",
|
"main": "kotlin-source-map-loader.js",
|
||||||
"files": [
|
|
||||||
"lib/**/*"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cpx \"kotlin-source-map-loader.js\" lib",
|
"build": "cpx \"kotlin-source-map-loader.js\" lib",
|
||||||
"test": "mocha -R spec"
|
"test": "mocha -R spec"
|
||||||
|
|||||||
Reference in New Issue
Block a user