Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue upgrading to 8.0.0-rc.0 #1902

Closed
adrogon opened this issue May 31, 2019 · 9 comments · Fixed by #1904 or TypescriptID/platform#225
Closed

Issue upgrading to 8.0.0-rc.0 #1902

adrogon opened this issue May 31, 2019 · 9 comments · Fixed by #1904 or TypescriptID/platform#225

Comments

@adrogon
Copy link

adrogon commented May 31, 2019

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 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.

@timdeschryver
Copy link
Member

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

@Domratchev
Copy link

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

@Domratchev
Copy link

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

@brandonroberts
Copy link
Member

Will someone provide a small reproduction of the issue?

@adrogon
Copy link
Author

adrogon commented May 31, 2019

@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/store@8.0.0-rc.0 @ngrx/router-store@8.0.0-rc.0 --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

@SerkanSipahi
Copy link
Contributor

SerkanSipahi commented Jun 1, 2019

@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.

@timdeschryver
Copy link
Member

timdeschryver commented Jun 1, 2019

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.

@liesahead
Copy link

liesahead commented Jun 3, 2019

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 #1905)

@timdeschryver
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants