'Angular MomentDateTimeAdapter not building after angular 8 update

after updating my angular project I faced some probles due to the breaking changes. Now I have got an Problem with my MomentDateTimeAdapter. I'm using this one.(/ng-pick-datetime-moment).

My application is running perfectly in dev mode but as soon as i try to build productive (ng build --prod) Im getting this error:

ERROR in ..\ng-pick-datetime-moment\moment-adapter\moment-date-time-adapter.class.ts(46,2): Error during template compile of 'MomentDateTimeAdapter' Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Injectable' 'Injectable' calls 'ɵmakeDecorator'.

I took every step described in the angular-update tutorial and updated all my dependencies. Does anyone know how to fix this?



Solution 1:[1]

I don't exactly know why but I found this github entry.

By just adding: "paths": { "@angular/*": ["../node_modules/@angular/*"] }, into my tsconfig.app.json the build is working again.

Solution 2:[2]

This is because ng-pick-datetime-moment-package is embedded with angular 7.

The MomentDateTimeAdapter is also included in the ng-pick-datetime-package. (v 7.0.0) No need to import from ng-pick-datetime-moment package, but from ng-pick-datetime package.

import { MomentDateTimeAdapter, OWL_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from 'ng-pick-datetime/date-time/adapter/moment-adapter/moment-date-time-adapter.class';

Solution 3:[3]

Here the @mat-datetimepicker/core description. So different Angular versions should use different versions of the package.

You can find the Angular 8 version on the 3.x branch.
You can find the Angular 9 version on the 4.x branch.
You can find the Angular 10 version on the 5.x branch.

I changed versions of these dependencies in package.json and it helped

Before(Angular 8):
"@mat-datetimepicker/core": "3.0.0-beta.0", "@mat-datetimepicker/moment": "3.0.0-beta.0",

After(Angular 9):
"@mat-datetimepicker/core": "^4.0.0", "@mat-datetimepicker/moment": "^4.0.0",

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Felix Gerber
Solution 2 Felix Gerber
Solution 3