-
-
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
"Stuff" not present with Shadow Endpoints #3860
Comments
Are you sure it's that extreme? The original issue for shadow endpoints includes an example of writing a
For this situation, it'd be like: <script context="module">
/** @type {import('@sveltejs/kit').Load */
export async function load({ props }) {
return {
props,
stuff: { ... },
}
}
</script> It is still the case, though, that you can't send something from |
It's not that extreme, no 🙂. But even that simple Really, my opinion was that this is something that should be explored, and if it's not feasable, discarded. But if it is feasable then it would reduce redundant code and increase DX. |
I'm finding my locals-to-stuff populating tends to happen in the root It would be "nice" to not need to have anything in __layout to do that root level population, but without it ... meh, I think I'll live. Mentally, I would prefer it to be part of hooks, it feels similar to the |
Yes, that works very well for passing from the I use |
Edit: Ignore the below; as #3860 (comment) points out, I misunderstood what's being asked for. I agree that it would be nice if shadow endpoints could be as equivalent as possible to So I'd say that while this is a nice idea, it might be impossible (or at least infeasible) to do, and it will probably be better to design your use of |
I think there might be some misunderstanding here. Both My suggestion was bringing the I wasn't suggesting that |
Yes, I missed that you specified output in your description. So the only technical challenge would be merging any I'll update my comment to mention that it was a misunderstanding. |
The challenge here is that For what it's worth you could rewrite this... <script context="module">
/** @type {import('@sveltejs/kit').Load */
export async function load({ props }) {
return {
props,
stuff: { ... },
}
}
</script> ...as this: <script context="module">
import { add_stuff } from '$lib/stuff';
export const load = add_stuff(props => ({
title: props.title
}));
</script> At that point it's only a tiny bit more code than adding |
Absolutely, that makes sense. I'm going to close this Issue then and we can reopen in the future if anything changes/there are any other considerations to consider. |
Describe the problem
With the recent advent of shadow endpoints #3532, it is now possible to move all database requests or other external loading to the
.ts
or.js
file.However:
stuff
likeload
functions.load
function is still required when wanting to passstuff
to__layout.svelte
files.stuff
as an output - for example, for<meta>
tags - then the entire point of shadow endpoints is defeated.Describe the proposed solution
A possible solution could be to add an export of
stuff
to endpoint files. The complexity of this is unknown.Alternatives considered
Require the user to provide a redundant
load
function on every page. However, this is suboptimal.Importance
Would make my life a lot easier!
Additional Information
*crickets chirp*
The text was updated successfully, but these errors were encountered: