Skip to content

"Error: HostResourceResolver: could not resolve" when using platform specific templates/styling #2305

@SmailHammour

Description

@SmailHammour

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 7.0.11-2020-11-16-175731-14298
  • Cross-platform modules:
  • Android Runtime: 7.0.1
  • iOS Runtime: 7.0.6
  • Plugin(s):
  • NativeScript-Angular: 11.0.0
  • Angular: 11.0.2

Describe the bug
When using platform specific templates (template.component.android.html/template.component.ios.html) an error is thrown. The code compiles but I’m seeing this in the console.

/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/core/src/compiler.js:379
                finally { if (e_2) throw e_2.error; }
                                   ^
Error: HostResourceResolver: could not resolve ./template.component.html in context of /path/to/app/acme-app/src/app/presentation/components/template/template.component.ts)
    at AdapterResourceLoader.resolve (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/resource/src/loader.js:59:23)
    at ComponentDecoratorHandler.analyze (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/annotations/src/component.js:205:59)
    at TraitCompiler.analyzeTrait (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:347:40)
    at analyze (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:299:58)
    at _loop_1 (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:321:21)
    at TraitCompiler.analyzeClass (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:327:35)
    at visit (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:109:27)
    at visitNodes (/path/to/app/acme-app/node_modules/typescript/lib/typescript.js:27037:30)
    at Object.forEachChild (/path/to/app/acme-app/node_modules/typescript/lib/typescript.js:27275:24)
    at visit (/path/to/app/acme-app/node_modules/@angular/compiler-cli/src/ngtsc/transform/src/compilation.js:111:20)

To Reproduce
Use platform specific templates

import {Component} from '@angular/core';
@Component({
  selector: 'template',
  templateUrl: './template.component.html',
  styleUrls: ['./template.component.scss']
})
export class TemplateComponent {}

template.component.android.html
template.component.ios.html

Expected behavior
Error should not be thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions