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

Prerendering from Content Collections still adds content to SSR server code #6350

Closed
1 task
jimjimovich opened this issue Feb 23, 2023 · 3 comments · Fixed by #7713
Closed
1 task

Prerendering from Content Collections still adds content to SSR server code #6350

jimjimovich opened this issue Feb 23, 2023 · 3 comments · Fixed by #7713
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: ssr Related to SSR (scope)

Comments

@jimjimovich
Copy link

What version of astro are you using?

2.0.14

Are you using an SSR adapter? If so, which one?

Deno

What package manager are you using?

npm

What operating system are you using?

Linux, Ubuntu 22.04

Describe the Bug

When prerendering content from content collections using the method described in the documentation and used in the blog example, the content of each item/page is still added to the entry.mjs file. Standard pages are prerendered to html and then not added to entry.mjs.

Duplicating the already prerendered content inside entry.mjs leads to very large server files and is in general not efficient.

See the example provided and you can see how the output from blog posts in the content folder are in entry.mjs but the content of the about.astro page is no longer included there when using prerendering.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-8mbuj5

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re natemoo-re added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Feb 27, 2023
@natemoo-re natemoo-re self-assigned this Feb 27, 2023
@jimjimovich
Copy link
Author

jimjimovich commented May 19, 2023

Any chance that this is fixable? I took a look at the code and couldn't figure out what needed changed.

Edit: I see that hybrid rendering doesn't suffer from this problem, nice!

@Princesseuh Princesseuh added the feat: ssr Related to SSR (scope) label Jul 17, 2023
@natemoo-re
Copy link
Member

Ah I'm sorry it took so long for us to get to this issue!

You're correct that hybrid rendering does not suffer from this issue, but it also looks like this /blog/[...slug].astro file includes a getStaticPaths() function but not an export const prerender = true statement. Setting the page to be prerendered should avoid the Content Collection code from ever being bundled on the server.

Astro should have a better warning is getStaticPaths is used but prerender is not!

@natemoo-re
Copy link
Member

I'm asking the rest of the team how we want to handle getStaticPaths with for output: 'server' if a prerender export doesn't exist...

As this issue shows, it's unintuitive that the getStaticPaths is silently ignored. It should probably warn, throw, or just imply that the page should be prerendered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: ssr Related to SSR (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants