angular: Document that libraries compiled with Angular 5.x are not compatible with Angular 4.x

I’m submitting a…


[ x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Compiling the library angular-gridster2 with ngc -p tsconfig-lib.json from Angular v5.0.0-beta.4 onward to v5.0.0-rc.1 fails at compiling correctly the files. left 5.0.0-beta.3 - right 5.0.0-rc.1 image

People using the library will get a ERROR in Metadata version mismatch for module ../node_modules/angular-gridster2/dist/index.d.ts, found version 4, expected 3. Issue

Expected behavior

It should compile as in v5.0.0-beta.3 I didn’t see any breaking changes in the changelog for tsconfig/compiler

Minimal reproduction of the problem with instructions

tsconfig-lib.json repo

  1. Clone repo
  2. Change version of @angular to 5.0.0-rc.1 in package.json
  3. Run npm install
  4. Run npm run build-npm It does "build-npm": "gulp inline-templates && ngc -p tsconfig-lib.json"
  5. Check file ./dist/gridster.module.js

Environment


Angular version: 5.0.0-beta.4 onward to 5.0.0-rc.1


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.50, npm 5.5.1  
- Platform:  Windows 10 

Others:

About this issue

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

Commits related to this issue

Most upvoted comments

Hi @alexzuza and @ocombe , Thank you for the clarification, and I understand why it should be like this, but.

Why this wasn’t written somewhere as a breaking change?

Thanks,

@dgroh angular continues breaking compatibility. That is very bad practice. So if I want to create or upgrade a small external component I need to upgrade the entire system. That is a shame:( What should I change in the metadata in order to make it work? Can you point me to an example?

if the library is still compiled with v4, it should be compatible for users who are on v5. It’s the other way around that doesn’t work (compiled with v5 and used in an app with v4)

I think people how are using build based on 5.0.0-rc.1 should use that version of angular compiler that supports metadata version 4. In 5.0.0-rc.1 angular team increased metadata version because they are capturing type aliases in metadata files. https://github.com/angular/angular/commit/a75040d0a15c06cc8250032f044b7df0ed885317

In 5.0.0-beta-4 compiler was switched to transformer based compiler https://github.com/angular/angular/commit/679608db6543c2f9633e33841a6074548006fbe2 So from this moment compiler host is located in transformers folder and host.getSourceFile implementation doesn’t have such function like downlevelDecorators as it was in TsickleCompilerHost.getSourceFile.

So i would avoid publishing library to npm until angular 5 is released

This kind of behaviour was not happened in angularjs and you could use ng1.6 components in ng1.5 app or even earlier versions.

@KErez That’s not true.

It may be able to work in some cases, but that’s not guaranteed at all.

The same goes with other libraries.

That’s not the case in any library, even minor version could bring new features, and you cannot force library to NOT use new features.

This comment is opinions only:

@KErez AngularJs 1.5 to 1.6 is a MINOR version number change. Angular 4 to 5 is a MAJOR version number change. You can compare bananas to rocks, it’s possible, but a MAJOR version change implies breaking code, a MINOR does not always imply broken code… you shouldn’t compare the two like you are.

Bottom line, it’s your own fault for using bleeding edge technologies. Technologies that are growing and changing as you are using them. It’s a risk, it’s where the bleeding term comes from.

Which you are now, bleeding time trying to patch a metadata file where instead that time most likely would be better spent updating Angular to the latest version

It’s probably a mistake if it’s not in the changelog