lephyrus / ngx-translate-messageformat-compiler

Advanced pluralization (and more) for ngx-translate, using standard ICU syntax which is compiled with the help of messageformat.js.
MIT License
93 stars 30 forks source link

Class constructor TranslateCompiler cannot be invoked without 'new' #66

Closed lucasskluser closed 9 months ago

lucasskluser commented 4 years ago

Hi from Brazil!

I'm trying to use TranslateMessageFormatCompiler in an Angular 7.1 project, however, my application doesn't work, as the following error is thrown:

image

Angular CLI: 7.3.10 Node: 13.12.0 OS: win32 x64 Angular: 7.1.4 @ngx-translate/core: 13.0.0 ngx-translate-messageformat-compiler: 4.7.0 messageformat: 2.0.5

In my app.module imports:

image

And providers:

image

I appreciate if you can help me.

jessorlisa commented 4 years ago

Having the same issue with Angular 10:

Angular CLI: 10.1.2
Node: 12.18.3
OS: darwin x64

Angular: 10.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.2
@angular-devkit/build-angular   0.1001.2
@angular-devkit/core            10.1.2
@angular-devkit/schematics      10.1.2
@angular/cdk                    10.2.1
@angular/material               10.2.1
@schematics/angular             10.1.2
@schematics/update              0.1001.2
rxjs                            6.6.3
typescript                      3.9.7
@ngx-translate/core@13.0.0 
ngx-translate-messageformat-compiler@4.8.0
messageformat@2.3.0

Is there anything we should provide to narrow this down?

jessorlisa commented 4 years ago

@lucasskluser Did you find a solution?

lephyrus commented 4 years ago

A quick internet search tells me that this probably has to do with module formats and/or what language level is targeted by the library and/or the app including it. I know that's vague, but the thing is: this library provides all kinds of builds (using the standard Angular CLI setup for libraries) and this error does not occur with a default Angular CLI setup for the app using it.

I suggest you try to find the difference between your app setup and the sample projects or the StackBlitz app. Check tsconfig.js (there's usually more than one), angular.json and package.json especially.

vincentpalita commented 4 years ago

@jessorlisa / @lucasskluser Do you have a specific webpack config? The default one from angular should just work fine. I had the same issue using this module in Storybook. I found a way to fix this, thanks to this issue: https://github.com/storybookjs/storybook/issues/11379#issuecomment-662953505

This configuration is done by angular-cli in the hidden webpack config.

lephyrus commented 9 months ago

Closed for staleness. Feel free to re-open if you encounter this.