-
-
Notifications
You must be signed in to change notification settings - Fork 10
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: allow building the app in prerendering by faking the page store during building #68
Conversation
🦋 Changeset detectedLatest commit: a513350 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
WalkthroughThis update introduces a significant enhancement to the handling of query parameters in SvelteKit applications, particularly focusing on improving the developer experience during prerendering. By adjusting the importation and usage of page stores and introducing a conditional assignment based on the build environment, the changes aim to address crashes related to accessing Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
✅ Deploy Preview for sveltekit-search-params ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- .changeset/seven-hounds-help.md (1 hunks)
- src/lib/sveltekit-search-params.ts (1 hunks)
Additional comments: 6
.changeset/seven-hounds-help.md (1)
- 1-5: The changeset description is clear and effectively communicates the purpose and impact of the patch. It succinctly explains how the fix allows building the app with prerendering by faking the page store during the building process.
src/lib/sveltekit-search-params.ts (5)
- 3-3: The import of
building
from$app/environment
is correctly implemented to determine if the app is in the build process. This is crucial for the conditional logic introduced later to fake the page store during building.- 5-5: Renaming
page
topage_store
in the import statement improves clarity and avoids potential confusion with thepage
variable used later in the code. This is a good practice for code readability and maintainability.- 6-6: The addition of type imports for
Page
from@sveltejs/kit
enhances type safety and clarity in the code, aligning with best practices for TypeScript development in SvelteKit projects.- 13-14: Importing
Readable
andreadable
fromsvelte/store
is necessary for the implementation of the fake page store and adheres to Svelte's reactive programming model. This ensures the code remains consistent with Svelte's design principles.- 21-33: The conditional assignment of
page
based on thebuilding
flag is a clever solution to the prerendering issue. By faking the page store during the build process, it prevents the application from crashing due to inaccessibleurl.searchParams
. This approach maintains client-side behavior post-build and addresses the core issue effectively. However, it's important to ensure that this workaround does not introduce unexpected side effects in the application's behavior during development or after deployment.
Closes #67
Summary by CodeRabbit