concat-with-sourcemaps
concat-with-sourcemaps copied to clipboard
Generates incorrect source map when one of the input files has an empty source map.
See https://github.com/wearefractal/gulp-concat/issues/94 and https://github.com/gulpjs/gulp/issues/843#issuecomment-101400811
Currently gulp passes this library empty source maps which cannot be concatenated. You wanted to fix the problem here rather than in gulp-concat
, I guess this would entail detecting empty source maps and replacing them with identity source maps.
@ohjames just for the record - gulp doesn't pass anybody sourcemaps. gulp-sourcemaps is responsible for all of that.
I know, but many plugins also touch the source map object attached to the vinyl by gulp-sourcemaps that's why I generically use the term gulp.
Hi @ohjames, sorry for the late answer. I just tested your example in the gulp-concat
thread and it worked fine. Could you set up a repository that shows the error you describe? Thanks!
If I may breath some life into this issue, the problem reported comes from line 93 (pretty sure)(https://github.com/floridoo/concat-with-sourcemaps/blob/master/index.js#L93)
this._sourceMap.addMapping({
generated: {
line: this.lineOffset + i,
column: (i === 1 ? this.columnOffset : 0)
},
original: {
line: i,
column: 0
},
source: filePath //This sucker right here
});
When a source map is not included, the mapping that is used uses the file path as the source location (as opposed to sourceMap.sources[0];
if there is a source map). This results in a source location that looks like this
/Users/astoker/Sites/aurelia-cli/test-dep1/src/app.html
as opposed to this
app.html
(based off the base url of src
).
The result is that when you look in the source mapped version of sources in a browser, you get strange paths that separate html files from js files. Strange meaning that the html files have fully qualified path names, while the js files are defined from the root of the application.
Example: