-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Warn when getStaticPaths
exists without a prerender
statement
#7713
Conversation
🦋 Changeset detectedLatest commit: 13fa4f4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Just tweaking the getStaticPaths
without prerender
warning so it runs during dev
and build
. Previously, it only ran when a page was being rendered in dev
.
if (ssr && mod.getStaticPaths && !route.prerender) { | ||
warn( | ||
logging, | ||
'getStaticPaths', | ||
`getStaticPaths() in ${bold(route.component)} is ignored when "output: server" is set.` | ||
); | ||
} |
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.
Instead of checking this at runtime like we do here...
|
||
// `getStaticPaths` warning is just a string check, should be good enough for most cases | ||
if (!pageOptions.prerender && isServerLikeOutput(settings.config) && code.includes('getStaticPaths')) { | ||
warn(logging, "getStaticPaths", `The getStaticPaths() statement in ${bold(rootRelativePath(settings.config.root, fileURL, true))} has been ignored.\n\nAdd \`export const prerender = true;\` to prerender this page.`); | ||
} |
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.
This check has been moved to compile time (in our astroScannerPlugin
).
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.
Updated this one per @sarah11918's feedback that mentioning output: "${mode}"
would be helpful.
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.
I like the move to compile/build-time warnings!
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.
I like the new warning! Nice that it includes a helpful actionable step of how to fix.
Changes
getStaticPaths
existing withoutprerender
.dev
. Now the warning happens atcompile
time duringdev
andbuild
.server | hybrid
outputs.Testing
We don't have (reliable) tests for CLI logs, unfortunately
Tested manually
Docs
cc @withastro/maintainers-docs for feedback on the warning message. These warnings aren't something we document like our errors, but they are user-facing!
Before
After