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

feat(compiler-cli): spike of standalone components #42831

Closed
wants to merge 1 commit into from

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented Jul 12, 2021

This is a WIP commit of a spike for standalone components - components which
declare their own dependencies and do not use an NgModule.

This is a WIP commit of a spike for standalone components - components which
declare their own dependencies and do not use an NgModule.
@google-cla google-cla bot added the cla: yes label Jul 12, 2021
@Component({
selector: 'test-cmp',
template: '<div dir></div>',
deps: [Dir],
Copy link
Contributor

@splincode splincode Jul 13, 2021

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?

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.

Copy link

Choose a reason for hiding this comment

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

imports would be awesome

Choose a reason for hiding this comment

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

yap, agree with imports

Copy link
Contributor

@LayZeeDK LayZeeDK Jul 14, 2021

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],
  // (...)
})

Copy link
Contributor

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.

Copy link

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.

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.

Copy link

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.

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.

@SanderElias
Copy link
Contributor

@alxhub This is a very welcome addition. Is there a place where I can follow the discussion around this?
I know it is a spike, but I have so many questions.

@pkozlowski-opensource
Copy link
Member

@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!

@alxhub
Copy link
Member Author

alxhub commented Jul 13, 2021

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 :)

@alxhub alxhub added the area: compiler Issues related to `ngc`, Angular's template compiler label Jul 16, 2021
@ngbot ngbot bot added this to the Backlog milestone Jul 16, 2021
@alxhub
Copy link
Member Author

alxhub commented Nov 4, 2021

Closing as this is now significantly out of sync with the Standalone Components design as discussed in the RFC.

@alxhub alxhub closed this Nov 4, 2021
@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 Dec 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants