[Angular] Angular material 再做build完成時會出錯

  • 88
  • 0
  • 2018-12-10

ng build --prod --build-optimizer=false

Have the same issue after updating both @angular/material and @angular/cdk from 6.3.0 to 6.4.6 .
When I used "ng build --prod"
not only datepicker, the mat-tree combined with mat-tree also got error. Besides, the property [panelWidth] of mat-input not work either.

the error from mat-tree as below:

ERROR Error: Uncaught (in promise): TypeError: a.ngOnDestroy is not a function
TypeError: a.ngOnDestroy is not a function
    at Ua (main.a04e041dad630a65e567.js:1) 
    at j (polyfills.99b05666391ec91781c2.js:1)
    at polyfills.99b05666391ec91781c2.js:1
    at e.invokeTask (polyfills.99b05666391ec91781c2.js:1)
    at Object.onInvokeTask (main.a04e041dad630a65e567.js:1)
    at e.invokeTask (polyfills.99b05666391ec91781c2.js:1)
    at t.runTask (polyfills.99b05666391ec91781c2.js:1)
    at d (polyfills.99b05666391ec91781c2.js:1)
    at t.invokeTask [as invoke] (polyfills.99b05666391ec91781c2.js:1)
    at _ (polyfills.99b05666391ec91781c2.js:1)

When using "ng build --prod --build-optimizer=false",
everything are working excellent!

@angular/cli : 6.0.8
@angular/cdk : 6.4.6
@angular/material : 6.4.6

參考資料:

1. datepicker opens but is blank with build-optimizer (aot) enable, https://github.com/angular/material2/issues/12199