In my Angular project, the structure is organized as follows:
/(root or repo folder)
|_ projects
|_ mylib (main library to be exported from the repo)
|_ sample-app (created for testing 'mylib' project in other projects)
To manage application state, I am using ngRx with Angular8.2.5, ngRx 8.3.0, and RxJs 6.5.3.
When running npm start
, the 'sample-app' project starts while 'mylib' project is lazily loaded.
Here is how I set up the app store/state:
In sample-app/app.module.ts
:
StoreModule.forRoot({}, {
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
strictStateSerializability: true,
strictActionSerializability: true,
},
}),
!environment.production ? StoreDevtoolsModule.instrument({ name: 'My Sample App' }) : [],
In mylib/mylib.module.ts
:
import { libReducer} from './shared/store/lib.store';
StoreModule.forFeature('libState', libReducer)
The issue arises during the project build process when using ng build
.
Error message:
https://i.sstatic.net/1KpZL.png
Logs do not provide much insight into the error.
The problem gets resolved if changing the definition inside mylib.module.ts
to:
StoreModule.forFeature('libState', subFeatureOneReducer)
I prefer to keep all reducers in one place and only reference StoreModule.forFeature
once within 'mylib' project.
Looking for guidance on setting up store/reducers correctly to resolve the build error.