Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an Ivy distribution #255

Closed
stefnedelchevbrady opened this issue Dec 7, 2021 · 28 comments · Fixed by #345
Closed

Provide an Ivy distribution #255

stefnedelchevbrady opened this issue Dec 7, 2021 · 28 comments · Fixed by #345
Labels
feature request A feature has been asked for or suggested by the community
Milestone

Comments

@stefnedelchevbrady
Copy link

stefnedelchevbrady commented Dec 7, 2021

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.

@stefnedelchevbrady stefnedelchevbrady added the feature request A feature has been asked for or suggested by the community label Dec 7, 2021
@frederikprijck
Copy link
Member

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.

@frederikprijck frederikprijck added the needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue label Jan 4, 2022
@stefnedelchevbrady
Copy link
Author

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.

@frederikprijck
Copy link
Member

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.

@frederikprijck frederikprijck removed the needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue label Feb 14, 2022
@frederikprijck frederikprijck added this to the v2.0.0 milestone Feb 14, 2022
@MedLeon
Copy link

MedLeon commented May 12, 2022

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?

@frederikprijck
Copy link
Member

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.

@MedLeon
Copy link

MedLeon commented May 16, 2022

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.

@frederikprijck
Copy link
Member

frederikprijck commented May 16, 2022

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.

@frederikprijck
Copy link
Member

@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.

@tuuling
Copy link

tuuling commented May 17, 2022

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:
lephyrus/ngx-translate-messageformat-compiler#78 (comment)

@stefnedelchevbrady
Copy link
Author

@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.

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?

@Lonli-Lokli
Copy link

Here is the guide from Angular team with settings you must use https://angular.io/guide/creating-libraries#publishing-libraries

@tuuling
Copy link

tuuling commented May 31, 2022

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.

@Lonli-Lokli
Copy link

Here you can see how @sentry solved this issue - they provides both version getsentry/sentry-javascript#4641

@joergbaier
Copy link

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.
getsentry/sentry-javascript#5268

@Lms24
Copy link

Lms24 commented Jun 27, 2022

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 ;)

@tuuling
Copy link

tuuling commented Jun 27, 2022

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.

@laurence-splendr
Copy link

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?

@VRMink
Copy link

VRMink commented Jul 11, 2022

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
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.

@VRMink
Copy link

VRMink commented Jul 11, 2022

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",

@thesuavehog
Copy link

I just hit the same message as @VRMink posted in my Angular 11 app.
image

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?

@frederikprijck
Copy link
Member

@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?

@thesuavehog
Copy link

@frederikprijck The issue I noted went away for me after some combination of re-compiling, reloading/restarting VS Code. Sorry for the confusion.

@Lonli-Lokli
Copy link

@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 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

  1. Install yarn
  2. run yarn install
  3. 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.

@frederikprijck
Copy link
Member

frederikprijck commented Aug 8, 2022

@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: angular/angular-cli#16980

@Lonli-Lokli
Copy link

@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.

angular/angular-cli#16980 (comment)

@frederikprijck
Copy link
Member

frederikprijck commented Aug 8, 2022

Thanks, that makes sense. Would you be able to verify if #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.

@Lonli-Lokli
Copy link

@frederikprijck Yes, it compiles & run without errors, I pushed code to same repo with changes.

@frederikprijck
Copy link
Member

frederikprijck commented Sep 29, 2022

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 to partial.

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? #345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature has been asked for or suggested by the community
Projects
None yet
10 participants