目前我正在尝试使用新的NgRX creator函数构建一个Angular + NgRX 8应用程序。但是当我为生产环境构建时,会出现以下错误:
在装饰器中不支持函数调用,但在'reducers'中调用了'createReducer'。
在开发模式下完全没有问题。
请求的reducer如下:
export interface State extends EntityState<Request> {
loading: boolean;
error: any;
}
export const initialState = adapter.getInitialState({
loading: false,
error: null
});
export const reducer = createReducer(
initialState,
on(RequestsActions.loadRequestsSuccess, (state, { requests }) => adapter.addAll(requests, {...state, loading: false})),
on(RequestsActions.loadRequestsFailed, (state, { error }) => ({...state, error, loading: false})),
on(RequestsActions.deleteRequestSuccess, (state, { id }) => adapter.removeOne(id, state))
);
并与其他reducer一起在index.ts文件中编写。
export const reducers = {
requests: reducer
// [...]
}
而 StoreModule 是这样与 reducers 映射一起导入的
@NgModule({
imports: [
CommonModule,
StoreModule.forFeature('requests', reducers),
EffectsModule.forFeature(effects),
// [...]
]
})
export class RequestsModule {}
你有任何想法吗?谢谢和干杯!