angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

@uirouter/core mismatch. Should be peerDep? #3794

Closed oBusk closed 4 years ago

oBusk commented 4 years ago

This issue tracker is for Bug Reports and Feature Requests only.

Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a (check one box):

My version of UI-Router is: (type version)

package.json

"@uirouter/angular": "6.0.1",
"@uirouter/angular-hybrid": "10.0.1",
"@uirouter/angularjs": "1.0.24",
"@uirouter/core": "6.0.4",
"@uirouter/rx": "0.6.4",

Bug Report

Current Behavior:

Hard to debug type errors regarding StateDeclaration mismatches.

Basically a lot of properties and interfaces do not match which seems weird because no related typing has changed between @uirouter/core@6.0.3 and @uirouter/core@6.0.4.

However looking at the lockfile, we can see that we have a duplication;

"@uirouter/angular@^6.0.1":
  version "6.0.1"
  resolved "https://registry.yarnpkg.com/@uirouter/angular/-/angular-6.0.1.tgz#fbd6512d4da82b95d182bc592a101a6606407a82"
  integrity sha512-7UU3rv1rY0oobL3gUpeJ8QpazbgcDxG1JomBvzE7kYyxkVNBZ3rDhPRbzXTniaUXC2J56CEBE9PMtXNPDSxPyQ==
  dependencies:
    tslib "^1.9.0"

"@uirouter/angularjs@^1.0.24":
  version "1.0.24"
  resolved "https://registry.yarnpkg.com/@uirouter/angularjs/-/angularjs-1.0.24.tgz#e8ac7c8b53f68481a070fbed87e9f7768d344942"
  integrity sha512-Q+gR5eskbOwK5DlzSOOXx3MGWbKq5xQrcF0T4csHXOHUBuGO26n6QTPFYsPwg0AfpC5yNou3jrDonI+UR8wDEg==
  dependencies:
    "@uirouter/core" "6.0.3"

"@uirouter/core@6.0.3":
  version "6.0.3"
  resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-6.0.3.tgz#1de7a3451039e1274e7f595de2be92421c26b09c"
  integrity sha512-ftAQw9czKUSgLFC3LwOeJP97PDQ6naHcEK0NrbWw3X/r49oQJBMRFAsz9oEKqPFPD2vUDqkvG18BZXglLp8k+Q==

"@uirouter/core@^6.0.4":
  version "6.0.4"
  resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-6.0.4.tgz#fcdc75ab10f1035176acf87a27d9d27a0101ecf9"
  integrity sha512-TQ9XOzZY+jmWKkU4993MAEBIy7Bs3kijDzj+A6RHR8gq/3UoQm3Q/l1igfao5GZyBjid7eRVeipPK14ovCYQ3g==

And my suspicion is that the mismatching of types is because the types I've imported from @uirouter/angularjs is not the same as the ones I import from @uirouter/angular.

Expected Behavior:

@uirouter/angularjs should have @uirouter/core as a peerDependency, just like the other uirouter packages, therefore ensuring that I use the same version of @uirouter/core.

Link to Plunker or stackblitz that reproduces the issue:

( if you want a response to your issue, provide a way to reproduce it ) ( http://bit.ly/UIR-Plunk1 ) ( https://stackblitz.com/edit/ui-router-angularjs )

oBusk commented 4 years ago

I guess an option to making @angular/core a peerDependency would be to make the dependency a bit more open like ^6.0.1 rather than specifying a specific version. This would mean less of a breaking change, but inconsistency compared to the other uirouter/* packages.

christopherthielen commented 4 years ago

The only top level uirouter project on peerDependencies today is the @uirouter/angular. I agree it's probably best to switch to all projects to peerDependencies. I'd like to coordinate switching all projects (angular-hybrid, react, react-hybrid) at the same time. This is a breaking change for every package which is why I haven't pulled the trigger yet.

oBusk commented 4 years ago

If changing to peerdep is a breaking change, thus major release, should there be a patch/minor that makes the dependency to core non-exact ^6.0.1 so that installing @uirouter/angular-hybrid and @uirouter/angular doesn't end up with the mismatch?

christopherthielen commented 4 years ago

The current recommendation for angular-hybrid (until all packages are peerDeps) is to only install @uirouter/angular-hybrid at the top level which should pick out exact versions of /angular, /angularjs, and /core which should be compatible

oBusk commented 4 years ago

How do you mean by that? @uirouter/angular-hybrid has no direct dependencies, only peerDependencies?

https://unpkg.com/browse/@uirouter/angular-hybrid@10.0.1/package.json

So to correctly install @uirouter/angular-hybrid, you'll have to install both @uirouter/angular and @uirouter/angularjs, causing the issue.

christopherthielen commented 4 years ago

Sorry, you are right. I didn't remember that I had also switched angular-hybrid to peerDependencies.

Now that I've released @uirouter/angularjs@1.0.25 which directly depends on @uirouter/core@6.0.4, you should have a valid combination of packages to install.

In the future I will switch all these to peerDependencies and do major releases of all the packages.