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

Add lightweight token doc to library section #36144

Closed
wants to merge 4 commits into from

Conversation

jbogarthyde
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Misko wrote up a design doc for the new lightweight-token design pattern that is recommended for library developers.

Issue Number: N/A

What is the new behavior?

The design doc content is transformed to user doc aimed at library developers and added to AIO as a new page in the Libraries section, with a link from
https://angular.io/guide/creating-libraries#refactoring-parts-of-an-app-into-a-library

Does this PR introduce a breaking change?

  • Yes
  • No

@jbogarthyde jbogarthyde added feature Issue that requests a new feature comp: docs effort2: days freq2: medium target: patch This PR is targeted for the next patch release risk: low labels Mar 19, 2020
@jbogarthyde jbogarthyde self-assigned this Mar 19, 2020
@ngbot ngbot bot modified the milestone: Backlog Mar 19, 2020
@mary-poppins
Copy link

You can preview 3e8e537 at https://pr36144-3e8e537.ngbuilds.io/.

@mary-poppins
Copy link

You can preview d75cfac at https://pr36144-d75cfac.ngbuilds.io/.

@mary-poppins
Copy link

You can preview c8c37f6 at https://pr36144-c8c37f6.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 3c1f196 at https://pr36144-3c1f196.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 38a27e5 at https://pr36144-38a27e5.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 6995f77 at https://pr36144-6995f77.ngbuilds.io/.

@jbogarthyde
Copy link
Contributor Author

@IgorMinar Thanks -- I am not going to make any more changes, unless you have any more comments.

@mary-poppins
Copy link

You can preview a0abbe7 at https://pr36144-a0abbe7.ngbuilds.io/.

@IgorMinar IgorMinar added PR action: rerun CI at HEAD target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Jun 23, 2020
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change LGTM now.

I'd like us to follow up on it after v10 is out and address several key points:

  • the intro into the guide could be more focused "This guide documents a recommended pattern for Angular library authors that ensure that their libraries are optimizable. Angular libraries are often composed of core functionality, as well as optional features. This lightweight injection pattern ensure that the code associated with the optional features unused by a particular application, is optimized away during production builds of this application."
  • some of the headings could be made more clear, I'll defer to @aikidave's guidance on this
  • somewhere early on, we should state that the pattern is applicable to two use-cases: optional features expressed as directives or components that the core part of the librarie queries for via @ContentChild, @ViewChild, etc. and optional dependencies injected into the constructor of a service or a component and flagged with the @Optional() decorator - this guide seems to mix these two use-cases, which results in confusion when the reader reads it. Again - the pattern and the recommendation to use abstract classes are applicable to both scenarios, but we should document them as two distinct use-case and show them off on two different examples.

The rest looks good. Thanks!

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@mary-poppins
Copy link

You can preview d68bc1c at https://pr36144-d68bc1c.ngbuilds.io/.

@IgorMinar IgorMinar removed the request for review from mhevery June 23, 2020 23:32
@IgorMinar IgorMinar added the action: merge The PR is ready for merge by the caretaker label Jun 23, 2020
@mhevery mhevery closed this in c95802f Jun 23, 2020
mhevery pushed a commit that referenced this pull request Jun 23, 2020
adds new DI technique recommendation for libraries to ensure tree-shaking for unused services
includes reasons for packaging schematics with libraries, clarify schematic usage recommendation

PR Close #36144
mhevery added a commit that referenced this pull request Jun 24, 2020
ngwattcos pushed a commit to ngwattcos/angular that referenced this pull request Jun 25, 2020
…37506)

Currently Angular internally already handles `InjectionToken` as
predicates for queries. This commit exposes this as public API as
developers already relied on this functionality but currently use
workarounds to satisfy the type constraints (e.g. `as any`).

We intend to make this public as it's low-effort to support, and
it's a significant key part for the use of light-weight tokens as
described in the upcoming guide: angular#36144.

In concrete, applications might use injection tokens over classes
for both optional DI and queries, because otherwise such references
cause classes to be always retained. This was also an issue in View
Engine, but now with Ivy, this pattern became worse, as factories are
directly attached to retained classes (ultimately ending up in the
production bundle, while being unused).

More details in the light-weight token guide and in: https://github.com/angular/angular-cli/issues/16866.

Closes angular#21152. Related to angular#36144.

PR Close angular#37506
ngwattcos pushed a commit to ngwattcos/angular that referenced this pull request Jun 25, 2020
…36144)

adds new DI technique recommendation for libraries to ensure tree-shaking for unused services
includes reasons for packaging schematics with libraries, clarify schematic usage recommendation

PR Close angular#36144
@jbogarthyde jbogarthyde deleted the jb-lightweight-tokens branch June 29, 2020 15:33
@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 Jul 30, 2020
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…36144)

adds new DI technique recommendation for libraries to ensure tree-shaking for unused services
includes reasons for packaging schematics with libraries, clarify schematic usage recommendation

PR Close angular#36144
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes effort2: days feature Issue that requests a new feature freq2: medium risk: low target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants