fetrarij / ngx-daterangepicker-material

Pure Angular 2+ date range picker with material design theme, a demo here:
https://fetrarij.github.io/ngx-daterangepicker-material/
MIT License
246 stars 247 forks source link

dayjs.extend(localeData) gets optimised out in Angular build --prod causing error "TypeError: ae.weekdaysMin is not a function" #405

Closed manwithtwowatches closed 2 years ago

manwithtwowatches commented 2 years ago

Versions

Describe the bug It seems that when building and Angular 11 project for production with "ng build --prod" there are certain parts of the code that get optimised out, causing errors. Specifically line 5 of daterangepicker.config.ts "dayjs.extend(localeData)" seems to be gone, causing an error on line 38 "daysOfWeek: dayjs.weekdaysMin(),":

Uncaught TypeError: ae.weekdaysMin is not a function

Naturally, since the extension didn't happen, this function is not present on the dayjs object.

Screenshots In the Chrome debugger you can see the lines are greyed out, which I'm assuming means that the line that the sourcemap is pointing to does not actually exist in the minified production code. Screenshot from 2021-11-04 21-59-53

Has anyone actually got this version working on a production built Angular 11+ app?

manwithtwowatches commented 2 years ago

This was fixed by creating a fresh Angular 11 project with all the latest packages (11.2.14/15).