Skip to content

Commit b3c4733

Browse files
committed
Merge pull request #5620 from Microsoft/inlineSourceMap
Fixes use of combination of options sourceRoot and mapRoot with inlineSourceMap and inlineSources
2 parents f256da9 + 1659300 commit b3c4733

32 files changed

+335
-8
lines changed

src/compiler/program.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -990,16 +990,15 @@ namespace ts {
990990
if (options.mapRoot) {
991991
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
992992
}
993-
if (options.sourceRoot) {
994-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
995-
}
996993
}
997994

998-
999995
if (options.inlineSources) {
1000996
if (!options.sourceMap && !options.inlineSourceMap) {
1001997
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
1002998
}
999+
if (options.sourceRoot) {
1000+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSources"));
1001+
}
10031002
}
10041003

10051004
if (options.out && options.outFile) {
@@ -1011,10 +1010,9 @@ namespace ts {
10111010
if (options.mapRoot) {
10121011
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
10131012
}
1014-
if (options.sourceRoot) {
1013+
if (options.sourceRoot && !options.inlineSourceMap) {
10151014
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
10161015
}
1017-
return;
10181016
}
10191017

10201018
const languageVersion = options.target || ScriptTarget.ES3;

tests/baselines/reference/inlineSourceMap2.errors.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
22
error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
3-
error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.
43
tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'.
54

65

76
!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
87
!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
9-
!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.
108
==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ====
119

1210
// configuration errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
2+
error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
3+
4+
5+
!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'.
6+
!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.
7+
==== tests/cases/compiler/optionsInlineSourceMapMapRoot.ts (0 errors) ====
8+
9+
var a = 10;

tests/baselines/reference/optionsInlineSourceMapMapRoot.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
===================================================================
2+
JsFile: optionsInlineSourceMapMapRoot.js
3+
mapUrl: local/optionsInlineSourceMapMapRoot.js.map
4+
sourceRoot:
5+
sources: ../optionsInlineSourceMapMapRoot.ts
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:tests/cases/compiler/optionsInlineSourceMapMapRoot.js
9+
sourceFile:../optionsInlineSourceMapMapRoot.ts
10+
-------------------------------------------------------------------
11+
>>>var a = 10;
12+
1 >
13+
2 >^^^^
14+
3 > ^
15+
4 > ^^^
16+
5 > ^^
17+
6 > ^
18+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
19+
1 >
20+
>
21+
2 >var
22+
3 > a
23+
4 > =
24+
5 > 10
25+
6 > ;
26+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
27+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
28+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
29+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
30+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
31+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
32+
---
33+
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcE1hcFJvb3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9vcHRpb25zSW5saW5lU291cmNlTWFwTWFwUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

tests/baselines/reference/optionsInlineSourceMapSourceRoot.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
===================================================================
2+
JsFile: optionsInlineSourceMapSourceRoot.js
3+
mapUrl: optionsInlineSourceMapSourceRoot.js.map
4+
sourceRoot: local/
5+
sources: optionsInlineSourceMapSourceRoot.ts
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:tests/cases/compiler/optionsInlineSourceMapSourceRoot.js
9+
sourceFile:optionsInlineSourceMapSourceRoot.ts
10+
-------------------------------------------------------------------
11+
>>>var a = 10;
12+
1 >
13+
2 >^^^^
14+
3 > ^
15+
4 > ^^^
16+
5 > ^^
17+
6 > ^
18+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
19+
1 >
20+
>
21+
2 >var
22+
3 > a
23+
4 > =
24+
5 > 10
25+
6 > ;
26+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
27+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
28+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
29+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
30+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
31+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
32+
---
33+
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZVJvb3QuanMiLCJzb3VyY2VSb290IjoibG9jYWwvIiwic291cmNlcyI6WyJvcHRpb25zSW5saW5lU291cmNlTWFwU291cmNlUm9vdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMifQ==
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts ===
2+
3+
var a = 10;
4+
>a : Symbol(a, Decl(optionsInlineSourceMapSourceRoot.ts, 1, 3))
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/optionsInlineSourceMapSourceRoot.ts ===
2+
3+
var a = 10;
4+
>a : number
5+
>10 : number
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
2+
3+
4+
!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
5+
==== tests/cases/compiler/optionsInlineSourceMapSourcemap.ts (0 errors) ====
6+
7+
var a = 10;

tests/baselines/reference/optionsInlineSourceMapSourcemap.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
===================================================================
2+
JsFile: optionsInlineSourceMapSourcemap.js
3+
mapUrl: optionsInlineSourceMapSourcemap.js.map
4+
sourceRoot:
5+
sources: optionsInlineSourceMapSourcemap.ts
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:tests/cases/compiler/optionsInlineSourceMapSourcemap.js
9+
sourceFile:optionsInlineSourceMapSourcemap.ts
10+
-------------------------------------------------------------------
11+
>>>var a = 10;
12+
1 >
13+
2 >^^^^
14+
3 > ^
15+
4 > ^^^
16+
5 > ^^
17+
6 > ^
18+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
19+
1 >
20+
>
21+
2 >var
22+
3 > a
23+
4 > =
24+
5 > 10
25+
6 > ;
26+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
27+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
28+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
29+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
30+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
31+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
32+
---
33+
>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9uc0lubGluZVNvdXJjZU1hcFNvdXJjZW1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm9wdGlvbnNJbmxpbmVTb3VyY2VNYXBTb3VyY2VtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDIn0=

tests/baselines/reference/optionsSourcemapInlineSources.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/optionsSourcemapInlineSources.js.map

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
===================================================================
2+
JsFile: optionsSourcemapInlineSources.js
3+
mapUrl: optionsSourcemapInlineSources.js.map
4+
sourceRoot:
5+
sources: optionsSourcemapInlineSources.ts
6+
sourcesContent: ["\nvar a = 10;"]
7+
===================================================================
8+
-------------------------------------------------------------------
9+
emittedFile:tests/cases/compiler/optionsSourcemapInlineSources.js
10+
sourceFile:optionsSourcemapInlineSources.ts
11+
-------------------------------------------------------------------
12+
>>>var a = 10;
13+
1 >
14+
2 >^^^^
15+
3 > ^
16+
4 > ^^^
17+
5 > ^^
18+
6 > ^
19+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
20+
1 >
21+
>
22+
2 >var
23+
3 > a
24+
4 > =
25+
5 > 10
26+
6 > ;
27+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
28+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
29+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
30+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
31+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
32+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
33+
---
34+
>>>//# sourceMappingURL=optionsSourcemapInlineSources.js.map
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/optionsSourcemapInlineSources.ts ===
2+
3+
var a = 10;
4+
>a : Symbol(a, Decl(optionsSourcemapInlineSources.ts, 1, 3))
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/optionsSourcemapInlineSources.ts ===
2+
3+
var a = 10;
4+
>a : number
5+
>10 : number
6+

tests/baselines/reference/optionsSourcemapInlineSourcesMapRoot.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/optionsSourcemapInlineSourcesMapRoot.js.map

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
===================================================================
2+
JsFile: optionsSourcemapInlineSourcesMapRoot.js
3+
mapUrl: local/optionsSourcemapInlineSourcesMapRoot.js.map
4+
sourceRoot:
5+
sources: ../optionsSourcemapInlineSourcesMapRoot.ts
6+
sourcesContent: ["\nvar a = 10;"]
7+
===================================================================
8+
-------------------------------------------------------------------
9+
emittedFile:tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.js
10+
sourceFile:../optionsSourcemapInlineSourcesMapRoot.ts
11+
-------------------------------------------------------------------
12+
>>>var a = 10;
13+
1 >
14+
2 >^^^^
15+
3 > ^
16+
4 > ^^^
17+
5 > ^^
18+
6 > ^
19+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
20+
1 >
21+
>
22+
2 >var
23+
3 > a
24+
4 > =
25+
5 > 10
26+
6 > ;
27+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
28+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
29+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
30+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
31+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
32+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
33+
---
34+
>>>//# sourceMappingURL=local/optionsSourcemapInlineSourcesMapRoot.js.map
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.ts ===
2+
3+
var a = 10;
4+
>a : Symbol(a, Decl(optionsSourcemapInlineSourcesMapRoot.ts, 1, 3))
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/compiler/optionsSourcemapInlineSourcesMapRoot.ts ===
2+
3+
var a = 10;
4+
>a : number
5+
>10 : number
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSources'.
2+
3+
4+
!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSources'.
5+
==== tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.ts (0 errors) ====
6+
7+
var a = 10;

tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.js.map

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
===================================================================
2+
JsFile: optionsSourcemapInlineSourcesSourceRoot.js
3+
mapUrl: optionsSourcemapInlineSourcesSourceRoot.js.map
4+
sourceRoot: local/
5+
sources: optionsSourcemapInlineSourcesSourceRoot.ts
6+
sourcesContent: ["\nvar a = 10;"]
7+
===================================================================
8+
-------------------------------------------------------------------
9+
emittedFile:tests/cases/compiler/optionsSourcemapInlineSourcesSourceRoot.js
10+
sourceFile:optionsSourcemapInlineSourcesSourceRoot.ts
11+
-------------------------------------------------------------------
12+
>>>var a = 10;
13+
1 >
14+
2 >^^^^
15+
3 > ^
16+
4 > ^^^
17+
5 > ^^
18+
6 > ^
19+
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
20+
1 >
21+
>
22+
2 >var
23+
3 > a
24+
4 > =
25+
5 > 10
26+
6 > ;
27+
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
28+
2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0)
29+
3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0)
30+
4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0)
31+
5 >Emitted(1, 11) Source(2, 11) + SourceIndex(0)
32+
6 >Emitted(1, 12) Source(2, 12) + SourceIndex(0)
33+
---
34+
>>>//# sourceMappingURL=optionsSourcemapInlineSourcesSourceRoot.js.map
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @mapRoot: local
2+
// @inlineSourceMap: true
3+
4+
var a = 10;

0 commit comments

Comments
 (0)