mwootendev / ngx-translate-plugins

Utilities plugins for the @ngx-translate translation library.
MIT License
15 stars 10 forks source link

Please publish an Ivy distribution #50

Closed JamesHenry closed 2 years ago

JamesHenry commented 2 years ago

Hi @mwootendev, thanks for the helpful library, I have just started helping a client migrate to Angular 13 and this package is proving to be the sticking point. They use jest (like the reporters of your two existing issues do) and I believe all of the issues can be solved by publishing an Ivy distribution per the latest guidance, full info below.


Describe the bug

I believe both of the open issues #48 and #49 are symptoms of the same point - the absence of an Ivy distribution of this library for use with Angular 13+ is problematic.

If you attempt to use this library with jest you will run into #49 if you do not run ngcc properly, and then #48 once you do.

I see you currently have "enableIvy": false - is there a particular reason for this?

One of the key parts of the guide for publishing Angular libraries (https://angular.io/guide/creating-libraries) is:

If you intend to publish your library to npm, compile with partial-Ivy code by setting "compilationMode": "partial" in tsconfig.prod.json.

The compilationMode option should replace the enableIvy one entirely AFAIK.

All users currently see this when using the library as a result of the above:

image

Reproduction

If you want to trivially reproduce the two issues above you can create an Nx workspace with the Angular preset (because it wires up a working jest + Angular setup out of the box):

npx create-nx-workspace --preset=angular

E.g.

image

And then install:

npm i ngx-translate-testing @ngx-translate/core @ngx-translate/http-loader

And update app.component.ts

image

At this stage you will be able to reproduce #49 by running the tests (assuming ngcc hasn't yet run)

Then run:

npm run postinstall

...to trigger ngcc

At this stage you will be able to reproduce #48 by running the tests

mwootendev commented 2 years ago

@JamesHenry Thank you so much for the excellent write up. I was able to reproduce the issue and have turned on partial Ivy compilation. There should now be a new 6.0.1 version published to NPM that includes Ivy support. Please let me know if that doesn't resolve your issue.

Once again, many kudos to you for your reproduction steps and explanation.

JamesHenry commented 2 years ago

@mwootendev Sorry for the delay in coming back to you - I can confirm that the ivy update resolved the issue as hoped 👍 Thanks for providing that