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

ng update does not update deps in projects #18205

Closed
patoncrispy opened this issue Jul 9, 2020 · 5 comments
Closed

ng update does not update deps in projects #18205

patoncrispy opened this issue Jul 9, 2020 · 5 comments

Comments

@patoncrispy
Copy link

🐞 bug report

Affected Package

This seems to be an issue with @angular/cli.

Is this a regression?

Not sure, first time trying to update a project!

Description

I've run through the ng update (from Angular 8.2 to Angular 9.1) process and the workspace deps were updated, but my project package.json was not updated with the new versions.

My workspace deps look like this:

  "dependencies": {
    "@angular/common": "^9.1.12",
    "@angular/compiler": "^9.1.12",
    "@angular/core": "^9.1.12",
    // ... etc.
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.10",
    "@angular-devkit/build-ng-packagr": "~0.901.10",
    // ... etc.
  }

while my project deps look like this:

  "peerDependencies": {
    "@angular/common": "^8.2.13",
    "@angular/core": "^8.2.13"
  },
  "devDependencies": {
    "@angular/compiler": "8.2.13",
    "@angular/platform-browser": "8.2.13",
    "@angular/platform-browser-dynamic": "8.2.13",
    // ... etc.
  }

🔬 Minimal Reproduction

I couldn't find a way of creating an Angular 8 project as ng new seems to just opt for latest. If this is incorrect, please correct me and I'll try and create a reproduction of this.

🌍 Your Environment

Angular Version:
Before upgrade:


Angular CLI: 8.3.17
Node: 12.16.1
OS: darwin x64
Angular: 8.2.13
... common, compiler, compiler-cli, core, language-service
... platform-browser, platform-browser-dynamic

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.17
@angular-devkit/build-angular      0.803.17
@angular-devkit/build-ng-packagr   0.803.17
@angular-devkit/build-optimizer    0.803.17
@angular-devkit/build-webpack      0.803.17
@angular-devkit/core               8.3.17
@angular-devkit/schematics         8.3.17
@angular/cli                       8.3.17
@ngtools/webpack                   8.3.17
@schematics/angular                8.3.17
@schematics/update                 0.803.17
ng-packagr                         5.7.1
rxjs                               6.4.0
typescript                         3.5.3
webpack                            4.39.2

After upgrade:


Angular CLI: 9.1.10
Node: 12.16.1
OS: darwin x64

Angular: 9.1.12
... common, compiler, compiler-cli, core, language-service
... platform-browser, platform-browser-dynamic
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.901.10
@angular-devkit/build-angular      0.901.10
@angular-devkit/build-ng-packagr   0.901.10
@angular-devkit/build-optimizer    0.901.10
@angular-devkit/build-webpack      0.901.10
@angular-devkit/core               9.1.10
@angular-devkit/schematics         9.1.10
@angular/cli                       9.1.10
@ngtools/webpack                   9.1.10
@schematics/angular                9.1.10
@schematics/update                 0.901.10
ng-packagr                         9.1.5
rxjs                               6.5.3
typescript                         3.8.3
webpack                            4.42.0
@alan-agius4 alan-agius4 transferred this issue from angular/angular Jul 9, 2020
@alan-agius4
Copy link
Collaborator

Hi @patoncrispy, in an Angular workspace only workspace (root) level dependencies are updated.

The main reason for this is because typically only the root level package.json contains devDependencies and dependencies.

See also: #7097 and #14841

@patoncrispy
Copy link
Author

Thanks, @alan-agius4. Why then if you follow the setup guide for a library do you get:

  "peerDependencies": {
    "@angular/common": "^10.0.2",
    "@angular/core": "^10.0.2"
  },
  "dependencies": {
    "tslib": "^2.0.0"
  }

in the package.json? How do we then separate workspace dependencies and library dependencies? If I have multiple libraries in my workspace, isn't that going to get messy?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jul 9, 2020

Dependencies and PeerDependencies in libraries are intended to be used by the library consumers.

In most cases libraries should not have dependencies and devDependencies, Using peerDependencies is recommended for optimal bundle size. The exception here is tslib which is bound with the version of typescript used to build your library.

In your case, in your library dev dependencies you are specifying @angular/* packages, these are redundant as they are unused and not installed if you are using the standard CLI setup and workflow.

Note: by design ng update will not modify peer dependencies since a library can be backward compatible, so it’s up to the library author to manually update them as desired.

@patoncrispy
Copy link
Author

Thanks for your explanation, @alan-agius4 . That really helps!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants