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(server): renderApplication now accepts a bootstrapping method #49248

Closed

Conversation

alan-agius4
Copy link
Contributor

The renderApplication now also accepts a bootstrapping function call with return Promise<ApplicationRef>as the first parameter.

Example:

 const bootstrap = () => bootstrapApplication(RootComponent, appConfig);

 const output: string = await renderApplication(bootstrap);

@alan-agius4 alan-agius4 added the area: server Issues related to server-side rendering label Feb 28, 2023
@ngbot ngbot bot added this to the Backlog milestone Feb 28, 2023
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Feb 28, 2023
@@ -187,20 +212,41 @@ export function renderModule<T>(moduleType: Type<T>, options: {
* @developerPreview
*/
export function renderApplication<T>(rootComponent: Type<T>, options: {
/** @deprecated use `APP_ID` token to set the application ID. */
appId: string,
document?: string|Document,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this API is developer preview, can we just remove instead of deprecating?

This comment was marked as duplicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct and also if we are going to keep the current method to pass in a component type deprecate passing in the APP_ID.

I am okay with keeping it for now. Although I did have to add an additional private export to core to check if it's a bootstrap function or a component type.

@alan-agius4 alan-agius4 force-pushed the render-application-bootstrap-fn branch 4 times, most recently from 4784b32 to 420977f Compare February 28, 2023 11:43
@alan-agius4 alan-agius4 marked this pull request as ready for review February 28, 2023 11:58
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Feb 28, 2023
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@alan-agius4 looks great 👍 Just left a couple non-blocking comments.

packages/platform-server/src/utils.ts Show resolved Hide resolved
packages/platform-server/src/utils.ts Show resolved Hide resolved
@@ -187,20 +212,41 @@ export function renderModule<T>(moduleType: Type<T>, options: {
* @developerPreview
*/
export function renderApplication<T>(rootComponent: Type<T>, options: {
/** @deprecated use `APP_ID` token to set the application ID. */
appId: string,
document?: string|Document,

This comment was marked as duplicate.

packages/platform-server/src/utils.ts Outdated Show resolved Hide resolved
@alfaproject
Copy link
Contributor

OOC what is this trying to solve? Sorry if it isn't obvious for me

@alan-agius4 alan-agius4 force-pushed the render-application-bootstrap-fn branch from 035921b to 04fed46 Compare March 1, 2023 13:46
@alan-agius4
Copy link
Contributor Author

@alfaproject This is needed for a cleaner integration when using SSR and SSG. Where users do not have direct access to renderApplication.

Copy link
Contributor

@dylhunn dylhunn left a 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

@pullapprove pullapprove bot requested a review from jessicajaniuk March 1, 2023 17:06
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a 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

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 1, 2023
@AndrewKushnir
Copy link
Contributor

@alan-agius4 it looks like this PR has a merge conflict with the main branch right now (likely due to another PR that removed renderModuleFactory method). Could you please rebase and resolve conflicts when you get a chance? Thank you.

@AndrewKushnir AndrewKushnir added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Mar 1, 2023
…g method

The `renderApplication` now also accepts a bootstrapping function call with return `Promise<ApplicationRef>`as the first parameter.

Example:
```ts
 const bootstrap = () => bootstrapApplication(RootComponent, appConfig);

 const output: string = await renderApplication(bootstrap);
```
@alan-agius4 alan-agius4 force-pushed the render-application-bootstrap-fn branch from 04fed46 to be34a3c Compare March 1, 2023 20:45
@alan-agius4
Copy link
Contributor Author

alan-agius4 commented Mar 1, 2023

@AndrewKushnir rebased.

Caretaker note: I don’t think this required another presubmit seeing that it’s just a rebase and the changes.

@alan-agius4 alan-agius4 added merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 1, 2023
@jessicajaniuk
Copy link
Contributor

This PR was merged into the repository by commit b5278cc.

@alan-agius4 alan-agius4 deleted the render-application-bootstrap-fn branch March 2, 2023 07:17
@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 Apr 2, 2023
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 area: server Issues related to server-side rendering detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants