From a5ea55a63668ed8a5fdd5df1822d002e35aa9c91 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 8 Feb 2019 22:10:20 +0000 Subject: [PATCH] fix(core): use the correct template URL in render3 JIT compilation (#28055) Previously JIT compiled components did not use the correct URL if the template was resolved from a `templateUrl`. PR Close #28055 --- packages/core/src/render3/jit/directive.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/render3/jit/directive.ts b/packages/core/src/render3/jit/directive.ts index 57a217b87f..81c785c328 100644 --- a/packages/core/src/render3/jit/directive.ts +++ b/packages/core/src/render3/jit/directive.ts @@ -54,11 +54,11 @@ export function compileComponent(type: Type, metadata: Component): void { throw new Error(error.join('\n')); } - const sourceMapUrl = `ng://${renderStringify(type)}/template.html`; + const templateUrl = metadata.templateUrl || `ng:///${renderStringify(type)}/template.html`; const meta: R3ComponentMetadataFacade = { ...directiveMetadata(type, metadata), typeSourceSpan: - compiler.createParseSourceSpan('Component', renderStringify(type), sourceMapUrl), + compiler.createParseSourceSpan('Component', renderStringify(type), templateUrl), template: metadata.template || '', preserveWhitespaces: metadata.preserveWhitespaces || false, styles: metadata.styles || EMPTY_ARRAY, @@ -71,7 +71,7 @@ export function compileComponent(type: Type, metadata: Component): void { interpolation: metadata.interpolation, viewProviders: metadata.viewProviders || null, }; - ngComponentDef = compiler.compileComponent(angularCoreEnv, sourceMapUrl, meta); + ngComponentDef = compiler.compileComponent(angularCoreEnv, templateUrl, meta); // When NgModule decorator executed, we enqueued the module definition such that // it would only dequeue and add itself as module scope to all of its declarations,