ngx-moment icon indicating copy to clipboard operation
ngx-moment copied to clipboard

Angular 13 + ngx-moment 6.0.2: This module is declared with using 'export =

Open vadimwe opened this issue 3 years ago • 9 comments

Multiple error in CLI: This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

Problem goes away if allowSyntheticDefaultImports: true in tsconfig.json

Did you search for duplicate issue? [Yes / No] Yes

Please describe the issue and steps to reproduce, preferably with a code sample / plunker:

Angular update till v13.* Ionic update till 6.* ngx-moment update to 6.0.2 ionic serve/build

  • Angular version? 13
  • TypeScript version? 4.5.4
  • moment version? 2.29.1
  • Are you using moment-timezone? No
  • Are you using the angular-cli? Yes
  • Using Rollup/Webpack/System.js/Ionic/similar? Yes, Ionic

vadimwe avatar Dec 27 '21 09:12 vadimwe

I also faced the same issue with 6.0.2. I think the import statement has been changed to 'import 'moment' from moment;'. Should it be 'import * as moment from 'moment';'? I saw this change while trying between 6.0.1 and 6.0.2.

@vadimwe, Meanwhile, I would advise to switch to 6.0.1 and then try to build the solution.

AravindMakam avatar Dec 30 '21 21:12 AravindMakam

Back porting to 6.0.1 re-introduces this issue https://github.com/urish/ngx-moment/issues/245

pete-mcwilliams avatar Jan 04 '22 14:01 pete-mcwilliams

Enable the allowSyntheticDefaultImports in tsconfig bypass this issue, not sure if the maintainer have to "fix" anything. Maybe for backward compatibility ?

PillowPillow avatar Jan 07 '22 10:01 PillowPillow

If the maintainer changes import moment from 'moment'; back to import * as moment from 'moment'; then the allowSyntheticDefaultImports flag would not need to be set to true in your tsconfig of the project using the dependency.

JaxonWright avatar Jan 10 '22 17:01 JaxonWright

Will @JaxonWright change ever be implemented?

talynone avatar Apr 07 '22 15:04 talynone

+1

Stankman avatar Jan 10 '23 18:01 Stankman

+1

tiberioalunni avatar Feb 06 '23 18:02 tiberioalunni

I am sure you guys wont like my comment as it might not be helpful however i was in your place once. I got rid of moment library all together and moved to date-fns - its much lighter and more robust. Moment was quite good in the early days but now it was getting harder to maintain with changing NG versions.

hassanasad avatar Feb 07 '23 07:02 hassanasad

Following @hassanasad's advice is indeed the correct one, as the moment team has announced they deprecated the project.

We recognize that many existing projects may continue to use Moment, but we would like to discourage Moment from being used in new projects going forward. Instead, we would like to recommend alternatives that are excellent choices for use in modern applications today.

fish3046 avatar Aug 18 '23 18:08 fish3046