robisim74 / angular-l10n

Angular library to translate texts, dates and numbers
MIT License
380 stars 59 forks source link

Module parse failed: Identifier 'ɵngcc0' has already been declared build error #323

Closed ryaa closed 3 years ago

ryaa commented 3 years ago

Describe the bug The angular 11.x (~11.2.0) app build fails with the below error

[ng] Build at: 2021-03-12T17:05:41.195Z - Hash: e3489378a350358168e1 - Time: 9401ms
[ng] Error: ./node_modules/angular-l10n/__ivy_ngcc__/fesm2015/angular-l10n.js 13:12
[ng] Module parse failed: Identifier 'ɵngcc0' has already been declared (13:12)
[ng] File was processed with these loaders:
[ng]  * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
[ng]  * ./node_modules/@ngtools/webpack/src/ivy/index.js
[ng] You may need an additional loader to handle the result of these loaders.
[ng] |  */
[ng] | import * as ɵngcc0 from '@angular/core';
[ng] > import * as ɵngcc0 from '@angular/core';
[ng] | const L10N_CONFIG = new InjectionToken('L10N_CONFIG');
[ng] | /**

Note that it worked with Angular 10.x

To Reproduce Create an empty angular 11.x app and integrate this lib. After that the build fails with the error above I use ionic/angular and created the ionic/angular app from their starter template.

Expected behavior No error and everything is functional

Screenshots See the error above

Desktop (please complete the following information): N/A

Smartphone (please complete the following information): N/A

Additional context

Alexs-MacBook-Pro-3:internationalization-localization-support alexryltsov$ ionic info

Ionic:

   Ionic CLI                     : 6.13.1 (/Users/alexryltsov/.nvm/versions/node/v14.16.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.6.0
   @angular-devkit/build-angular : 0.1101.4
   @angular-devkit/schematics    : 11.1.4
   @angular/cli                  : 11.1.4
   @ionic/angular-toolkit        : 3.1.0

Capacitor:

   Capacitor CLI   : 2.4.7
   @capacitor/core : 2.4.7

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v14.16.0 (/Users/alexryltsov/.nvm/versions/node/v14.16.0/bin/node)
   npm    : 6.14.11
   OS     : macOS Big Sur
robisim74 commented 3 years ago

Hi @ryaa,

I created an Angular 11.x app, I added the library, but i got no errors during the build.

Then I created an Ionic app, but i got no errors during the build.

My environment:

Angular CLI: 11.1.4
Node: 14.15.1
OS: win32 x64
Ionic:

   Ionic CLI                     : 6.13.1 (C:\Users\simon\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.6.0
   @angular-devkit/build-angular : 0.1101.4
   @angular-devkit/schematics    : 11.2.4
   @angular/cli                  : 11.1.4
   @ionic/angular-toolkit        : 3.1.0

So I have to ask you to create a repro so I can investigate the problem.

ryaa commented 3 years ago

@robisim74 thank you for the quick response.

I created new ionic/angular application and added your library however the problem did not appear there and everything works fine. I did a little more investigation and found the below problem in ivy generated file

Screenshot 2021-03-13 at 08 24 48

Once I removed the duplicate everything started to work. I also uninstall and install angular-l10 library and build again, and the problem was not reproducible.

My assumption is that this seems to be not the angular-l10 problem but ivy adding the duplicate entry in the generated file. Since i can not reproduce it anymore and everything works as expected I'm going to close this issue. If the problem appear again, i will provide more details

Thank you for your great library and support!