[Transforms] Fix other sourcemaps (#8721)

* Update correct sourcemaps

* Fix emit BOM in sourcemap

* Stop emit .js.map when no .js is emitted

* verify and update sourcemaps and sourcemap.txt

* Verify and update systemjs sourcemaps
This commit is contained in:
Yui 2016-05-24 08:52:15 -07:00
parent 9cd96e6929
commit 65a641f33a
20 changed files with 80 additions and 191 deletions

View file

@ -218,7 +218,7 @@ const _super = (function (geti, seti) {
// Write the source map
if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), compilerOptions.emitBOM);
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false);
}
// Record source map data for the test harness.

View file

@ -156,7 +156,7 @@ class CompilerBaselineRunner extends RunnerBase {
if (options.sourceMap || options.inlineSourceMap) {
Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => {
const record = result.getSourceMapRecord();
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
if ((options.noEmitOnError && result.errors.length !== 0) || record === undefined) {
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required.
return null;
}
@ -232,7 +232,7 @@ class CompilerBaselineRunner extends RunnerBase {
}
Harness.Baseline.runBaseline("Correct Sourcemap output for " + fileName, justName.replace(/\.tsx?/, ".js.map"), () => {
if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) {
if ((options.noEmitOnError && result.errors.length !== 0) || result.sourceMaps.length === 0) {
// We need to return null here or the runBaseLine will actually create a empty file.
// Baselining isn't required here because there is no output.
return null;

View file

@ -1432,7 +1432,7 @@ namespace Harness {
}
public getSourceMapRecord() {
if (this.sourceMapData) {
if (this.sourceMapData.length > 0) {
return Harness.SourceMapRecorder.getSourceMapRecord(this.sourceMapData, this.program, this.files);
}
}

View file

@ -1,2 +1,2 @@
//// [computedPropertyNamesSourceMap2_ES5.js.map]
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC,GAAT;QACI,QAAQ,CAAC;IACb,CAAC;OACJ,CAAA"}
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC;IACD,GAAC,OAAO,IAAR;QACI,QAAQ,CAAC;IACb,CAAC;OACJ,CAAA"}

View file

@ -12,34 +12,28 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts
1 >
2 >^^^^
3 > ^
4 > ^^^
5 > ^^^^^^^^^^^^^^^^^^^^^^^^->
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
2 >var
3 > v
4 > =
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
---
>>> _a["hello"] = function () {
1->^^^^
2 > ^^^
3 > ^^^^^^^
4 > ^
5 > ^^^
1->{
4 > ^^^^
1-> = {
>
2 > [
3 > "hello"
4 > ]
5 >
4 >
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(2, 8) Source(2, 6) + SourceIndex(0)
3 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
4 >Emitted(2, 16) Source(2, 14) + SourceIndex(0)
5 >Emitted(2, 19) Source(2, 5) + SourceIndex(0)
4 >Emitted(2, 19) Source(2, 5) + SourceIndex(0)
---
>>> debugger;
1 >^^^^^^^^

File diff suppressed because one or more lines are too long

View file

@ -1116,28 +1116,31 @@ sourceFile:contextualTyping.ts
---
>>> C5T5.foo = function (i, s) {
1->^^^^
2 > ^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^
5 > ^
6 > ^^
7 > ^
2 > ^^^^^
3 > ^^^
4 > ^^^
5 > ^^^^^^^^^^
6 > ^
7 > ^^
8 > ^
1->
> export var foo: (i: number, s: string) => string;
>
2 > foo
3 > =
4 > function(
5 > i
6 > ,
7 > s
2 >
3 > foo
4 > =
5 > function(
6 > i
7 > ,
8 > s
1->Emitted(52, 5) Source(68, 5) + SourceIndex(0)
2 >Emitted(52, 13) Source(68, 8) + SourceIndex(0)
3 >Emitted(52, 16) Source(68, 11) + SourceIndex(0)
4 >Emitted(52, 26) Source(68, 20) + SourceIndex(0)
5 >Emitted(52, 27) Source(68, 21) + SourceIndex(0)
6 >Emitted(52, 29) Source(68, 23) + SourceIndex(0)
7 >Emitted(52, 30) Source(68, 24) + SourceIndex(0)
2 >Emitted(52, 10) Source(68, 5) + SourceIndex(0)
3 >Emitted(52, 13) Source(68, 8) + SourceIndex(0)
4 >Emitted(52, 16) Source(68, 11) + SourceIndex(0)
5 >Emitted(52, 26) Source(68, 20) + SourceIndex(0)
6 >Emitted(52, 27) Source(68, 21) + SourceIndex(0)
7 >Emitted(52, 29) Source(68, 23) + SourceIndex(0)
8 >Emitted(52, 30) Source(68, 24) + SourceIndex(0)
---
>>> return s;
1 >^^^^^^^^

View file

@ -17,7 +17,7 @@ declare class Bar {
EmitSkipped: false
FileName : tests/cases/fourslash/inputFile2.js.map
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,6BAAK,IAAI,EAAG,CAAC,GAAI,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
var y = "my div";
var x = React.createElement("div", { name: y });
//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts

View file

@ -1,2 +1,2 @@
//// [all.js.map]
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;IACA;QAAA;QAAiB,CAAC;QAAD,QAAC;IAAD,CAAC,AAAlB,IAAkB;IAAL,SAAC,IAAI,CAAA;;;;ICAlB;QAAuB,qBAAC;QAAxB;YAAuB,8BAAC;QAAG,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,SAAC,IAAc,CAAA"}
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;IACA;QAAA;QAAiB,CAAC;QAAD,QAAC;IAAD,CAAC,AAAlB,IAAkB;IAAlB,cAAkB;;;;ICAlB;QAAuB,qBAAC;QAAxB;YAAuB,8BAAC;QAAG,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAA5B,cAA4B"}

View file

@ -62,17 +62,11 @@ sourceFile:tests/cases/compiler/ref/a.ts
---
>>> exports.A = A;
1->^^^^
2 > ^^^^^^^^^
3 > ^^^^
4 > ^
2 > ^^^^^^^^^^^^^^
1->
2 > A
3 > { }
4 >
1->Emitted(13, 5) Source(2, 14) + SourceIndex(0)
2 >Emitted(13, 14) Source(2, 15) + SourceIndex(0)
3 >Emitted(13, 18) Source(2, 19) + SourceIndex(0)
4 >Emitted(13, 19) Source(2, 19) + SourceIndex(0)
2 > export class A { }
1->Emitted(13, 5) Source(2, 1) + SourceIndex(0)
2 >Emitted(13, 19) Source(2, 19) + SourceIndex(0)
---
-------------------------------------------------------------------
emittedFile:all.js
@ -150,17 +144,11 @@ sourceFile:tests/cases/compiler/b.ts
---
>>> exports.B = B;
1->^^^^
2 > ^^^^^^^^^
3 > ^^^^
4 > ^
2 > ^^^^^^^^^^^^^^
1->
2 > B
3 > extends A { }
4 >
1->Emitted(24, 5) Source(2, 14) + SourceIndex(1)
2 >Emitted(24, 14) Source(2, 15) + SourceIndex(1)
3 >Emitted(24, 18) Source(2, 29) + SourceIndex(1)
4 >Emitted(24, 19) Source(2, 29) + SourceIndex(1)
2 > export class B extends A { }
1->Emitted(24, 5) Source(2, 1) + SourceIndex(1)
2 >Emitted(24, 19) Source(2, 29) + SourceIndex(1)
---
>>>});
>>>//# sourceMappingURL=all.js.map

View file

@ -1,2 +0,0 @@
//// [all.js.map]
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,0BAA0B"}

View file

@ -1,26 +0,0 @@
===================================================================
JsFile: all.js
mapUrl: all.js.map
sourceRoot:
sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts
===================================================================
-------------------------------------------------------------------
emittedFile:all.js
sourceFile:tests/cases/compiler/ref/a.ts
-------------------------------------------------------------------
>>>var __extends = (this && this.__extends) || function (d, b) {
>>> for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
>>> function __() { this.constructor = d; }
>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
>>>};
>>>// This should be an error
1 >
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^^->
1 >
>
2 >// This should be an error
1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(6, 27) Source(2, 27) + SourceIndex(0)
---
>>>//# sourceMappingURL=all.js.map

View file

@ -1,2 +0,0 @@
//// [all.js.map]
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AACA,0BAA0B"}

View file

@ -1,21 +0,0 @@
===================================================================
JsFile: all.js
mapUrl: all.js.map
sourceRoot:
sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts
===================================================================
-------------------------------------------------------------------
emittedFile:all.js
sourceFile:tests/cases/compiler/ref/a.ts
-------------------------------------------------------------------
>>>// This should be an error
1 >
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^^->
1 >
>
2 >// This should be an error
1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(1, 27) Source(2, 27) + SourceIndex(0)
---
>>>//# sourceMappingURL=all.js.map

View file

@ -1,2 +1,2 @@
//// [all.js.map]
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;YACA;gBAAA;gBAAiB,CAAC;gBAAD,QAAC;YAAD,CAAC,AAAlB,IAAkB;YAAlB,iBAAkB,CAAA;;;;;;;;;;;;;;;YCAlB;gBAAuB,qBAAC;gBAAxB;oBAAuB,8BAAC;gBAAG,CAAC;gBAAD,QAAC;YAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;YAA5B,iBAA4B,CAAA"}
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;;;;;;;;YACA;gBAAA;gBAAiB,CAAC;gBAAD,QAAC;YAAD,CAAC,AAAlB,IAAkB;;QAClB,CAAC;;;;;;;;;;;;;;YCDD;gBAAuB,qBAAC;gBAAxB;oBAAuB,8BAAC;gBAAG,CAAC;gBAAD,QAAC;YAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;;QAAA,CAAC"}

View file

@ -13,13 +13,13 @@ sourceFile:tests/cases/compiler/ref/a.ts
>>> function __() { this.constructor = d; }
>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
>>>};
>>>System.register("ref/a", [], function(exports_1, context_1) {
>>>System.register("ref/a", [], function (exports_1, context_1) {
>>> "use strict";
>>> var __moduleName = context_1 && context_1.id;
>>> var A;
>>> return {
>>> setters:[],
>>> execute: function() {
>>> setters: [],
>>> execute: function () {
>>> A = (function () {
1 >^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^->
@ -66,34 +66,32 @@ sourceFile:tests/cases/compiler/ref/a.ts
4 >Emitted(17, 18) Source(2, 19) + SourceIndex(0)
---
>>> exports_1("A", A);
1->^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^
3 > ^
1->
2 > export class A { }
3 >
1->Emitted(18, 13) Source(2, 1) + SourceIndex(0)
2 >Emitted(18, 30) Source(2, 19) + SourceIndex(0)
3 >Emitted(18, 31) Source(2, 19) + SourceIndex(0)
>>> }
1->^^^^^^^^
2 > ^
1->
>
2 >
1->Emitted(19, 9) Source(3, 1) + SourceIndex(0)
2 >Emitted(19, 10) Source(3, 2) + SourceIndex(0)
---
-------------------------------------------------------------------
emittedFile:all.js
sourceFile:tests/cases/compiler/b.ts
-------------------------------------------------------------------
>>> }
>>> }
>>> };
>>>});
>>>System.register("b", ["ref/a"], function(exports_2, context_2) {
>>>System.register("b", ["ref/a"], function (exports_2, context_2) {
>>> "use strict";
>>> var __moduleName = context_2 && context_2.id;
>>> var a_1;
>>> var B;
>>> var a_1, B;
>>> return {
>>> setters:[
>>> setters: [
>>> function (a_1_1) {
>>> a_1 = a_1_1;
>>> }],
>>> execute: function() {
>>> }
>>> ],
>>> execute: function () {
>>> B = (function (_super) {
1 >^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^->
@ -162,17 +160,14 @@ sourceFile:tests/cases/compiler/b.ts
6 >Emitted(39, 23) Source(2, 29) + SourceIndex(1)
---
>>> exports_2("B", B);
1->^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^
3 > ^
1->
2 > export class B extends A { }
3 >
1->Emitted(40, 13) Source(2, 1) + SourceIndex(1)
2 >Emitted(40, 30) Source(2, 29) + SourceIndex(1)
3 >Emitted(40, 31) Source(2, 29) + SourceIndex(1)
---
>>> }
>>> }
1->^^^^^^^^
2 > ^
1->
2 >
1->Emitted(41, 9) Source(2, 29) + SourceIndex(1)
2 >Emitted(41, 10) Source(2, 30) + SourceIndex(1)
---
>>> };
>>>});
>>>//# sourceMappingURL=all.js.map

View file

@ -1,2 +0,0 @@
//// [all.js.map]
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AACA,oBAAoB"}

View file

@ -1,26 +0,0 @@
===================================================================
JsFile: all.js
mapUrl: all.js.map
sourceRoot:
sources: tests/cases/compiler/ref/a.ts,tests/cases/compiler/b.ts
===================================================================
-------------------------------------------------------------------
emittedFile:all.js
sourceFile:tests/cases/compiler/ref/a.ts
-------------------------------------------------------------------
>>>var __extends = (this && this.__extends) || function (d, b) {
>>> for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
>>> function __() { this.constructor = d; }
>>> d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
>>>};
>>>// This should error
1 >
2 >^^^^^^^^^^^^^^^^^^^^
3 > ^^^^^^^^^^->
1 >
>
2 >// This should error
1 >Emitted(6, 1) Source(2, 1) + SourceIndex(0)
2 >Emitted(6, 21) Source(2, 21) + SourceIndex(0)
---
>>>//# sourceMappingURL=all.js.map

View file

@ -1,2 +1,2 @@
//// [all.js.map]
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/b.ts","tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AAAA,iCAAiC;AACjC;IAAA;IAEA,CAAC;IAAD,UAAC;AAAD,CAAC,AAFD,IAEC;;;ICFD,+BAA+B;IAC/B;QAAA;QAEA,CAAC;QAAD,QAAC;IAAD,CAAC,AAFD,IAEC;IAFY,SAAC,IAEb,CAAA;;;;ICHD;QAAuB,qBAAC;QAAxB;YAAuB,8BAAC;QAAG,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAAf,SAAC,IAAc,CAAA"}
{"version":3,"file":"all.js","sourceRoot":"","sources":["tests/cases/compiler/ref/b.ts","tests/cases/compiler/ref/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":";;;;;AAAA,iCAAiC;AACjC;IAAA;IAEA,CAAC;IAAD,UAAC;AAAD,CAAC,AAFD,IAEC;;;ICFD,+BAA+B;IAC/B;QAAA;QAEA,CAAC;QAAD,QAAC;IAAD,CAAC,AAFD,IAEC;IAFD,cAEC;;;;ICHD;QAAuB,qBAAC;QAAxB;YAAuB,8BAAC;QAAG,CAAC;QAAD,QAAC;IAAD,CAAC,AAA5B,CAAuB,KAAC,GAAI;IAA5B,cAA4B"}

View file

@ -136,19 +136,13 @@ sourceFile:tests/cases/compiler/ref/a.ts
---
>>> exports.A = A;
1->^^^^
2 > ^^^^^^^^^
3 > ^^^^
4 > ^
2 > ^^^^^^^^^^^^^^
1->
2 > A
3 > {
> member: typeof GlobalFoo;
> }
4 >
1->Emitted(20, 5) Source(3, 14) + SourceIndex(1)
2 >Emitted(20, 14) Source(3, 15) + SourceIndex(1)
3 >Emitted(20, 18) Source(5, 2) + SourceIndex(1)
4 >Emitted(20, 19) Source(5, 2) + SourceIndex(1)
2 > export class A {
> member: typeof GlobalFoo;
> }
1->Emitted(20, 5) Source(3, 1) + SourceIndex(1)
2 >Emitted(20, 19) Source(5, 2) + SourceIndex(1)
---
-------------------------------------------------------------------
emittedFile:all.js
@ -226,17 +220,11 @@ sourceFile:tests/cases/compiler/b.ts
---
>>> exports.B = B;
1->^^^^
2 > ^^^^^^^^^
3 > ^^^^
4 > ^
2 > ^^^^^^^^^^^^^^
1->
2 > B
3 > extends A { }
4 >
1->Emitted(31, 5) Source(2, 14) + SourceIndex(2)
2 >Emitted(31, 14) Source(2, 15) + SourceIndex(2)
3 >Emitted(31, 18) Source(2, 29) + SourceIndex(2)
4 >Emitted(31, 19) Source(2, 29) + SourceIndex(2)
2 > export class B extends A { }
1->Emitted(31, 5) Source(2, 1) + SourceIndex(2)
2 >Emitted(31, 19) Source(2, 29) + SourceIndex(2)
---
>>>});
>>>//# sourceMappingURL=all.js.map