auth0-angular
auth0-angular copied to clipboard
Provide an Ivy distribution
After migrating to Angular 13, now I get this message when building:
⠙ Generating browser application bundles (phase: setup)...Processing legacy "View Engine" libraries:
- @auth0/auth0-angular [es2015/esm2015] (git+https://github.com/auth0/auth0-angular.git)
- @auth0/angular-jwt [es2015/esm2015] (git+https://github.com/auth0/angular2-jwt.git)
Encourage the library authors to publish an Ivy distribution.
I think it's related to the fact that Angular are deprecating the View Engine in favour of Ivy which means in Angular v14 the library won't be able to build any more if this change is not being addressed.
Thanks for reporting this.
I will have a look into this, in the mean time if this is blocking for you I am happy to review a PR.
Thanks for reporting this.
I will have a look into this, in the mean time if this is blocking for you I am happy to review a PR.
Thank you. No, currently it's not blocking, it would become blocking when Angular 14 gets released and people migrate to it.
We looked at this internally and believe it is definitely an improvement to be providing an Ivy Distribution. However, doing so could mean our SDK stops working for people using Angular 9 and 10. Even though those two versions aren't supported by the Angular team itself, we do have customers using those versions and we feel like we don't want to break our SDK for them.
The above means we will need to patch this in a major version, which we feel like we want to use to introduce a few other breaking changes as well and plan it for later this year.
It also looks like our SDK still works with Angular 14 beta, however as soon as it turns out our SDK is not compatible with the latest version of Angular we will definitely put a fix out as soon as possible.
I am looking forward to it!
The first RC for Angular 14 is out. What's the progress on version 2.0? Have you already checked wether the SDK works with the RC or not?
Curious why you are looking forward to it? Anything you are missing in the current format that doesn't allow you to achieve what u want?
There is no time frame on 2.0 currently, no.
I was hoping for an easy way to write to user_metadata
. At the moment it's really difficult.
Furthermore I am just looking forward to using Angular v14. There is some good stuff coming. But it looks like the RC is Ivy only. So without the update to an Ivy distribution Auth0 would hold me back from using some incredible features.
Thanks for that info @MedLeon . Our intention is definitely not to block anyone. I will look into the RC and try and identify what it means for non-Ivy Distributions.
@MedLeon , I installed our SDK in an Angular application that's using 14.0.0-rc.0
and the behavior seems to be identical to 13: it works fine but outputs a Processing legacy "View Engine" libraries
.
Would you have some more information about this?
But it looks like the RC is Ivy only. So without the update to an Ivy distribution Auth0 would hold me back from using some incredible features.
Building View Engine libraries makes to build process longer than it has to imo.
The above means we will need to patch this in a major version, which we feel like we want to use to introduce a few other breaking changes as well and plan it for later this year.
Just make Ivy 2.0 and next breaking changes 3.0 - doesn't cost you anything. This is what other angular libraries have done for Ivy support. See my comment here: https://github.com/lephyrus/ngx-translate-messageformat-compiler/pull/78#issuecomment-1004619430
@MedLeon , I installed our SDK in an Angular application that's using
14.0.0-rc.0
and the behavior seems to be identical to 13: it works fine but outputs aProcessing legacy "View Engine" libraries
.Would you have some more information about this?
But it looks like the RC is Ivy only. So without the update to an Ivy distribution Auth0 would hold me back from using some incredible features.
Let's see what's going to happen when the final 14.0.0 release comes out. Maybe they will drop the View Engine support last, who knows?
Here is the guide from Angular team with settings you must use https://angular.io/guide/creating-libraries#publishing-libraries
I'm also thinking that test don't work fine if the library is not Ivy compatible.
Jest tests fail for me:
Unexpected value 'AuthModule' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.
I could look into how to make Jest compile this module "the old way", but I don't want to.
Please, make a new major version that is Ivy compatible so we can all go on with our lives.
Here you can see how @sentry solved this issue - they provides both version https://github.com/getsentry/sentry-javascript/pull/4641
Here you can see how @sentry solved this issue - they provides both version getsentry/sentry-javascript#4641
I don't think they solved it. It looks like they will provide an Ivy distribution with a major version bump. https://github.com/getsentry/sentry-javascript/issues/5268
I don't think they solved it.
Nope, we didn't solve full Ivy compatibility yet. Basically we're struggling with the same support of older Angular versions problem. Will revisit this for the next major release, as promised ;)
Don't want to sound mean, but I think I will.
Basically we're struggling with the same support of older Angular versions problem.
What you are struggling with is the version numbering you are currently using doesn't fit what Angular is doing.
If you look around at Angular 1st and 3rd party libraries, a lot of them have different major versions for different Angular versions. So it's not that you can't support multiple Angular versions - it's that you don't want to "mess up the nice version numbers" to support multiple Angular versions.
Both Auth0 and Sentry are paid products - you could show a bit of love for the customer here.
Angular 14 is out and I'm trying to integrate the library and it's failing due to lack of Ivy support. Any idea when support is coming for Ivy?
I can't seem to complete the tutorials from the Auth0 team due to the Ivy problem. I am attempting to follow instructions from this repository readme, and from this Auth0 blogpost: https://auth0.com/blog/add-oidc-to-angular-apps-quickly/
/// Visual Studio Code, editor error message (method) AuthModule.forRoot(config?: AuthConfig | undefined): ModuleWithProviders<AuthModule> Initialize the authentication module system. Configuration can either be specified here, or by calling AuthClientConfig.set (perhaps from an APP_INITIALIZER factory function).
@param config — The optional configuration for the SDK.
'AuthModule' does not appear to be an NgModule class.(-996002) auth.module.d.ts(3, 18): This likely means that the library (@auth0/auth0-angular) which declares AuthModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
Angular 13, /package.json @@ -23,6 +23,7 @@ "@angular/platform-browser-dynamic": "~13.2.0", "@angular/router": "~13.2.0", "@apollo/client": "^3.0.0",
- "@auth0/auth0-angular": "^1.10.0",
I just hit the same message as @VRMink posted in my Angular 11 app.
package.json
"@angular-devkit/core": "v11-lts",
"@angular/animations": "v11-lts",
"@angular/cdk": "v11-lts",
"@angular/common": "v11-lts",
"@angular/compiler": "v11-lts",
"@angular/core": "v11-lts",
"@angular/forms": "v11-lts",
"@angular/localize": "v11-lts",
"@angular/platform-browser": "v11-lts",
"@angular/platform-browser-dynamic": "v11-lts",
"@angular/router": "v11-lts",
...
"@auth0/auth0-angular": "^1.10.1",
Are there any current solutions for this or are we stuck for now?
@thesuavehog and @VRMink This looks like a different problem. Our SDK has worked fine with Angular 11 and 13 before, apart from the console output being discussed in this thread. I just gave it another try, and I am not getting the above error in a new Angular 11 and 13 project, ng serve
an ng build
seem to work fine once I include auth0-angular
.
Could you please open another issue so we can look into what's going on there?
@frederikprijck The issue I noted went away for me after some combination of re-compiling, reloading/restarting VS Code. Sorry for the confusion.
@thesuavehog and @VRMink This looks like a different problem. Our SDK has worked fine with Angular 11 and 13 before, apart from the console output being discussed in this thread. I just gave it another try, and I am not getting the above error in a new Angular 11 and 13 project,
ng serve
anng build
seem to work fine once I includeauth0-angular
.Could you please open another issue so we can look into what's going on there?
@frederikprijck I am facing an error with Yarn PnP enabled. So to show you I copied your playground, converted code alittle bit and switched to Yarn PnP.
You can check my repro & steps here https://github.com/Lonli-Lokli/auth0-pnp
- Install yarn
- run
yarn install
- run
yarn start
Error: src/app/app.module.ts:49:12 - error NG6002: 'AuthModule' does not appear to be an NgModule class.
49 imports: [
~
50 BrowserModule,
~~~~~~~~~~~~~~~~~~
...
58 AuthModule.forRoot(/* authConfig */),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 ],
~~~
.yarn/__virtual__/@auth0-auth0-angular-virtual-e265aedbd3/0/cache/@auth0-auth0-angular-npm-1.10.1-031f9b929e-38342167c6.zip/node_modules/@auth0/auth0-angular/lib/auth.module.d.ts:3:22
3 export declare class AuthModule {
~~~~~~~~~~
This likely means that the library (@auth0/auth0-angular) which declares AuthModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
× Failed to compile.
@Lonli-Lokli I am not familiar with Yarn PhP, but the error looks to be the same as others have run into, which went away randomly.
Not sure I understand correctly but are u insisting providing an Ivy distibution would fix this?
If that would not be the case, please open another issue so we can look into what it takes to support Yarn PnP, but be aware we have no explicit support for that and, as you may be well aware as you are involved, Yarn PnP does have some issues with the Angular CLI: https://github.com/angular/angular-cli/issues/16980
@frederikprijck yarn PnP is a mode when you do not have node_modules but have readonly tarballs, which can be consumed by webpack5 during the build.
ViewEngine requires ngcc to run, which must mutate packages with it. As it's readonly, it cannot be done - and skipped, and later fails.
Ivy partial format is a special partially compiled libraries which do not require ngcc layer because can be consumed directly.
https://github.com/angular/angular-cli/issues/16980#issuecomment-844967912
Thanks, that makes sense. Would you be able to verify if https://github.com/auth0/auth0-angular/pull/324 would solve it for Yarn PnP as well? That should use partial compilation mode.
- clone our repo
- git checkout chore/update-angular
- npm i
- npm run build
- cd dist/auth0-angular
- npm pack
Then install using the tarball generated inside dist/auth0-angular
.
@frederikprijck Yes, it compiles & run without errors, I pushed code to same repo with changes.
Sorry for this to take so long, but this has shown to be more complicated as I think it should be.
I had a conversation with the Angular team and concluded the following:
When you compile an SDK with Angular 14 and compilationMode set to partial, the SDK will only work with Angular 14+. However, as we still need to support Angular 12 and 13, it appears to be that we have two options:
- Create a separate version for every major version of Angular
- Compile using the lowest supported Angular version, currently being 12, with
compilationMode
set topartial
.
Given we have no specific features from angular apart from a service and an interceptor, I believe we should be fine to stick with Angular 12, that would have full support for Angular 12, 13, 14 and 15.
However, that would mean we can not merge the PR that bumps Angular to 14 yet, but can only do so once Angular has dropped support for Angular 12 and 13. Maintaining multiple versions comes with a cost that is not worth it for our SDK.
Long story short, I have created a PR to get rid of this warning, can you please have a look and let me know if it would do for those in this tread? https://github.com/auth0/auth0-angular/pull/345