Skip to content

Commit f0480e0

Browse files
Sync kit docs (#1483)
sync kit docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent 317b742 commit f0480e0

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

apps/svelte.dev/content/docs/kit/30-advanced/50-server-only-modules.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ export const add = (a, b) => a + b;
4848
...SvelteKit will error:
4949

5050
```
51-
Cannot import $lib/server/secrets.js into public-facing code:
52-
- src/routes/+page.svelte
53-
- src/routes/utils.js
54-
- $lib/server/secrets.js
51+
Cannot import $lib/server/secrets.ts into code that runs in the browser, as this could leak sensitive information.
52+
53+
src/routes/+page.svelte imports
54+
src/routes/utils.js imports
55+
$lib/server/secrets.ts
56+
57+
If you're only using the import as a type, change it to `import type`.
5558
```
5659

5760
Even though the public-facing code — `src/routes/+page.svelte` — only uses the `add` export and not the secret `atlantisCoordinates` export, the secret code could end up in JavaScript that the browser downloads, and so the import chain is considered unsafe.
5861

59-
This feature also works with dynamic imports, even interpolated ones like ``await import(`./${foo}.js`)``, with one small caveat: during development, if there are two or more dynamic imports between the public-facing code and the server-only module, the illegal import will not be detected the first time the code is loaded.
62+
This feature also works with dynamic imports, even interpolated ones like ``await import(`./${foo}.js`)``.
6063

6164
> [!NOTE] Unit testing frameworks like Vitest do not distinguish between server-only and public-facing code. For this reason, illegal import detection is disabled when running tests, as determined by `process.env.TEST === 'true'`.
6265

apps/svelte.dev/content/docs/kit/30-advanced/68-observability.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ sdk.start();
9595
```
9696
9797
Now, server-side requests will begin generating traces, which you can view in Jaeger's web console at [localhost:16686](http://localhost:16686).
98+
99+
## `@opentelemetry/api`
100+
101+
SvelteKit uses `@opentelemetry/api` to generate its spans. This is declared as an optional peer dependency so that users not needing traces see no impact on install size or runtime performance. In most cases, if you're configuring your application to collect SvelteKit's spans, you'll end up installing a library like `@opentelemetry/sdk-node` or `@vercel/otel`, which in turn depend on `@opentelemetry/api`, which will satisfy SvelteKit's dependency as well. If you see an error from SvelteKit telling you it can't find `@opentelemetry/api`, it may just be because you haven't set up your trace collection yet. If you _have_ done that and are still seeing the error, you can install `@opentelemetry/api` yourself.

apps/svelte.dev/content/docs/kit/98-reference/[email protected]

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,37 @@ type PrerenderOption = boolean | 'auto';
39283928

39293929
</div>
39303930

3931+
## PrerenderUnseenRoutesHandler
3932+
3933+
<div class="ts-block">
3934+
3935+
```dts
3936+
interface PrerenderUnseenRoutesHandler {/*…*/}
3937+
```
3938+
3939+
<div class="ts-block-property">
3940+
3941+
```dts
3942+
(details: { routes: string[]; message: string }): void;
3943+
```
3944+
3945+
<div class="ts-block-property-details"></div>
3946+
</div></div>
3947+
3948+
## PrerenderUnseenRoutesHandlerValue
3949+
3950+
<div class="ts-block">
3951+
3952+
```dts
3953+
type PrerenderUnseenRoutesHandlerValue =
3954+
| 'fail'
3955+
| 'warn'
3956+
| 'ignore'
3957+
| PrerenderUnseenRoutesHandler;
3958+
```
3959+
3960+
</div>
3961+
39313962
## Prerendered
39323963

39333964
<div class="ts-block">

apps/svelte.dev/content/docs/kit/98-reference/50-configuration.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,34 @@ How to respond when an entry generated by the `entries` export doesn't match the
11141114
</div>
11151115
<div class="ts-block-property">
11161116

1117+
```ts
1118+
// @noErrors
1119+
handleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;
1120+
```
1121+
1122+
<div class="ts-block-property-details">
1123+
1124+
<div class="ts-block-property-bullets">
1125+
1126+
- <span class="tag">default</span> `"fail"`
1127+
- <span class="tag since">available since</span> v2.16.0
1128+
1129+
</div>
1130+
1131+
How to respond when a route is marked as prerenderable but has not been prerendered.
1132+
1133+
- `'fail'` — fail the build
1134+
- `'ignore'` - silently ignore the failure and continue
1135+
- `'warn'` — continue, but print a warning
1136+
- `(details) => void` — a custom error handler that takes a `details` object with a `routes` property which contains all routes that haven't been prerendered. If you `throw` from this function, the build will fail
1137+
1138+
The default behavior is to fail the build. This may be undesirable when you know that some of your routes may never be reached under certain
1139+
circumstances such as a CMS not returning data for a specific area, resulting in certain routes never being reached.
1140+
1141+
</div>
1142+
</div>
1143+
<div class="ts-block-property">
1144+
11171145
```ts
11181146
// @noErrors
11191147
origin?: string;

0 commit comments

Comments
 (0)