From 22c66f0e023383ed6ee45f2f98ac2de3b6573f57 Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Thu, 26 Oct 2017 16:58:45 -0700 Subject: [PATCH] fix(compiler-cli): avoid producing source mappings for host views (#19965) The host view doesn't map back to user code so the template compiler produces a blank `url` for them. PR Close #19965 --- .../compiler-cli/src/transformers/node_emitter.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/compiler-cli/src/transformers/node_emitter.ts b/packages/compiler-cli/src/transformers/node_emitter.ts index 83b9fdd279..df85976e20 100644 --- a/packages/compiler-cli/src/transformers/node_emitter.ts +++ b/packages/compiler-cli/src/transformers/node_emitter.ts @@ -144,12 +144,14 @@ class _NodeEmitterVisitor implements StatementVisitor, ExpressionVisitor { const span = node.sourceSpan; if (span.start.file == span.end.file) { const file = span.start.file; - let source = this._templateSources.get(file); - if (!source) { - source = ts.createSourceMapSource(file.url, file.content, pos => pos); - this._templateSources.set(file, source); + if (file.url) { + let source = this._templateSources.get(file); + if (!source) { + source = ts.createSourceMapSource(file.url, file.content, pos => pos); + this._templateSources.set(file, source); + } + return {pos: span.start.offset, end: span.end.offset, source}; } - return {pos: span.start.offset, end: span.end.offset, source}; } } return null;