angular-auth-oidc-client icon indicating copy to clipboard operation
angular-auth-oidc-client copied to clipboard

[Bug]: Updating Angular should be a breaking change

Open lorenzodallavecchia opened this issue 1 year ago • 7 comments

Version

14.1.5

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Upgrading `angular-auth-oidc-client` from 14.0.2. to 14.1.5 I have the following compilation error:

  This application depends upon a library published using Angular version 14.1.0, which requires Angular version 14.0.0 or newer to work correctly.
  Consider upgrading your application to use a more recent version of Angular.

Steps to reproduce the behavior

No response

A clear and concise description of what you expected to happen.

My application is still using Angular 13, so the error is correct. However, I was not expecting the error to happen with a minor upgrade of `angular-auth-oidc-client`.

Additional context

The problem happens because Angular is sometimes updated in the source workspace without waiting for a major release.

  • Angular 14 in 5ec347912d50afd970ee045c7c98979a68559666 (version 14.1.0)
  • Angular 15 in e4640280a0488374eb6f1c73be18e6af1fb7d776 (version 15.0.1)
  • Angular 16 in cf8dda00052e73b40d3c0d48de06c5c0d1f343ff (not released - hope we are waiting for 16.0.0 😀)

Unfortunately, Angular Ivy is not forward-compatible, as explained here.

I think it would be better to stick with the Angular version declared as a lower bound in peerDependencies. Currently, it is still 12.0.0. That should not be a big deal because Angular is backward-compatible.

lorenzodallavecchia avatar Jun 14 '23 12:06 lorenzodallavecchia

Thanks for this. I agree that we did miss this and did a bad job there. We try to rely on the Angular Versions which are released. Angular 16 is out and we should be compatible. So I don't understand:

Angular 16 in https://github.com/damienbod/angular-auth-oidc-client/commit/cf8dda00052e73b40d3c0d48de06c5c0d1f343ff (not released - hope we are waiting for 16.0.0 😀)

We are on 16 already. Can you elaborate?

Thanks!

FabianGosebrink avatar Jun 15 '23 17:06 FabianGosebrink

We are on 16 already. Can you elaborate?

Sorry, I realize now that I referred to the version numbers unclearly.

What I mean is that you have not yet released any angular-auth-oidc-client version compiled with Angular 16. The latest released version, 15.0.5, was still compiled with Angular 15. Since changing the base version of Angular is breaking, it should be released as part of the next major release of angular-auth-oidc-client, which would be 16.0.0. Also, the released package.json should now require Angular with >=16.0.0.

lorenzodallavecchia avatar Jun 16 '23 06:06 lorenzodallavecchia

What I mean is that you have not yet released any angular-auth-oidc-client version compiled with Angular 16. The latest released version, 15.0.5, was still compiled with Angular 15.

Where do you see this?

FabianGosebrink avatar Jun 16 '23 06:06 FabianGosebrink

I checked commit cf8dda00052e73b40d3c0d48de06c5c0d1f343ff, and it is not yet included in any tagged release.

Another way to see that is by installing angular-auth-oidc-client@latest (now 15.0.5) and looking for Angular AOT metadata inside compiled files. For example, in fesm2020/angular-auth-oidc-client.mjs, towards the end.

DefaultLocalStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DefaultLocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });

The version: "15.0.0" refers to the Angular version used for compiling.

By the way, the minVersion puzzles me. Previously I took it as an indication that I could use even a version that low (12.0.0 in this case), but apparently, that's not the case, as I get the compilation error "Consider upgrading your application".

This discussion seems to clarify that Angular 14.0.0 broke forward compatibility, and the Angular folks say that it was never intended. It also appears that the minVersion field is hard-coded and useless.

Indeed, the output for libraries contains the exact version used during compilation, as well as a minimum target version. This was baked in from the start of v12 (the initial availability of Ivy's library output) to allow detecting libraries that require a later version at application build time.

In v14, the library output has changed [...] this is a forwards compatibility break, [...]

So I wonder if there is any way to instruct the compiler that my library may be used with Angular 12? Maybe some kind of a metadata that may be given during a build of a library or an app to a compiler/builder?

This is not possible and won't be supported, as there's loads of potential forwards compatibility hazards as Alex mentioned; you'll have to build with the version that you want to support as a minimum.

lorenzodallavecchia avatar Jun 16 '23 07:06 lorenzodallavecchia

That is correct. We will release a version with A16 in the next couple of days.

FabianGosebrink avatar Jun 16 '23 15:06 FabianGosebrink

Do we have Angular 16 version?

tushar9919 avatar Jul 22 '23 15:07 tushar9919

You can use v16.0.0 @tushar9919 (I think v15 should also work, but you don't have the new functional API's available)

timdeschryver avatar Jul 22 '23 18:07 timdeschryver