-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
perf(compiler-cli): optimize NgModule emit for standalone components #49837
Conversation
15a81a1
to
1946b14
Compare
packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.ts
Outdated
Show resolved
Hide resolved
*/ | ||
mayContainProviders( | ||
ref: Reference<ClassDeclaration>, | ||
callback?: (importRef: Reference<ClassDeclaration>) => void): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is callback
here supposed to be? I also don't see any calls to this function where the callback isn't passed so does it have to be optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it to dependencyCallback
and added jsdocs.
It's optional because, for the conceptual operation of "does X contain exported providers?", a consumer may only be interested in the answer and not in recording information about dependencies (for example, if producing a diagnostic instead of emitting code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. Thanks Alex
1946b14
to
aad4dec
Compare
NgModules which import standalone components currently list those components in their injector definitions, because we assume that any standalone component may export providers from its own imports. This commit adds an optimization for that emit, which attempts to statically analyze the NgModule imports and determine which standalone components, if any are present, do not export providers and thus can be omitted. This analysis is imperfect, because some imported components may be declared outside of the current compilation, or transitively import types which are declared outside the compilation. These types are therefore _assumed_ to carry providers and so the optimization isn't applied to them.
aad4dec
to
bde2b44
Compare
@alxhub I've updated this to |
This PR was merged into the repository by commit 78c76ce. |
…49837) NgModules which import standalone components currently list those components in their injector definitions, because we assume that any standalone component may export providers from its own imports. This commit adds an optimization for that emit, which attempts to statically analyze the NgModule imports and determine which standalone components, if any are present, do not export providers and thus can be omitted. This analysis is imperfect, because some imported components may be declared outside of the current compilation, or transitively import types which are declared outside the compilation. These types are therefore _assumed_ to carry providers and so the optimization isn't applied to them. PR Close #49837
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
NgModules which import standalone components currently list those components in their injector definitions, because we assume that any standalone component may export providers from its own imports.
This commit adds an optimization for that emit, which attempts to statically analyze the NgModule imports and determine which standalone components, if any are present, do not export providers and thus can be omitted.
This analysis is imperfect, because some imported components may be declared outside of the current compilation, or transitively import types which are declared outside the compilation. These types are therefore assumed to carry providers and so the optimization isn't applied to them.