@@ -414,12 +414,12 @@ public void testSourceMaps() {
414
414
" }" ,
415
415
" return X;" ,
416
416
"}());" );
417
- String sourceMapPath = "relativedir/ foo.js.map" ;
418
- String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMapPath ;
417
+ String sourceMappingURL = "foo.js.map" ;
418
+ String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMappingURL ;
419
419
String code = sourceMapTestCode + "\n " + sourceMappingURLComment ;
420
420
421
421
Result result = testAndReturnResult (srcs (code ), expected (code ));
422
- assertThat (result .compiler .getInputSourceMappingURL ("testcode" )).isEqualTo (sourceMapPath );
422
+ assertThat (result .compiler .getInputSourceMappingURL ("testcode" )).isEqualTo (sourceMappingURL );
423
423
}
424
424
425
425
@ Test
@@ -433,8 +433,8 @@ public void testSourceMapsWithoutResolvingSourceMapAnnotations() {
433
433
" }" ,
434
434
" return X;" ,
435
435
"}());" );
436
- String sourceMapPath = "relativedir/ foo.js.map" ;
437
- String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMapPath ;
436
+ String sourceMappingURL = "foo.js.map" ;
437
+ String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMappingURL ;
438
438
String code = sourceMapTestCode + "\n " + sourceMappingURLComment ;
439
439
440
440
Result result = testAndReturnResult (srcs (code ), expected (code ));
@@ -453,14 +453,37 @@ public void testSourceMapsWithoutParsingInlineSourceMaps() {
453
453
" }" ,
454
454
" return X;" ,
455
455
"}());" );
456
- String sourceMapPath = "relativedir/ foo.js.map" ;
457
- String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMapPath ;
456
+ String sourceMappingURL = "foo.js.map" ;
457
+ String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMappingURL ;
458
458
String code = sourceMapTestCode + "\n " + sourceMappingURLComment ;
459
459
460
460
Result result = testAndReturnResult (srcs (code ), expected (code ));
461
461
// Input source map is registered when `parseInlineSourceMaps = false`, but we won't try to
462
462
// parse it as a Base64 encoded source map.
463
- assertThat (result .compiler .getInputSourceMappingURL ("testcode" )).isEqualTo (sourceMapPath );
463
+ assertThat (result .compiler .getInputSourceMappingURL ("testcode" )).isEqualTo (sourceMappingURL );
464
+ }
465
+
466
+ @ Test
467
+ public void testConfiguredDirectorySourceMaps () {
468
+ // We do not allow the TypeScript compiler to set "compilerOptions.sourceRoot" (option to
469
+ // configure a directory to store
470
+ // sourcemaps). Sourcemaps (.js.map) files are placed next to the .js files.
471
+ // This means sourcemap URLs should be the name of the sourcemap file, not a path to the
472
+ // sourcemap file. If we see a path, we will serialize only the name of the sourcemap file.
473
+ String sourceMapTestCode =
474
+ lines (
475
+ "var X = (function () {" ,
476
+ " function X(input) {" ,
477
+ " this.y = input;" ,
478
+ " }" ,
479
+ " return X;" ,
480
+ "}());" );
481
+ String sourceMappingURLPath = "directory/foo.js.map" ;
482
+ String sourceMappingURLComment = "//# sourceMappingURL=" + sourceMappingURLPath ;
483
+ String code = sourceMapTestCode + "\n " + sourceMappingURLComment ;
484
+
485
+ Result result = testAndReturnResult (srcs (code ), expected (code ));
486
+ assertThat (result .compiler .getInputSourceMappingURL ("testcode" )).isEqualTo ("foo.js.map" );
464
487
}
465
488
466
489
@ Test
0 commit comments