Skip to content

Commit 2acc6ed

Browse files
committed
Merge pull request #100 from mzgoddard/fix-third-param-source-content
Fix applySourceMap's aSourceMapPath parameter source content support
2 parents d42b3e6 + 1fdb9c7 commit 2acc6ed

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/source-map/source-map-generator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ define(function (require, exports, module) {
229229
aSourceMapConsumer.sources.forEach(function (sourceFile) {
230230
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
231231
if (content) {
232+
if (aSourceMapPath) {
233+
sourceFile = util.join(aSourceMapPath, sourceFile);
234+
}
232235
if (sourceRoot) {
233236
sourceFile = util.relative(sourceRoot, sourceFile);
234237
}

test/source-map/test-source-map-generator.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,22 @@ define(function (require, exports, module) {
309309
original: { line: 2, column: 2 },
310310
source: '../coffee/foo.coffee'
311311
});
312+
bundleMap.setSourceContent('../coffee/foo.coffee', 'foo coffee');
312313
bundleMap.addMapping({
313314
generated: { line: 13, column: 13 },
314315
original: { line: 12, column: 12 },
315316
source: '/bar.coffee'
316317
});
318+
bundleMap.setSourceContent('/bar.coffee', 'bar coffee');
317319
bundleMap.addMapping({
318320
generated: { line: 23, column: 23 },
319321
original: { line: 22, column: 22 },
320322
source: 'http://www.example.com/baz.coffee'
321323
});
324+
bundleMap.setSourceContent(
325+
'http://www.example.com/baz.coffee',
326+
'baz coffee'
327+
);
322328
bundleMap = new SourceMapConsumer(bundleMap.toJSON());
323329

324330
var minifiedMap = new SourceMapGenerator({
@@ -352,16 +358,19 @@ define(function (require, exports, module) {
352358
original: { line: 2, column: 2 },
353359
source: sources[0]
354360
});
361+
map.setSourceContent(sources[0], 'foo coffee');
355362
map.addMapping({
356363
generated: { line: 11, column: 11 },
357364
original: { line: 12, column: 12 },
358365
source: sources[1]
359366
});
367+
map.setSourceContent(sources[1], 'bar coffee');
360368
map.addMapping({
361369
generated: { line: 21, column: 21 },
362370
original: { line: 22, column: 22 },
363371
source: sources[2]
364372
});
373+
map.setSourceContent(sources[2], 'baz coffee');
365374
return map.toJSON();
366375
}
367376

0 commit comments

Comments
 (0)