diff --git a/packages/compiler-cli/src/ngtsc/shims/src/host.ts b/packages/compiler-cli/src/ngtsc/shims/src/host.ts index 5dcf0af8dc..d30dac5756 100644 --- a/packages/compiler-cli/src/ngtsc/shims/src/host.ts +++ b/packages/compiler-cli/src/ngtsc/shims/src/host.ts @@ -95,11 +95,10 @@ export class GeneratedShimsHostWrapper implements ts.CompilerHost { getNewLine(): string { return this.delegate.getNewLine(); } fileExists(fileName: string): boolean { - const canonical = this.getCanonicalFileName(fileName); // Consider the file as existing whenever 1) it really does exist in the delegate host, or // 2) at least one of the shim generators recognizes it. return this.delegate.fileExists(fileName) || - this.shimGenerators.some(gen => gen.recognize(canonical)); + this.shimGenerators.some(gen => gen.recognize(fileName)); } readFile(fileName: string): string|undefined { return this.delegate.readFile(fileName); } diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts index 71c02f37d6..a27662e909 100644 --- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts +++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts @@ -1550,6 +1550,23 @@ describe('ngtsc behavioral tests', () => { expect(emptyFactory).toContain(`export var ɵNonEmptyModule = true;`); }); + it('should be able to compile an app using the factory shim', () => { + env.tsconfig({'allowEmptyCodegenFiles': true}); + + env.write('test.ts', ` + export {MyModuleNgFactory} from './my-module.ngfactory'; + `); + + env.write('my-module.ts', ` + import {NgModule} from '@angular/core'; + + @NgModule({}) + export class MyModule {} + `); + + env.driveMain(); + }); + it('should generate correct imports in factory stubs when compiling @angular/core', () => { env.tsconfig({'allowEmptyCodegenFiles': true});