Skip to content

Commit 195ccbd

Browse files
authored
Merge branch 'main' into @feat/client-handle-fetch
2 parents 0518df8 + 149779a commit 195ccbd

File tree

66 files changed

+1140
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1140
-842
lines changed

.changeset/hip-moons-camp.md renamed to .changeset/heavy-roses-grab.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'@sveltejs/adapter-vercel': patch
44
---
55

6-
chore(deps): upgrade esbuild to 0.25.2
6+
chore(deps): upgrade to esbuild 0.25.3

.changeset/khaki-queens-provide.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/purple-feet-lay.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/silly-ears-visit.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

documentation/docs/20-core-concepts/10-routing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ Like `+layout.js`, `+layout.server.js` can export [page options](page-options)
277277

278278
## +server
279279

280-
As well as pages, you can define routes with a `+server.js` file (sometimes referred to as an 'API route' or an 'endpoint'), which gives you full control over the response. Your `+server.js` file exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT`, `DELETE`, `OPTIONS`, and `HEAD` that take a `RequestEvent` argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
280+
As well as pages, you can define routes with a `+server.js` file (sometimes referred to as an 'API route' or an 'endpoint'), which gives you full control over the response. Your `+server.js` file exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT`, `DELETE`, `OPTIONS`, and `HEAD` that take a [`RequestEvent`](@sveltejs-kit#RequestEvent) argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
281281

282282
For example we could create an `/api/random-number` route with a `GET` handler:
283283

documentation/docs/25-build-and-deploy/40-adapter-node.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Development dependencies will be bundled into your app using [Rollup](https://ro
3434

3535
### Compressing responses
3636

37-
You will typically want to compress responses coming from the server. If you are already deploying your server behind a reverse proxy for SSL or load balancing, it typically results in better performance to also handle compression at that layer since Node.js is single-threaded.
37+
You will typically want to compress responses coming from the server. If you're already deploying your server behind a reverse proxy for SSL or load balancing, it typically results in better performance to also handle compression at that layer since Node.js is single-threaded.
3838

3939
However, if you're building a [custom server](#Custom-server) and do want to add a compression middleware there, note that we would recommend using [`@polka/compression`](https://www.npmjs.com/package/@polka/compression) since SvelteKit streams responses and the more popular `compression` package does not support streaming and may cause errors when used.
4040

@@ -101,7 +101,7 @@ If `adapter-node` can't correctly determine the URL of your deployment, you may
101101
102102
### `ADDRESS_HEADER` and `XFF_DEPTH`
103103

104-
The [RequestEvent](@sveltejs-kit#RequestEvent) object passed to hooks and endpoints includes an `event.getClientAddress()` function that returns the client's IP address. By default this is the connecting `remoteAddress`. If your server is behind one or more proxies (such as a load balancer), this value will contain the innermost proxy's IP address rather than the client's, so we need to specify an `ADDRESS_HEADER` to read the address from:
104+
The [`RequestEvent`](@sveltejs-kit#RequestEvent) object passed to hooks and endpoints includes an `event.getClientAddress()` function that returns the client's IP address. By default this is the connecting `remoteAddress`. If your server is behind one or more proxies (such as a load balancer), this value will contain the innermost proxy's IP address rather than the client's, so we need to specify an `ADDRESS_HEADER` to read the address from:
105105

106106
```
107107
ADDRESS_HEADER=True-Client-IP node build

documentation/docs/25-build-and-deploy/99-writing-adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Within the `adapt` method, there are a number of things that an adapter should d
5151
- Output code that:
5252
- Imports `Server` from `${builder.getServerDirectory()}/index.js`
5353
- Instantiates the app with a manifest generated with `builder.generateManifest({ relativePath })`
54-
- Listens for requests from the platform, converts them to a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) if necessary, calls the `server.respond(request, { getClientAddress })` function to generate a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) and responds with it
54+
- Listens for requests from the platform, converts them to a standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) if necessary, calls the `server.respond(request, { getClientAddress })` function to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) and responds with it
5555
- expose any platform-specific information to SvelteKit via the `platform` option passed to `server.respond`
5656
- Globally shims `fetch` to work on the target platform, if necessary. SvelteKit provides a `@sveltejs/kit/node/polyfills` helper for platforms that can use `undici`
5757
- Bundle the output to avoid needing to install dependencies on the target platform, if necessary

documentation/docs/30-advanced/20-hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ The following can be added to `src/hooks.server.js` _and_ `src/hooks.client.js`:
112112

113113
#### on the server
114114

115-
This function allows you to modify (or replace) a `fetch` request that happens inside a `load` or `action` function that runs on the server (or during pre-rendering).
115+
This function allows you to modify (or replace) a `fetch` request that happens inside a `load`, `action` or `handle` function that runs on the server (or during prerendering).
116116

117117
For example, your `load` function might make a request to a public URL like `https://api.yourapp.com` when the user performs a client-side navigation to the respective page, but during SSR it might make sense to hit the API directly (bypassing whatever proxies and load balancers sit between it and the public internet).
118118

@@ -183,7 +183,7 @@ export async function handleFetch({ request, fetch }) {
183183

184184
### handleError
185185

186-
If an [unexpected error](errors#Unexpected-errors) is thrown during loading or rendering, this function will be called with the `error`, `event`, `status` code and `message`. This allows for two things:
186+
If an [unexpected error](errors#Unexpected-errors) is thrown during loading, rendering, or from an endpoint, this function will be called with the `error`, `event`, `status` code and `message`. This allows for two things:
187187

188188
- you can log the error
189189
- you can generate a custom representation of the error that is safe to show to users, omitting sensitive details like messages and stack traces. The returned value, which defaults to `{ message }`, becomes the value of `$page.error`.

documentation/docs/40-best-practices/07-images.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ Doing this manually is tedious. There are a variety of techniques you can use, d
2727
`@sveltejs/enhanced-img` is a plugin offered on top of Vite's built-in asset handling. It provides plug and play image processing that serves smaller file formats like `avif` or `webp`, automatically sets the intrinsic `width` and `height` of the image to avoid layout shift, creates images of multiple sizes for various devices, and strips EXIF data for privacy. It will work in any Vite-based project including, but not limited to, SvelteKit projects.
2828

2929
> [!NOTE] As a build plugin, `@sveltejs/enhanced-img` can only optimize files located on your machine during the build process. If you have an image located elsewhere (such as a path served from your database, CMS, or backend), please read about [loading images dynamically from a CDN](#Loading-images-dynamically-from-a-CDN).
30-
>
31-
> **WARNING**: The `@sveltejs/enhanced-img` package is experimental. It uses pre-1.0 versioning and may introduce breaking changes with every minor version release.
3230
3331
### Setup
3432

@@ -47,7 +45,7 @@ import { defineConfig } from 'vite';
4745

4846
export default defineConfig({
4947
plugins: [
50-
+++enhancedImages(),+++
48+
+++enhancedImages(), // must come before the SvelteKit plugin+++
5149
sveltekit()
5250
]
5351
});
@@ -67,7 +65,7 @@ At build time, your `<enhanced:img>` tag will be replaced with an `<img>` wrappe
6765

6866
You should provide your image at 2x resolution for HiDPI displays (a.k.a. retina displays). `<enhanced:img>` will automatically take care of serving smaller versions to smaller devices.
6967

70-
If you wish to add styles to your `<enhanced:img>`, you should add a `class` and target that.
68+
> [!NOTE] if you wish to use a [tag name CSS selector](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Basic_selectors#type_selectors) in your `<style>` block you will need to write `enhanced\:img` to escape the colon in the tag name.
7169
7270
### Dynamically choosing an image
7371

packages/adapter-auto/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,20 @@ export default () => ({
122122
},
123123
supports: {
124124
read: () => {
125-
throw new Error(
126-
"The read function imported from $app/server only works in certain environments. Since you're using @sveltejs/adapter-auto, SvelteKit cannot determine whether it will work when your app is deployed. Please replace it with an adapter tailored to your target environment."
125+
supports_error(
126+
'The read function imported from $app/server only works in certain environments'
127127
);
128128
}
129129
}
130130
});
131+
132+
/**
133+
* @param {string} message
134+
* @returns {never}
135+
* @throws {Error}
136+
*/
137+
function supports_error(message) {
138+
throw new Error(
139+
`${message}. Since you're using @sveltejs/adapter-auto, SvelteKit cannot determine whether it will work when your app is deployed. Please replace it with an adapter tailored to your target environment.`
140+
);
141+
}

packages/adapter-cloudflare/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @sveltejs/adapter-cloudflare
22

3+
## 7.0.2
4+
### Patch Changes
5+
6+
7+
- chore(deps): upgrade @cloudflare/workers-types to 4.20250415.0 ([#13716](https://github.com/sveltejs/kit/pull/13716))
8+
9+
- Updated dependencies [[`c51fb554416e0c4a21655c1d79e834f69743d1d5`](https://github.com/sveltejs/kit/commit/c51fb554416e0c4a21655c1d79e834f69743d1d5)]:
10+
- @sveltejs/kit@2.20.8
11+
312
## 7.0.1
413
### Patch Changes
514

packages/adapter-cloudflare/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sveltejs/adapter-cloudflare",
3-
"version": "7.0.1",
3+
"version": "7.0.2",
44
"description": "Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration",
55
"keywords": [
66
"adapter",
@@ -48,7 +48,7 @@
4848
"@playwright/test": "catalog:",
4949
"@sveltejs/kit": "workspace:^",
5050
"@types/node": "^18.19.48",
51-
"esbuild": "^0.25.2",
51+
"esbuild": "^0.25.3",
5252
"typescript": "^5.3.3"
5353
},
5454
"peerDependencies": {

packages/adapter-cloudflare/test/apps/pages/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"dev": "vite dev",
77
"build": "vite build",
8-
"preview": "wrangler pages dev .svelte-kit/cloudflare --port 8787",
8+
"preview": "wrangler pages dev .svelte-kit/cloudflare --port 8787",
99
"prepare": "svelte-kit sync || echo ''",
1010
"test": "playwright test"
1111
},
@@ -14,7 +14,7 @@
1414
"@sveltejs/vite-plugin-svelte": "^5.0.1",
1515
"server-side-dep": "file:server-side-dep",
1616
"svelte": "^5.23.1",
17-
"vite": "^6.2.6",
17+
"vite": "^6.2.7",
1818
"wrangler": "^4.11.0"
1919
},
2020
"type": "module"

packages/adapter-cloudflare/test/apps/workers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@sveltejs/vite-plugin-svelte": "^5.0.1",
1515
"server-side-dep": "file:server-side-dep",
1616
"svelte": "^5.23.1",
17-
"vite": "^6.2.6",
17+
"vite": "^6.2.7",
1818
"wrangler": "^4.11.0"
1919
},
2020
"type": "module"

packages/adapter-netlify/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @sveltejs/adapter-netlify
22

3+
## 5.0.1
4+
### Patch Changes
5+
6+
7+
- chore(deps): upgrade esbuild to 0.25.2 ([#13716](https://github.com/sveltejs/kit/pull/13716))
8+
9+
- Updated dependencies [[`c51fb554416e0c4a21655c1d79e834f69743d1d5`](https://github.com/sveltejs/kit/commit/c51fb554416e0c4a21655c1d79e834f69743d1d5)]:
10+
- @sveltejs/kit@2.20.8
11+
312
## 5.0.0
413
### Major Changes
514

packages/adapter-netlify/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sveltejs/adapter-netlify",
3-
"version": "5.0.0",
3+
"version": "5.0.1",
44
"description": "A SvelteKit adapter that creates a Netlify app",
55
"keywords": [
66
"adapter",
@@ -42,7 +42,7 @@
4242
},
4343
"dependencies": {
4444
"@iarna/toml": "^2.2.5",
45-
"esbuild": "^0.25.2",
45+
"esbuild": "^0.25.3",
4646
"set-cookie-parser": "^2.6.0"
4747
},
4848
"devDependencies": {

packages/adapter-static/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"sirv": "^3.0.0",
4747
"svelte": "^5.23.1",
4848
"typescript": "^5.3.3",
49-
"vite": "^6.2.6"
49+
"vite": "^6.2.7"
5050
},
5151
"peerDependencies": {
5252
"@sveltejs/kit": "^2.0.0"

packages/adapter-static/test/apps/prerendered/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@sveltejs/vite-plugin-svelte": "^5.0.1",
1414
"sirv-cli": "^3.0.0",
1515
"svelte": "^5.23.1",
16-
"vite": "^6.2.6"
16+
"vite": "^6.2.7"
1717
},
1818
"type": "module"
1919
}

packages/adapter-static/test/apps/spa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@sveltejs/vite-plugin-svelte": "^5.0.1",
1515
"sirv-cli": "^3.0.0",
1616
"svelte": "^5.23.1",
17-
"vite": "^6.2.6"
17+
"vite": "^6.2.7"
1818
},
1919
"type": "module"
2020
}

packages/adapter-vercel/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @sveltejs/adapter-vercel
22

3+
## 5.7.1
4+
### Patch Changes
5+
6+
7+
- chore(deps): upgrade esbuild to 0.25.2 ([#13716](https://github.com/sveltejs/kit/pull/13716))
8+
9+
10+
- fix: include the `edge-light` bundling condition when building edge functions ([#13720](https://github.com/sveltejs/kit/pull/13720))
11+
12+
- Updated dependencies [[`c51fb554416e0c4a21655c1d79e834f69743d1d5`](https://github.com/sveltejs/kit/commit/c51fb554416e0c4a21655c1d79e834f69743d1d5)]:
13+
- @sveltejs/kit@2.20.8
14+
315
## 5.7.0
416
### Minor Changes
517

packages/adapter-vercel/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sveltejs/adapter-vercel",
3-
"version": "5.7.0",
3+
"version": "5.7.1",
44
"description": "A SvelteKit adapter that creates a Vercel app",
55
"keywords": [
66
"adapter",
@@ -41,7 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@vercel/nft": "^0.29.2",
44-
"esbuild": "^0.25.2"
44+
"esbuild": "^0.25.3"
4545
},
4646
"devDependencies": {
4747
"@sveltejs/kit": "workspace:^",

packages/enhanced-img/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @sveltejs/enhanced-img
22

3+
## 0.5.0
4+
### Minor Changes
5+
6+
7+
- feat: add support for targeting `enhanced\:img` in CSS ([#13617](https://github.com/sveltejs/kit/pull/13617))
8+
39
## 0.4.4
410
### Patch Changes
511

packages/enhanced-img/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sveltejs/enhanced-img",
3-
"version": "0.4.4",
3+
"version": "0.5.0",
44
"description": "Image optimization for your Svelte apps",
55
"repository": {
66
"type": "git",
@@ -43,15 +43,17 @@
4343
"zimmerframe": "^1.1.2"
4444
},
4545
"devDependencies": {
46+
"@sveltejs/vite-plugin-svelte": "^5.0.1",
4647
"@types/estree": "^1.0.5",
4748
"@types/node": "^18.19.48",
4849
"rollup": "^4.27.4",
4950
"svelte": "^5.23.1",
5051
"typescript": "^5.6.3",
51-
"vite": "^6.2.6",
52+
"vite": "^6.2.7",
5253
"vitest": "^3.1.1"
5354
},
5455
"peerDependencies": {
56+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
5557
"svelte": "^5.0.0",
5658
"vite": ">= 5.0.0"
5759
}

packages/enhanced-img/src/index.js

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22
import process from 'node:process';
33
import { imagetools } from 'vite-imagetools';
4-
import { image } from './preprocessor.js';
4+
import { image_plugin } from './vite-plugin.js';
55

66
/**
77
* @returns {import('vite').Plugin[]}
@@ -13,42 +13,6 @@ export function enhancedImages() {
1313
: [];
1414
}
1515

16-
/**
17-
* Creates the Svelte image plugin which provides the preprocessor.
18-
* @param {import('vite').Plugin} imagetools_plugin
19-
* @returns {import('vite').Plugin}
20-
*/
21-
function image_plugin(imagetools_plugin) {
22-
/**
23-
* @type {{
24-
* plugin_context: import('vite').Rollup.PluginContext
25-
* vite_config: import('vite').ResolvedConfig
26-
* imagetools_plugin: import('vite').Plugin
27-
* }}
28-
*/
29-
const opts = {
30-
// @ts-expect-error populated when build starts so we cheat on type
31-
plugin_context: undefined,
32-
// @ts-expect-error populated when build starts so we cheat on type
33-
vite_config: undefined,
34-
imagetools_plugin
35-
};
36-
const preprocessor = image(opts);
37-
38-
return {
39-
name: 'vite-plugin-enhanced-img',
40-
api: {
41-
sveltePreprocess: preprocessor
42-
},
43-
configResolved(config) {
44-
opts.vite_config = config;
45-
},
46-
buildStart() {
47-
opts.plugin_context = this;
48-
}
49-
};
50-
}
51-
5216
/** @type {Record<string,string>} */
5317
const fallback = {
5418
'.avif': 'png',

0 commit comments

Comments
 (0)