-
-
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
[fix] load data through regular json request #7177
Conversation
🦋 Changeset detectedLatest commit: aa6535f 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 |
The wrinkle here is that if someone posts to an action manually, they'll get devalue-encoded data in return. We could handle it in SSR and import { decode } from '$app/forms'; or, more directly, import { decode } from 'devalue'; // doesn't currently exist, but decode(obj) would === parse(JSON.stringify(obj)) I think it's fine to merge this as-is then handle headers in a separate PR, so I'm marking this ready |
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.
Can't approve because it's my own PR, but consider this an approval in case the answer to my question in the code-comment is "yes".
Edit: Oh and this needs a changeset.
@@ -10,6 +16,7 @@ import { HttpError, Redirect } from '../control.js'; | |||
import { stores } from './singletons.js'; | |||
import { DATA_SUFFIX } from '../../constants.js'; | |||
import { unwrap_promises } from '../../utils/promises.js'; | |||
import * as devalue from 'devalue'; |
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.
will tree shaking remove the other stuff correctly if we write the import like this?
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.
Yep, Rollup doesn't care either way
Thanks, I'll check if it fixes #7203 ! |
I'm glad to see this PR fixes a theoretical consideration on a closed issue of mine: Worth to mark this issue as "fixed" in the main description of this PR, for automatic referencing to the future. |
using devalue's stringify/parse methods
Part of #7125 and #6477
Not sure exactly what's left for the above issues to get closed besides allowing setting cache headers again.
If we change to this we could use the same methods for interacting with form actions, allowing them to also return
Date
objects for example.Marked as draft, @Rich-Harris feel free to take over/close.
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. All changesets should bepatch
until SvelteKit 1.0