fix(ivy): allow `R3TestBedCompiler` to work in ngcc-processed apps (#28530)

Previously, `R3TestBedCompiler` was dynamically defining an
`@NgModule`-decorated `CompilerModule` class inside a method call.
Since ngcc only processes top-level classes, this class was not
transformed causing failures in unit tests (see #30121 for details).

This commit fixes it by using `compileNgModuleDefs()` directly (similar
to the fix in #30037).

Fixes #30121

PR Close #28530
This commit is contained in:
George Kalpakas 2019-05-01 02:27:31 +03:00 committed by Kara Erickson
parent 5b80ab372d
commit 066ec33342
1 changed files with 2 additions and 3 deletions

View File

@ -548,9 +548,8 @@ export class R3TestBedCompiler {
}
// TODO(ocombe): make this work with an Injector directly instead of creating a module for it
@NgModule({providers})
class CompilerModule {
}
class CompilerModule {}
compileNgModuleDefs(CompilerModule as NgModuleType<any>, {providers});
const CompilerModuleFactory = new R3NgModuleFactory(CompilerModule);
this._injector = CompilerModuleFactory.create(this.platform.injector).injector;