angular-architects / ngrx-toolkit

Various Extensions for the NgRx Signal Store
MIT License
174 stars 23 forks source link

Build errors with 18.0.2 #79

Closed caboodal closed 3 months ago

caboodal commented 3 months ago

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';
    ╵                                              ~~~~~~~~~~~~~~~~~~~~~~~~
caboodal commented 3 months ago

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?

rainerhahnekamp commented 3 months ago

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

caboodal commented 3 months ago

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?

rainerhahnekamp commented 3 months ago

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

caboodal commented 3 months ago

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

rainerhahnekamp commented 3 months ago

@caboodal did it work?

nelkasovic commented 3 months ago

@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 commented 3 months ago

@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 commented 3 months ago

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

the1979 commented 3 months ago

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

caboodal commented 3 months ago

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

caboodal commented 3 months ago

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

maniya108 commented 3 months ago

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
rainerhahnekamp commented 3 months ago

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

rainerhahnekamp commented 3 months ago

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.

michael-small commented 3 months ago

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.

the1979 commented 3 months ago

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!

rainerhahnekamp commented 3 months ago

Great, thanks for your quick response!

caboodal commented 3 months ago

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 :-)