wishtack / wishtack-steroids

Frontend on Steroids: Reactive Component Loader, RxJS Scavenger...
https://wishtack.io
MIT License
96 stars 16 forks source link

No provider for InjectionToken REACTIVE_COMPONENT_LOADER_MODULE_REGISTRY #181

Closed roseyda closed 5 years ago

roseyda commented 5 years ago

I just install reactive-component-loader + its dependency (rx-scavenger + ng-dynamic-component). The build is OK (JIT and AOT), but when trying to access the website, I got the following console error: "NullInjectorError: No provider for InjectionToken REACTIVE_COMPONENT_LOADER_MODULE_REGISTRY!"

Tested version of the lib: 0.2.5 and 0.2.4 Angular-cli v7.3.8

After taking a look in the code of the lib, I figura out that:

And on master branch:

@NgModule({
    declarations: [
        LazyComponent,
        LazyDirective
    ],
    exports: [
        LazyComponent,
        LazyDirective
    ],
    imports: [
        CommonModule,
        DynamicModule.withComponents([])
    ],
    providers: [
        /* @HACK: Add an empty array to ROUTE token.
         * Otherwise `PreloadAllModules` preloading strategy ends up in infinite loop. */
        provideRoutes([])
    ]
})
export class ReactiveComponentLoaderModule {

    static forRoot() {
        return {
            ngModule: ReactiveComponentLoaderModule,
            providers: [
                {
                    provide: NgModuleFactoryLoader,
                    useClass: SystemJsNgModuleLoader
                }
            ]
        };
    }

    static withModule(moduleInfo: ModuleInfo): ModuleWithProviders {
        return {
            ngModule: ReactiveComponentLoaderModule,
            providers: [
                provideRoutes([
                    {
                        loadChildren: moduleInfo.loadChildren,
                        matcher: noMatch
                    }
                ]),
                {
                    **provide: REACTIVE_COMPONENT_LOADER_MODULE_REGISTRY,**
                    useValue: moduleInfo,
                    multi: true
                }
            ]
        };
    }
}
roseyda commented 5 years ago

Update, I reach to make it work :-) I add to declare the lazy load module in the import of the app module. My issue was that: