fix(compiler): look for flat module resources using declaration module path (#15367)

`ngc` would look for flat module resources relative to the flat module index.
`ngc` now looks for flat module resources relative to the `.d.ts` file that declarates
the component.

Fixes #15221

PR Close #15367
This commit is contained in:
Chuck Jazdzewski
2017-03-20 16:31:11 -07:00
committed by Miško Hevery
parent 7354949763
commit 90d2518d9a
19 changed files with 311 additions and 17 deletions

View File

@ -20,6 +20,7 @@ export interface PlatformReflectionCapabilities {
setter(name: string): SetterFn;
method(name: string): MethodFn;
importUri(type: Type<any>): string;
resourceUri(type: Type<any>): string;
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any;
resolveEnum(enumIdentifier: any, name: string): any;
}

View File

@ -226,6 +226,8 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return `./${stringify(type)}`;
}
resourceUri(type: any): string { return `./${stringify(type)}`; }
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {
return runtime;
}

View File

@ -49,6 +49,8 @@ export class Reflector extends ReflectorReader {
importUri(type: any): string { return this.reflectionCapabilities.importUri(type); }
resourceUri(type: any): string { return this.reflectionCapabilities.resourceUri(type); }
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
}

View File

@ -15,6 +15,7 @@ export abstract class ReflectorReader {
abstract annotations(typeOrFunc: /*Type*/ any): any[];
abstract propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]};
abstract importUri(typeOrFunc: /*Type*/ any): string;
abstract resourceUri(typeOrFunc: /*Type*/ any): string;
abstract resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any;
abstract resolveEnum(identifier: any, name: string): any;
}