Repository: sveltejs/kit
Pull request #6313 (2022-08-26 11:34:06)

[docs] clarify load return value shape
Part of #6305

Writing it, I thought if we should also mention that the output is merged with the other load functions so people can also understand _why_ this is necessary.

### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it.

### Tests
- [ ] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`

### Changesets
- [ ] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. All changesets should be `patch` until SvelteKit 1.0


changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: ee247090c493eeed0140e74fa70edb3b17897bb3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/sveltejs/kit/new/dummdidumm-patch-1?filename=.changeset/warm-geckos-speak.md&value=---%0A%0A---%0A%0A%5Bdocs%5D%20clarify%20load%20return%20value%20shape%0A)



Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b5ffafb11..644b30596 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -25,7 +25,7 @@ Entry points to be aware of are:
 
 - [`packages/create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) - code that's run when you create a new project with `npm create svelte@latest`
 - [`packages/package`](https://github.com/sveltejs/kit/tree/master/packages/package) - for the `svelte-package` command
-- [`packages/kit/src/vite/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/vite/index.js) - for the Vite plugin
+- [`packages/kit/src/vite/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/exports/vite/index.js) - for the Vite plugin
 - [`packages/kit/src/core/sync/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/core/sync/sync.js) - for `svelte-kit sync`, which regenerates routing info and type definitions
 - [`packages/adapter-[platform]`](https://github.com/sveltejs/kit/tree/master/packages) - for the various SvelteKit-provided adapters
 
diff --git a/documentation/docs/05-load.md b/documentation/docs/05-load.md
index 040eaaf3c..30340f984 100644
--- a/documentation/docs/05-load.md
+++ b/documentation/docs/05-load.md
@@ -4,7 +4,7 @@ title: Loading data
 
 A [`+page.svelte`](/docs/routing#page-page-svelte) or [`+layout.svelte`](/docs/routing#layout-layout-svelte) gets its `data` from a `load` function.
 
-If the `load` function is defined in `+page.js` or `+layout.js` it will run both on the server and in the browser. If it's instead defined in `+page.server.js` or `+layout.server.js` it will only run on the server, in which case it can (for example) make database calls and access private [environment variables](/docs/modules#$env-static-private), but can only return data that can be serialized as JSON.
+If the `load` function is defined in `+page.js` or `+layout.js` it will run both on the server and in the browser. If it's instead defined in `+page.server.js` or `+layout.server.js` it will only run on the server, in which case it can (for example) make database calls and access private [environment variables](/docs/modules#$env-static-private), but can only return data that can be serialized as JSON. In both cases, the return value (if there is one) must be an object.
 
 ```js
 /// file: src/routes/+page.js
@@ -256,7 +256,7 @@ export async function load({ setHeaders }) {
 
 ### Output
 
-Any promises on the returned `data` object will be resolved, if they are top-level properties. This makes it easy to return multiple promises without creating a waterfall:
+The returned `data`, if any, must be an object of values. For a server-only `load` function, these values must be JSON-serializable. Top-level promises will be awaited, which makes it easy to return multiple promises without creating a waterfall:
 
 ```js
 // @filename: $types.d.ts


Test patch:
diff --git a/packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-server-load/+page.server.js b/packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-server-load/+page.server.js
index bbfe5178f..f3fc49dac 100644
--- a/packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-server-load/+page.server.js
+++ b/packages/kit/test/apps/basics/src/routes/load/server-data-reuse/with-server-load/+page.server.js
@@ -1,4 +1,4 @@
-/** @type {import('.$/types').ServerLoad} */
+/** @type {import('./$types').PageServerLoad} */
 export function load() {
 	return { server: true };
 }