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,