-
Notifications
You must be signed in to change notification settings - Fork 27k
feat(compiler-cli): spike of standalone components #42831
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
Conversation
This is a WIP commit of a spike for standalone components - components which declare their own dependencies and do not use an NgModule.
| @Component({ | ||
| selector: 'test-cmp', | ||
| template: '<div dir></div>', | ||
| deps: [Dir], |
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.
Why deps? :)
Why not use a convenient declarations name that everyone is used to by now for providing component or directive in modules?
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 think that we will have lots of discussion on a name (both in this exploratory PR and the upcoming RFC). But before deciding on a name we should first consider what this name tries to convey.
I this particular case we are trying to express: "brings in things declared already into a compilation scope of this template". As such it is not really the act of "declaring" (the dependent class was already declared) but rather depending or importing an existing declaration. In this light the deps conveys better what we mean. The other good name, if we would like to reuse existing ones, would be to use imports. This would be equivalent to imports from a NgModule (both in terms of the actual name and the actual semantics).
Again, I'm sure we will have more discussion on the name, just trying to redirect thinking to the actual meaning of things so we can pick a name that fits best.
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.
imports would be awesome
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.
yap, agree with imports
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.
deps is a common name in Angular, up until now used for provider dependencies.
Component deps is not only for declarable dependencies; it also supports Angular module dependencies, for example:
@Component({
deps: [HighlightDirective, ListComponent, CommonModule],
// (...)
})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.
On imports, it has historically only been for setting up dependencies between Angular modules. Then again, deps has only been for declaring dependencies such as class-based services and dependency injection tokens, not for declarables.
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.
If authors are trying to get rid of ngModule usage (in standalone components), then “imports” is absolutely valid replacement. And it will be easy to copy this into a test spec :) I guess this feature should be able to import modules and other standalone components.
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.
On the one hand, imports make a lot of sense here since it will act like NgModule['imports'].
On the other hand, it's semantically different since imports is strictly for NgModules, where's deps can accept both NgModules and other dependencies.
I might end up agreeing with deps (or dependencies if shorthand is unwanted) since it's a little bit more accurate (and somewhat more intuitive) than imports.
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.
Not sure if anyone is asking for our agreement here. As mentioned by one of the authors,
This would be equivalent to imports from a NgModule (both in terms of the actual name and the actual semantics).
So semantically it's not different.
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.
Of course, none is asking for our agreement, it was just stating an opinion for the sake of the discussion.
My first intuition was that because imports in NgModules could only import modules, then using the same name in components would be semantically different. However, considering you'll now be able to import Components as well, perhaps it IS semantically the same.
|
@alxhub This is a very welcome addition. Is there a place where I can follow the discussion around this? |
|
@SanderElias we are working on a public RFC so there will be plenty room for additional questions. But to write a RFC we need to experiment and hence this PR :-) . I'm trying to help with a RFC and have it out asap! |
|
Yep - as @pkozlowski-opensource points out, this PR is an experiment to explore what challenges might be involved implementing standalone components in our compiler. This isn't anywhere close to a "production" implementation, as evidenced by the thoroughly broken CI :) |
|
Closing as this is now significantly out of sync with the Standalone Components design as discussed in the RFC. |
|
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. |
This is a WIP commit of a spike for standalone components - components which
declare their own dependencies and do not use an NgModule.