-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Allow server-only load functions to return more than JSON
#6318
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
Conversation
🦋 Changeset detectedLatest commit: 5eafe2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
|
Did you have an opinion about a statically analyzable config for making a given page use JSON instead of Devalue? Do you think the performance impact is not big enough to warrant that? |
|
I think it's probably fine — for all but the most complex objects, we're talking fractions of milliseconds. One thing devalue could do to reduce the overhead is, after it completes its initial walk of the object, return |
|
No, I'm afraid that's probably a non-starter. The code generated by |
dummdidumm
left a comment
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 looks very nice! Looking at the code I think it may even be possible to make this configurable to some extend. The window method stays but what kind of format is written to it could be configured by the user (JSON, superjson, whatever). Not for now but thought for later.
|
Oh. Yeah. :) |
closes #6008
fixes #6357
This allows
loadfunctions to return things likeDateobjects, regexes,MapandSet,BigIntand so on. It also allows repeated and cyclical references, for the times when they're useful.TODO:
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0