Skip to content

NGCC only transforms top level modules #30121

@alan-agius4

Description

@alan-agius4

@gkalpak and myself saw the below issue when running tests under ivy

Error: ASSERTION ERROR: NgModule 'CompilerModule' is not a subtype of 'NgModuleType'.
    at throwError (http://localhost:9876/_karma_webpack_/vendor.js:62601:11)
    at assertDefined (http://localhost:9876/_karma_webpack_/vendor.js:62595:9)
    at new NgModuleRef$1 (http://localhost:9876/_karma_webpack_/vendor.js:86038:22)
    at NgModuleFactory$1.create (http://localhost:9876/_karma_webpack_/vendor.js:86109:16)

It seems the issue is that NGCC only transforms top level modules.

@NgModule({providers})
class CompilerModule {
}
const CompilerModuleFactory = new R3NgModuleFactory(CompilerModule);
this._injector = CompilerModuleFactory.create(this.platform.injector).injector;
return this._injector;

with ngcc the output of it is

        class CompilerModule {
        }
        CompilerModule.decorators = [
            { type: NgModule, args: [{ providers },] },
        ];
        /** @type {?} */
        const CompilerModuleFactory = new ɵNgModuleFactory(CompilerModule);
        this._injector = CompilerModuleFactory.create(this.platform.injector).injector;
        return this._injector;

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtime

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions