Platform: Issue upgrading to 8.0.0-rc.0

Created on 31 May 2019  路  9Comments  路  Source: ngrx/platform

Minimal reproduction of the bug/regression with instructions:

App working under 8.0.0-beta.2, upgrading to 8.0.0-rc.0 make serving the app fail with the following message:

ERROR in : Invalid provider for undefined. useClass cannot be undefined.
           Usually it happens when:
           1. There's a circular dependency (might be caused by using index.ts (barrel) files).
           2. Class was used before it was declared. Use forwardRef in this case.
: Can't resolve all parameters for StoreRouterConnectingModule in /app/node_modules/@ngrx/router-store/router-store.d.ts: ([object Object], [object Object], ?, [object Object], [object Object]).

Expected behavior:

The app to work again ; the listed breaking changes don't seem like they should impact the ability to serve the app.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

We use the following packages in 8.0.0-rc.0

  • @ngrx/effects
  • @ngrx/entity
  • @ngrx/router-store
  • @ngrx/store
  • @ngrx/store-devtools

@angular and its friends are all in ^8.0.0, node is 10.14.1.

Other information:

I would be willing to submit a PR to fix this issue

[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

I would love to, but could not find the root cause so far.
Looking at https://github.com/ngrx/platform/compare/8.0.0-beta.2...8.0.0-rc.0, no change would obviously break our code, which make it look like a circular dependency got added when adding MinimalRouterStateSerializer.

8.x Needs Reproduction bug

Most helpful comment

@DenisSemionov the fix for this issue hasn't been released yet.
You can install it from our nightlies

All 9 comments

Do you provide your own serializer by any chance @adrogon ?
Could you share your usage of StoreRouterConnectingModule.forRoot?

Broken either way, with serializer specified or with any routerState, e.g.
StoreRouterConnectingModule.forRoot({
routerState: RouterState.Full
})

BTW, it only affects AOT, JIT seems to be Ok, if I am not mistaken.

Will someone provide a small reproduction of the issue?

@Domratchev is correct, this happens when AOT is enabled.

@brandonroberts Here is a simple reproduction:

Generate a dummy application

ng new repro && cd repro && ng update rxjs @angular/cli @angular/core && npm i @ngrx/[email protected] @ngrx/[email protected] --save

Load NgRx modules

src/app/app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { StoreModule } from '@ngrx/store';
import { StoreRouterConnectingModule } from '@ngrx/router-store';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StoreModule.forRoot({}),
    StoreRouterConnectingModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Serve the app with AOT enabled

ng serve --aot

@brandonroberts @timdeschryver

I can confirm that issue. It only occurs in AOT. Had the same problem when activating the AOT flag.

There are two different issues.

1.) Just loading (without any assignment in a module, etc) something from '@ngrx/router-store':
import { StoreRouterConnectingModule } from '@ngrx/router-store'; // @ngrx v8.0.0-rc.0

error:

ERROR in : Can't resolve all parameters for StoreRouterConnectingModule in /node_modules/@ngrx/router-store/router-store.d.ts: ([object Object], [object Object], ?, [object Object], [object Object]).
2.) This error occurs when using it in context of a module.
import { StoreRouterConnectingModule } from '@ngrx/router-store';

@NgModule({
  declarations: [
    AppComponent,
  ],
  bootstrap: [
    AppComponent,
  ],
  imports: [
     StoreRouterConnectingModule.forRoot({
       routerState: RouterState.Minimal,
     }),
})
export class AppModule { }

error:

Invalid provider for undefined. useClass cannot be undefined.
Usually it happens when:
1. There's a circular dependency (might be caused by using index.ts (barrel) files).
2. Class was used before it was declared. Use forwardRef in this case.

Repro: https://github.com/timdeschryver/sandbox-version-eight
Weird that the example-app didn't caught this, my guess is that this is because it has @ngrx/router-store set as a path.

I'm getting the same error with 8.0.0-beta.0, 8.0.0-beta.1, 8.0.0-beta.2 and 8.0.0-rc.0 on build. Currently I'm using 7.4.0, but it also has its issues (I have opened an issue https://github.com/ngrx/platform/issues/1905)

@DenisSemionov the fix for this issue hasn't been released yet.
You can install it from our nightlies

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NathanWalker picture NathanWalker  路  3Comments

Matmo10 picture Matmo10  路  3Comments

bhaidar picture bhaidar  路  3Comments

oxiumio picture oxiumio  路  3Comments

hccampos picture hccampos  路  3Comments