angular: Metadata version changed to 2 in 2.2.2, breaking consumers with older versions

I’m submitting a …

[x] bug report
[ ] feature request
[ ] support request

Current behavior Metadata built with Angular >= 2.2.2 comes out with version 2 due to dddbb1c1cb08115f339e34487774c85a3c6493f3. An application with Angular <= 2.2.1 won’t be able to consume this metadata, throwing the following error:

Error: Metadata version mismatch for module /home/local/TELERIK/tsonev/gitlab/angular-aot/node_modules/@progress/kendo-angular-buttons/dist/es/button.service.d.ts, found version 2, expected 1
    at StaticReflector.getModuleMetadata (/home/local/TELERIK/tsonev/gitlab/angular-aot/node_modules/@angular/compiler-cli/src/static_reflector.js:500:23)

Expected behavior Metadata version shouldn’t change in a patch or minor releases.

Minimal reproduction of the problem with instructions Try to consumе this dummy package built with 2.2.2 in a project with 2.2.1. You can see that the metadata is set to version 2.

What is the motivation / use case for changing the behavior? Avoiding breaking changes.

Please tell us about your environment: any

  • Angular version: 2.2.2

  • Browser: all

  • Language: TypeScript 2.x

  • Node (for AoT issues): node --version =

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 12
  • Comments: 20 (9 by maintainers)

Most upvoted comments

As a package publisher, we don’t know which version of Angular 2 the consumer is using. Yet, we have to ship metadata as part of our packages to make them usable with AoT compilation. This makes metadata part of the public API, albeit indirectly.

Thus we have two choices:

  1. Lock down our packages to 2.2.1 in order to produce v1 metadata. This is usable by all consumers.
  2. Build against the latest stable 2.x release and break users with 2.2.1 and earlier. The semver way to address this situation is to introduce a breaking change in our package with the Angular peer dependency set to >= 2.2.2

You can see where I’m going. If a version of Angular forces us to introduce a breaking change then it must be a breaking change itself.

Welcome to the world of “third-party” vendors 😃

@bahodirk The problem is that we didn’t pin the version of @angular/tsc-wrapped in @angular/compiler-cli

FYI: Here is the revert PR that should become part of 2.2.3: https://github.com/angular/angular/pull/13067

@victormejia Just give us some hours, we are in the process of fixing this.

@tbosch can you please help, i’m still facing this even though i’m using 2.2.3 version.

I don’t know if this is even related to version mismatches between different modules - my project only uses 1 module and I’m getting the Metadata version mismatch for module for a .ts file in my project that only contains interfaces (nothing ng related at all and certainly no metadata files for it)

The project compiled fine until this morning - all our angular references are locked to 2.2.0 but we didn’t npm shrinkwrap and I’m guessing the build server pulled @angular/tsc-wrapped : 0.4.1, after we do a clean npm install locally the local builds started breaking as well.

Downgrading to Angular 2.1.2 works fine for now. I will try to create a repro but I think something broke in 0.4.1 and I agree with the OP these kinds of changes don’t feel like they should be done on a patch level change.

A general note for other readers about the metadata files: We didn’t commit to our metadata files being public api (see https://github.com/angular/angular/blob/master/docs/PUBLIC_API.md). So using them directly might break you in the future as well… Same as when using @angular/compiler directly (i.e. importing directly from it) (see the linked doc).