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(elements): create custom elements without NgModule #46475
feat(elements): create custom elements without NgModule #46475
Conversation
f8a74a4
to
c2dc2d3
Compare
Very much looking forward to this one, thanks! I’m curious about the ergonomics of this implementation. |
@michielkikkert you can get the feel for the ergonomics by looking at the test. But the tl;dr; is this: // get a hand on the `ApplicationRef` to access its injector
const applicationRef = await createApplication();
// create a constructor of a custom element
const NgElementCtor = createCustomElement(TestStandaloneCmp, {injector: applicationRef.injector});
// register in a browser
customElements.define('test-standalone-cmp', NgElementCtor);
// good to go! |
I'm really happy to see this 🧡 Is there an option to bootstrap the custom element with noop-zone or is this subject to another RFC/ topic/ PR? |
d634f09
to
26173a7
Compare
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.
So looking forward to this 🎉
Thank you, @pkozlowski-opensource 👏
I left a couple of minor comments/questions, but overall lgtm 👍
BTW, there are a couple of typos in the second commit message:
where ones want to
-->where one wants to
environnement
-->environment
351b99a
to
515a5fa
Compare
@gkalpak thnx for the detailed review and all the feedback. I believe that I've addressed most of it, feel free to do another pass on this PR. |
0f1fcf7
to
75d0951
Compare
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.
@pkozlowski-opensource the API looks really nice 👍
Reviewed-for: public-api
75d0951
to
7196d24
Compare
The `createApplication` function makes it possible to create an application instance (represented by the `ApplicationRef`) without bootstrapping any components. It is useful in the situations where ones wants to decouple and delay components rendering and / or render multiple root components in one application. Angular elements can use this API to create custom element types with an environment linked to a created application.
7196d24
to
63b296c
Compare
This commit adds a test demonstrating how a standalone Angular component could be turned into a custom element.
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.
reviewed-for: fw-core, public-api, fw-platform-server
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.
reviewed-for: public-api, fw-core
This PR was merged into the repository by commit 9285c66. |
This commit adds a test demonstrating how a standalone Angular component could be turned into a custom element. PR Close #46475
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 an exploratory PR to introduce APIs needed for Angular elements creation without NgModule. It has 2 changes (will split it into several commits before sending out for review):
createRootEnvironment
API;createRootEnvironment
API in the context of custom elements created from standalone components;There are several open questions on the table but opening an early draft PR to discuss details of the APIs.