From 066ec33342c371e6a1a11e35a6c0d44f94b1c96a Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 1 May 2019 02:27:31 +0300 Subject: [PATCH] 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 --- packages/core/testing/src/r3_test_bed_compiler.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/core/testing/src/r3_test_bed_compiler.ts b/packages/core/testing/src/r3_test_bed_compiler.ts index b2ff479ad2..e18e7f81fa 100644 --- a/packages/core/testing/src/r3_test_bed_compiler.ts +++ b/packages/core/testing/src/r3_test_bed_compiler.ts @@ -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, {providers}); const CompilerModuleFactory = new R3NgModuleFactory(CompilerModule); this._injector = CompilerModuleFactory.create(this.platform.injector).injector;