a custom collection-service...
@Injectable({
providedIn: 'root'
})
export class ComponentService extends EntityCollectionServiceBase<Component> {
constructor(serviceElementsFactory: EntityCollectionServiceElementsFactory) {
super('Component', serviceElementsFactory);
}
}
and a custom data-service...
@Injectable({
providedIn: 'root'
})
export class ComponentDataService extends DefaultDataService<Component> {
constructor(http: HttpClient, httpUrlGenerator: HttpUrlGenerator, logger: Logger) {
super('Component', http, httpUrlGenerator);
logger.log('Created custom Component EntityDataService');
}
getAll(): Observable<Component[]> {
return super.getAll().pipe(map(components => components.map(component => this.mapComponent(component))));
}
getById(id: string | number): Observable<Component> {
return super.getById(id).pipe(map(component => this.mapComponent(component)));
}
getWithQuery(params: string | QueryParams): Observable<Component[]> {
return super.getWithQuery(params).pipe(map(components => components.map(component => this.mapComponent(component))));
}
private mapComponent(component: Component): Component {
return {...component};
}
}
and registering the data-service...
export class AppStoreModule {
constructor(@Optional() @SkipSelf() parentModule: AppStoreModule,
private entityDataService: EntityDataService,
private componentDataService: ComponentDataService) {
throwIfAlreadyLoaded(parentModule, 'AppStoreModule');
entityDataService.registerService('Component', componentDataService);
}
It all works perfectly fine when I then call load() on the data-service. however, once i test for production:
ng serve --prod
the data-service will not get called anymore, also any default data-services are not called (as if they have been removed by the build optimizer)
if i start like this ng serve --prod --optimizer=false
it works fine again...
so i am not entirely sure whether this is a ngrx issue in the first place or rather a cli compiler problem.
"@angular/animations": "8.2.0",
"@angular/cdk": "8.1.2",
"@angular/common": "8.2.0",
"@angular/compiler": "8.2.0",
"@angular/core": "8.2.0",
"@angular/forms": "8.2.0",
"@angular/platform-browser": "8.2.0",
"@angular/platform-browser-dynamic": "8.2.0",
"@angular/router": "8.2.0",
"@ngrx/data": "8.2.0",
"@ngrx/effects": "8.2.0",
"@ngrx/entity": "8.2.0",
"@ngrx/router-store": "8.2.0",
"@ngrx/store": "8.2.0",
"@angular-devkit/build-angular": "0.802.0",
"@angular/cli": "8.2.0",
"@angular/compiler-cli": "8.2.0",
"@angular/language-service": "8.2.0",
"@ngrx/store-devtools": "8.2.0",
"zone.js": "0.10.1"
[ ] Yes (Assistance is provided if you need help submitting a pull request)
[x] No
I can confirm this!
OK, seems this is related to the following: https://github.com/ng-packagr/ng-packagr/issues/1307
So, it is highly unlikely this to be a NGRX issue. To verify this, i have built with es5 as the target (in tsconfig.json).
Then, doing a --prod build without any flags, it all worked as expected.
This issue can be closed. With the latest version of @angular-devkit/build-optimizer (0.802.2)
(https://github.com/angular/angular-cli/releases)
Builds now work again as expected, also for es2015 targets.
Most helpful comment
This issue can be closed. With the latest version of @angular-devkit/build-optimizer (0.802.2)
(https://github.com/angular/angular-cli/releases)
Builds now work again as expected, also for es2015 targets.