【发布时间】:2018-12-04 20:22:03
【问题描述】:
尝试构建一个 Angular 6 应用程序。使用--prod时出现以下错误
ERROR in Error during template compile of 'AppModule'
Expression form not supported in 'reducers'
'reducers' contains the error at app/app.module.ts(48,3).
app.module.ts
import AuthEffects from './store/auth/auth.effects';
import ContentEffects from './store/content/content.effects';
import NavigationEffects from './store/navigation/navigation.effects';
import ConfigEffects from './store/config/config.effects';
import { ICommonAppState } from './app.state';
import { reducer as authReducer, key as authKey } from './store/auth';
import { reducer as configReducer, key as configKey } from './store/config';
import { reducer as contentReducer, key as contentKey } from './store/content';
import { reducer as navigationReducer, key as navigationKey } from './store/navigation';
import { PageContainerComponent } from './page-container/page-container.component';
import { BenefitsComponent } from './+benefits/benefits.component';
import { NavigationComponent } from './navigation/navigation.component';
const enhancers = [];
if (!environment.production) {
enhancers.push(StoreDevtoolsModule.instrument({ maxAge: 10 }));
}
export const reducers: ActionReducerMap<ICommonAppState> = {
[authKey]: authReducer,
[configKey]: configReducer,
[navigationKey]: navigationReducer,
[contentKey]: contentReducer,
};
const effects = [AuthEffects, ConfigEffects, NavigationEffects, ContentEffects];
@NgModule({
declarations: [AppComponent, NavigationComponent, PageContainerComponent, BenefitsComponent],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
SharedComponentsModule,
StoreModule.forRoot(reducers),
EffectsModule.forRoot(effects),
...enhancers,
],
providers: [
{ provide: APP_BASE_HREF, useValue: '/content-manager/' },
{ provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true },
DiscoveryService,
AuthService,
JWTService,
ConfigService,
ContentService,
NavigationService,
TenantGuard,
AuthGuard,
],
bootstrap: [AppComponent],
})
export class AppModule {}
报告错误的第 48 行似乎是
export const reducers: ActionReducerMap<ICommonAppState> = {
[authKey]: authReducer,
[configKey]: configReducer,
[navigationKey]: navigationReducer,
[contentKey]: contentReducer,
};
我正在使用 Angular 6 和 NgRX 6。我不明白为什么这不起作用。如果我不使用 prod 标志,我已遵循文档,并且我的应用程序构建得很好。但是构建臃肿且缓慢,我更喜欢AOT 构建。
【问题讨论】:
标签: angular ngrx angular2-aot