fix(compiler): don’t use ng:// in AOT source maps, and never point to the original source file

This is important to not confuse users nor downstream tools that
consume our source maps. For generated content for which we don’t
have an original source file, we use the generated file now.

Fixes #19538
This commit is contained in:
Tobias Bosch
2017-10-04 13:37:27 -07:00
committed by Alex Rickabaugh
parent 5b5108363d
commit 01f711281c
16 changed files with 42 additions and 56 deletions

View File

@ -13,7 +13,6 @@ import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '@angular/compiler
import {stripSourceMapAndNewLine} from './abstract_emitter_spec';
const someGenFilePath = 'somePackage/someGenFile';
const someSourceFilePath = 'somePackage/someSourceFile';
const anotherModuleUrl = 'somePackage/someOtherPath';
const sameModuleIdentifier = new o.ExternalReference(null, 'someLocalId', null);
@ -36,7 +35,7 @@ export function main() {
function emitStmt(stmt: o.Statement | o.Statement[], preamble?: string): string {
const stmts = Array.isArray(stmt) ? stmt : [stmt];
const source = emitter.emitStatements(someSourceFilePath, someGenFilePath, stmts, preamble);
const source = emitter.emitStatements(someGenFilePath, stmts, preamble);
return stripSourceMapAndNewLine(source);
}
@ -435,7 +434,7 @@ export function main() {
new o.ReturnStatement(o.variable('someVar', null, referenceSpan), returnSpan)
])])];
const {sourceText, context} =
emitter.emitStatementsAndContext('a.ts', 'a.ts', statements, '/* some preamble /*\n\n');
emitter.emitStatementsAndContext('a.ts', statements, '/* some preamble /*\n\n');
const spanOf = (text: string, after: number = 0) => {
const location = sourceText.indexOf(text, after);
const {line, col} = calculateLineCol(sourceText, location);