Correctly set sourceFileInfo for bundle when generating output without creating program

This commit is contained in:
Sheetal Nandi
2019-02-21 12:54:00 -08:00
parent e9fb843e56
commit ad72aef4b1
13 changed files with 204 additions and 14 deletions
+8 -2
View File
@@ -537,7 +537,7 @@ namespace ts {
if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding";
const buildInfo = JSON.parse(buildInfoText) as BuildInfo;
if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationMapText && !buildInfo.bundle.dts)) return buildInfoPath!;
if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts)) return buildInfoPath!;
const ownPrependInput = createInputFiles(
jsFileText,
declarationText!,
@@ -578,7 +578,13 @@ namespace ts {
case buildInfoPath:
const newBuildInfo = JSON.parse(text) as BuildInfo;
newBuildInfo.program = buildInfo.program;
outputFiles.push({ name, text: getBuildInfoText({ program: buildInfo.program, bundle: newBuildInfo.bundle }), writeByteOrderMark });
// Update sourceFileInfo
const { js, dts } = buildInfo.bundle!;
newBuildInfo.bundle!.js!.sources = js!.sources;
if (dts) {
newBuildInfo.bundle!.dts!.sources = dts.sources;
}
outputFiles.push({ name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark });
return;
case declarationFilePath:
if (declarationText === text) return;
@@ -423,7 +423,12 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
"end": 1343,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"helpers": [
"typescript:rest"
]
}
},
"dts": {
"sections": [
@@ -623,7 +623,14 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
"end": 2661,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"helpers": [
"typescript:rest",
"typescript:read",
"typescript:spread"
]
}
},
"dts": {
"sections": [
@@ -435,7 +435,12 @@ const { b, ...rest } = { a: 10, b: 30, yy: 30 };
"end": 2118,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"helpers": [
"typescript:rest"
]
}
},
"dts": {
"sections": [
@@ -406,7 +406,44 @@ console.log(s);
"end": 635,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"prologues": [
{
"file": "/src/third/third_part1.ts",
"text": "\"myPrologue3\";\n\"myPrologue\";",
"directives": [
{
"pos": -1,
"end": -1,
"expression": {
"pos": -1,
"end": -1,
"text": "use strict"
}
},
{
"pos": 0,
"end": 14,
"expression": {
"pos": 0,
"end": 13,
"text": "myPrologue3"
}
},
{
"pos": 14,
"end": 28,
"expression": {
"pos": 14,
"end": 27,
"text": "myPrologue"
}
}
]
}
]
}
},
"dts": {
"sections": [
@@ -367,7 +367,26 @@ console.log(s);
"end": 619,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"prologues": [
{
"file": "/src/third/third_part1.ts",
"text": "",
"directives": [
{
"pos": -1,
"end": -1,
"expression": {
"pos": -1,
"end": -1,
"text": "use strict"
}
}
]
}
]
}
},
"dts": {
"sections": [
@@ -355,7 +355,26 @@ console.log(s);
"end": 588,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"prologues": [
{
"file": "/src/third/third_part1.ts",
"text": "",
"directives": [
{
"pos": -1,
"end": -1,
"expression": {
"pos": -1,
"end": -1,
"text": "use strict"
}
}
]
}
]
}
},
"dts": {
"sections": [
@@ -466,7 +466,12 @@ function forfirstfirst_PART1Rest() { }
"end": 1249,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"helpers": [
"typescript:rest"
]
}
},
"dts": {
"sections": [
@@ -700,7 +700,14 @@ function forfirstfirst_PART1Rest() { }
"end": 2567,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"helpers": [
"typescript:rest",
"typescript:read",
"typescript:spread"
]
}
},
"dts": {
"sections": [
@@ -478,7 +478,12 @@ function forfirstfirst_PART1Rest() { }
"end": 2024,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"helpers": [
"typescript:rest"
]
}
},
"dts": {
"sections": [
@@ -549,7 +549,44 @@ console.log(s);
"end": 634,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"prologues": [
{
"file": "/src/third/third_part1.ts",
"text": "\"myPrologue3\";\n\"myPrologue\";",
"directives": [
{
"pos": -1,
"end": -1,
"expression": {
"pos": -1,
"end": -1,
"text": "use strict"
}
},
{
"pos": 0,
"end": 14,
"expression": {
"pos": 0,
"end": 13,
"text": "myPrologue3"
}
},
{
"pos": 14,
"end": 28,
"expression": {
"pos": 14,
"end": 27,
"text": "myPrologue"
}
}
]
}
]
}
},
"dts": {
"sections": [
@@ -510,7 +510,26 @@ console.log(s);
"end": 618,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"prologues": [
{
"file": "/src/third/third_part1.ts",
"text": "",
"directives": [
{
"pos": -1,
"end": -1,
"expression": {
"pos": -1,
"end": -1,
"text": "use strict"
}
}
]
}
]
}
},
"dts": {
"sections": [
@@ -498,7 +498,26 @@ console.log(s);
"end": 586,
"kind": "sourceMapUrl"
}
]
],
"sources": {
"prologues": [
{
"file": "/src/third/third_part1.ts",
"text": "",
"directives": [
{
"pos": -1,
"end": -1,
"expression": {
"pos": -1,
"end": -1,
"text": "use strict"
}
}
]
}
]
}
},
"dts": {
"sections": [