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

fix(hybrid-output): no matched route when using getStaticPaths #7150

Merged
merged 20 commits into from May 22, 2023

Conversation

MoustaphaDev
Copy link
Member

@MoustaphaDev MoustaphaDev commented May 20, 2023

Changes

Fix #7140

With the original prerendering feature, we had to export a prerender constant in order to prerender a page. Because of that we could get the prerendering state of a module by accessing its prerender export (mod.prerender)

With the new hybrid rendering feature however, we can't do that because it doesn't require a prerender export.

To get the prerender state of a route we should retrieve it from the metadata set by the astro:scanner vite plugin, which should erase inconsistencies on that front between dev and build.

Testing

Copy the test fixtures of ssr-prerender-get-static-paths, and remove the export const prerender = true from pages/endpoints.
In this case, creating a new test fixture seems like the easier choice.

Also fixed the old prerender tests, which weren't actually testing the prerendering feature.

Docs

Bug fix, N/A

@changeset-bot

This comment was marked as outdated.

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label May 20, 2023
@MoustaphaDev MoustaphaDev marked this pull request as draft May 20, 2023 16:37
@MoustaphaDev MoustaphaDev changed the title Fix(Hybrid output): no matched path when using getStaticPaths Fix(Hybrid output): no matched route when using getStaticPaths May 20, 2023
@MoustaphaDev MoustaphaDev changed the title Fix(Hybrid output): no matched route when using getStaticPaths fix(hybrid-output): no matched route when using getStaticPaths May 20, 2023
@MoustaphaDev MoustaphaDev marked this pull request as ready for review May 20, 2023 22:11
@bluwy
Copy link
Member

bluwy commented May 22, 2023

Copy the test fixtures of ssr-prerender-get-static-paths, and remove the export const prerender = true from pages/endpoints. In this case, creating a new test fixture seems like the easier choice.

We were discussing about testing recently, and would want to prevent duplicated test since it's getting slower. Would it be possible to share a single fixture to test it?

Besides that, the code changes looks good to me!

@MoustaphaDev
Copy link
Member Author

MoustaphaDev commented May 22, 2023

I guess I could use a vite plugin to remove the export const prerender=true from the original test fixture but that doesn't look very clean to me, but sure if it's a good compromise 👍️

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Thanks for the test refactors!

@MoustaphaDev MoustaphaDev merged commit 8f418d1 into main May 22, 2023
17 checks passed
@MoustaphaDev MoustaphaDev deleted the mk/fix-hybrid-gsp branch May 22, 2023 12:58
@astrobot-houston astrobot-houston mentioned this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pre-rendering error on dynamic routes with “hybrid” output
3 participants