angular-architects/ngrx-toolkit

Build errors with 18.0.2

Closed this issue · 19 comments

Just added the toolkit ^18.0.2 to my project with @ngrx/signals ^18.0.2 and I get the following build errors after adding withDevtools to a single signalStore.

X [ERROR] TS2307: Cannot find module '@ngrx/store/src/models' or its corresponding type declarations. [plugin angular-compiler]

node_modules/@angular-architects/ngrx-toolkit/lib/redux-connector/create-redux.d.ts:1:42:
  1 │ import { ActionCreator, ActionType } from "@ngrx/store/src/models";
    ╵                                           ~~~~~~~~~~~~~~~~~~~~~~~~

X [ERROR] TS2307: Cannot find module '@ngrx/store/src/models' or its corresponding type declarations. [plugin angular-compiler]

node_modules/@angular-architects/ngrx-toolkit/lib/redux-connector/model.d.ts:4:60:
  4 │ ...ctionCreator, ActionType, Prettify } from '@ngrx/store/src/models';
    ╵                                              ~~~~~~~~~~~~~~~~~~~~~~~~

OK I need @ngrx/store installed as a dependency as well, is there a document to explain the setup and also what I can achieve with the dev tools?

@caboodal, that's a bug. we will make the redux-connector as a second entrypoint. by that, you only need @ngrx/store if you use the connector.

the only documentation so far is the README. there is not so much you can do at the moment. What kind of requirements would you have?

I was keen to be able to visualize the signal store state like I did with the redux pattern, that was incredibly useful. I can't find the Ngrx Devtools extension in the Chrome store to progress any further?

@caboodal It is the same Redux extension you use for the Ngrx Devtools. You just add withDevtools and the Redux Devtools will show the NgRx Signal Store.

Ah OK I thought I'd tried that, OK no worries I'll take another look.

@caboodal did it work?

@caboodal Can you do me a favor and check what compilerOptions -> moduleResolution in your tsconfig.json is set to? I get the same error with moduleResolution: bundler. Some other options like node10 worked fine.

@caboodal did it work?

Yes it did, I did uninstall it the other day so just reinstalled it and I can now see my state

@caboodal Can you do me a favor and check what compilerOptions -> moduleResolution in your tsconfig.json is set to? I get the same error with moduleResolution: bundler. Some other options like node10 worked fine.

"moduleResolution": "node"

We are getting the same build error (^18.0.2 versions). We've tried with moduleResolution of "node" and "node10" - no luck.

@ngrx/store

I installed @ngrx/store as a dependency to make it work, I assume once the bug is resolved we can then remove that superfluous dependency again.

As there seems to be a few responses I've reopened the issue.

Hi Team, We are using angular latest version and ngrx-toolkit as well. In our team also facing the same issue. Attaching the screenshot for reference.
image

@maniya108 sorry for that. the quick workaround is to install @ngrx/store. We will soon have the fix which puts the redux connector as second entry point, meaning, you need @ngrx/store only, if you USE the connector.

Starting vom 18.0.3, you should not get any compilation errors anymore.

If you use the redux-connector, you must import it via a secondary entrypoint (see docs) and then you require @ngrx/store.

@maniya108, @caboodal @the1979: can somebody of you confirm that it is now working for you as well? Unfortunately, I was not able to reproduce it.

This seems to be relevant to this issue

This update to 18.0.3 allowed me to pull out @ngrx/store of the dependencies to get the toolkit working on Stackblitz. No more error like the one in this issue.

It also fixed type issues I had with updateState taking in incorrect types without @ngrx/store being imported. Now it detects type errors without it.

Starting vom 18.0.3, you should not get any compilation errors anymore.

If you use the redux-connector, you must import it via a secondary entrypoint (see docs) and then you require @ngrx/store.

@maniya108, @caboodal @the1979: can somebody of you confirm that it is now working for you as well? Unfortunately, I was not able to reproduce it.

@rainerhahnekamp I can confirm that 18.0.3 fixes it for us. Thank you!

Great, thanks for your quick response!

Hi @rainerhahnekamp

Everything now building successfully without the need for a dependency on @ngrx/store, many thanks!

Sorry for the slow response, just returned from holiday :-)