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

Add @angular/platform-server/init to main.server.ts file #664

Closed
1 of 2 tasks
goetzrobin opened this issue Sep 21, 2023 · 1 comment · Fixed by #747
Closed
1 of 2 tasks

Add @angular/platform-server/init to main.server.ts file #664

goetzrobin opened this issue Sep 21, 2023 · 1 comment · Fixed by #747
Assignees
Labels
accepting PRs enhancement New feature or request

Comments

@goetzrobin
Copy link
Member

Which scope/s are relevant/related to the feature request?

create-analog

Information

Some libraries depend on DOM globals, which are not available without the following import:

import '@angular/platform-server/init';

What does it do?

From the docs:
Initializes the server environment for rendering an Angular application.
For example, it provides shims (such as DOM globals) for the server environment.
The import must come before any imports (direct or transitive) that rely on DOM built-ins being available.

I think we should add this as part of the create-analog tool and the Nx plugin.

Describe any alternatives/workarounds you're currently using

Add it manually.

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@goetzrobin goetzrobin added the enhancement New feature or request label Sep 21, 2023
@brandonroberts
Copy link
Member

👍

goetzrobin added a commit that referenced this issue Nov 8, 2023
this solves an issue when libraries might rely on injecting dom elements,
e.g. nx-scroll-bar, which causes the dev server to throw an error as these
dom elements are not available during SSR. however, angular allows us to
stub these elements on the server by importing @angular/platform-server/init.

Closes #664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting PRs enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants