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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preset @angular/* peer dependencies when creating a library-only project #16124

Open
selangley-wa opened this issue Oct 22, 2019 · 2 comments

Comments

@selangley-wa
Copy link

@selangley-wa selangley-wa commented Oct 22, 2019

馃殌 feature request

Relevant Package

@angular/cli

Description

The documentation around library creation suggests listing all @angular/* dependencies as peer dependencies.

Problem

But, the user has to do this manually.

Solution

I suggest that if you are creating a library only project via the ng commands, Angular should do this for the user automatically in the tsconfig.json along with a code comment describing why and pointing them to the relevant documentation.

Here's an example creating a library this way as described in Angular Workspace: No Application for You!

ng new foo-lib --create-application=false
cd foo-lib
ng generate library foo-lib --prefix=foo

Describe alternatives you've considered

  • Have the ng build command for a library inform the user that they should really set the @angular packages as peer dependencies and point them to the relevant documentation.
  • Have users search StackOverflow when they run into a problem and are scratching their heads about a mismatched dependency.
@trotyl

This comment has been minimized.

Copy link
Contributor

@trotyl trotyl commented Oct 23, 2019

The suggestion is about all @angular/* dependencies (of your library), not all @angular/* packages, there is no way to know which package your library is depending upon. So that you still need to manually add anything except @angular/core.

Technically speaking an Angular library may not even depend on @angular/core, for example @angular/pwa which is only meant for ng add.

@IgorMinar IgorMinar transferred this issue from angular/angular Nov 8, 2019
@ngbot ngbot bot modified the milestone: Backlog Nov 8, 2019
@clydin

This comment has been minimized.

Copy link
Member

@clydin clydin commented Nov 8, 2019

Note that the section in question is not actually about adding peer dependencies to the library project but rather instructions detailing the necessary steps to properly use a library that has been npm/yarn linked. As this is not a requirement to develop a library nor is it necessarily the common scenario, automatically adding the path mapping may be unnecessary and potentially break projects that rely on different development setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can鈥檛 perform that action at this time.