-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
docs: mention the building
variable to execute non-prerenderable code in server handle
#13153
base: main
Are you sure you want to change the base?
Conversation
|
preview: https://svelte-dev-git-preview-kit-13153-svelte.vercel.app/ this is an automated message |
@@ -39,6 +39,8 @@ export async function handle({ event, resolve }) { | |||
If unimplemented, defaults to `({ event, resolve }) => resolve(event)`. | |||
|
|||
If you need to exclude some code from running during the build or prerendering step, check that the app is not [`building`]($app-environment#building) beforehand. |
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.
Not sure if this suffices - the confusion is also about why handle
even is executed
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.
If you need to exclude some code from running during the build or prerendering step, check that the app is not [`building`]($app-environment#building) beforehand. | |
The `handle` hook is invoked each time a route is requested during prerendering. If you need to exclude some code from running during this phase, check that the app is not [`building`]($app-environment#building) beforehand. |
Does this preceding sentence help answer that question?
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.
Not quite - the question is also "why is that route even requested during prerendering, I did export const prerender = false
"
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.
How about mentioning the crawler? It's true that it crawls both prerendered and non-prerendered pages.
If you need to exclude some code from running during the build or prerendering step, check that the app is not [`building`]($app-environment#building) beforehand. | |
During prerendering, SvelteKit crawls your pages for links and invokes the `handle` hook for each route it finds. If you need to exclude some code from running during this phase, check that the app is not [`building`]($app-environment#building) beforehand. |
closes #9965
Adds a note that the
building
variable should be used to check that the app isn't building before executing some code only available when not prerendering or building.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits