Skip to content

Commit c63b0d4

Browse files
committed
Merge branch 'master' into primitives-for-i18n-routing
2 parents 49cc7ef + b8363fc commit c63b0d4

File tree

99 files changed

+597
-314
lines changed

Some content is hidden

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

99 files changed

+597
-314
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"commit": false,
55
"linked": [],
66
"access": "public",
7-
"baseBranch": "master",
7+
"baseBranch": "main",
88
"bumpVersionsWithWorkspaceProtocolOnly": true,
99
"ignore": ["!(@sveltejs/*|create-svelte|svelte-migrate)"]
1010
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
pull_request:
88

99
env:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77

88
permissions: {}
99
jobs:

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{
2222
"files": [
2323
"**/CHANGELOG.md",
24+
"**/vite.config.js.timestamp-*",
2425
"**/.svelte-kit/**",
2526
"documentation/**/*.md",
2627
"packages/package/test/fixtures/**/expected/**/*",

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ If you want to test against an existing project, you can use [pnpm `overrides`](
4343

4444
Entry points to be aware of are:
4545

46-
- [`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`
47-
- [`packages/package`](https://github.com/sveltejs/kit/tree/master/packages/package) - for the `svelte-package` command
48-
- [`packages/kit/src/core`](https://github.com/sveltejs/kit/tree/master/packages/kit/src/core) - code that's called at dev/build-time
49-
- [`packages/kit/src/core/sync`](https://github.com/sveltejs/kit/tree/master/packages/kit/src/core/sync) - for `svelte-kit sync`, which regenerates routing info and type definitions
50-
- [`packages/kit/src/runtime`](https://github.com/sveltejs/kit/tree/master/packages/kit/src/runtime) - code that's called at runtime
51-
- [`packages/kit/src/exports/vite`](https://github.com/sveltejs/kit/tree/master/packages/kit/src/exports/vite) - for all the Vite plugin related stuff
52-
- [`packages/adapter-[platform]`](https://github.com/sveltejs/kit/tree/master/packages) - for the various SvelteKit-provided adapters
46+
- [`packages/create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte) - code that's run when you create a new project with `npm create svelte@latest`
47+
- [`packages/package`](https://github.com/sveltejs/kit/tree/main/packages/package) - for the `svelte-package` command
48+
- [`packages/kit/src/core`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/core) - code that's called at dev/build-time
49+
- [`packages/kit/src/core/sync`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/core/sync) - for `svelte-kit sync`, which regenerates routing info and type definitions
50+
- [`packages/kit/src/runtime`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/runtime) - code that's called at runtime
51+
- [`packages/kit/src/exports/vite`](https://github.com/sveltejs/kit/tree/main/packages/kit/src/exports/vite) - for all the Vite plugin related stuff
52+
- [`packages/adapter-[platform]`](https://github.com/sveltejs/kit/tree/main/packages) - for the various SvelteKit-provided adapters
5353

5454
## Good first issues
5555

@@ -101,7 +101,7 @@ If you would like to test local changes to Vite or another dependency, you can b
101101

102102
## Documentation changes
103103

104-
All documentation for SvelteKit is in the [`documentation` directory](https://github.com/sveltejs/kit/tree/master/documentation), and any improvements should be made as a Pull Request to this repository. The site itself is located in the [`sites/kit.svelte.dev` directory](https://github.com/sveltejs/kit/tree/master/sites/kit.svelte.dev) and can be run locally to preview changes.
104+
All documentation for SvelteKit is in the [`documentation` directory](https://github.com/sveltejs/kit/tree/main/documentation), and any improvements should be made as a Pull Request to this repository. The site itself is located in the [`sites/kit.svelte.dev` directory](https://github.com/sveltejs/kit/tree/main/sites/kit.svelte.dev) and can be run locally to preview changes.
105105

106106
## Sending PRs
107107

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Web development, streamlined. Read the [documentation](https://kit.svelte.dev/do
2222
| [create-svelte](packages/create-svelte) | [Changelog](packages/create-svelte/CHANGELOG.md) |
2323
| [svelte-migrate](packages/migrate) | [Changelog](packages/migrate/CHANGELOG.md) |
2424

25-
[Additional adapters](<(https://sveltesociety.dev/components#adapters)>) are maintained by the community.
25+
[Additional adapters](<(https://sveltesociety.dev/packages#svelte-kit-adapters)>) are maintained by the community.
2626

2727
## Bug reporting
2828

@@ -44,4 +44,4 @@ Funds donated via Open Collective will be used for compensating expenses related
4444

4545
## License
4646

47-
[MIT](https://github.com/sveltejs/kit/blob/master/LICENSE)
47+
[MIT](https://github.com/sveltejs/kit/blob/main/LICENSE)

documentation/docs/10-getting-started/20-creating-a-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ Try editing the files to get a feel for how everything works.
2222

2323
## Editor setup
2424

25-
We recommend using [Visual Studio Code (aka VS Code)](https://code.visualstudio.com/download) with [the Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), but [support also exists for numerous other editors](https://sveltesociety.dev/tools#editor-support).
25+
We recommend using [Visual Studio Code (aka VS Code)](https://code.visualstudio.com/download) with [the Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), but [support also exists for numerous other editors](https://sveltesociety.dev/resources#editor-support).

documentation/docs/20-core-concepts/30-form-actions.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ Each action receives a `RequestEvent` object, allowing you to read the data with
108108
```js
109109
// @errors: 2304
110110
/// file: src/routes/login/+page.server.js
111+
import { base } from '$app/paths';
112+
111113
/** @type {import('./$types').PageServerLoad} */
112114
export async function load({ cookies }) {
113115
const user = await db.getUserFromSession(cookies.get('sessionid'));
@@ -122,7 +124,7 @@ export const actions = {
122124
const password = data.get('password');
123125

124126
const user = await db.getUser(email);
125-
cookies.set('sessionid', await db.createSession(user));
127+
cookies.set('sessionid', await db.createSession(user), { path: base});
126128

127129
return { success: true };
128130
},
@@ -156,6 +158,7 @@ If the request couldn't be processed because of invalid data, you can return val
156158
```diff
157159
/// file: src/routes/login/+page.server.js
158160
+import { fail } from '@sveltejs/kit';
161+
import { base } from '$app/paths';
159162

160163
/** @type {import('./$types').Actions} */
161164
export const actions = {
@@ -174,7 +177,7 @@ export const actions = {
174177
+ return fail(400, { email, incorrect: true });
175178
+ }
176179

177-
cookies.set('sessionid', await db.createSession(user));
180+
cookies.set('sessionid', await db.createSession(user), { path: base });
178181

179182
return { success: true };
180183
},
@@ -214,6 +217,7 @@ Redirects (and errors) work exactly the same as in [`load`](load#redirects):
214217
```diff
215218
/// file: src/routes/login/+page.server.js
216219
+import { fail, redirect } from '@sveltejs/kit';
220+
import { base } from '$app/paths';
217221

218222
/** @type {import('./$types').Actions} */
219223
export const actions = {
@@ -231,7 +235,7 @@ export const actions = {
231235
return fail(400, { email, incorrect: true });
232236
}
233237

234-
cookies.set('sessionid', await db.createSession(user));
238+
cookies.set('sessionid', await db.createSession(user), { path: base });
235239

236240
+ if (url.searchParams.has('redirectTo')) {
237241
+ redirect(303, url.searchParams.get('redirectTo'));
@@ -293,6 +297,8 @@ declare namespace App {
293297

294298
// @filename: index.js
295299
// ---cut---
300+
import { base } from '$app/paths';
301+
296302
/** @type {import('./$types').PageServerLoad} */
297303
export function load(event) {
298304
return {
@@ -303,7 +309,7 @@ export function load(event) {
303309
/** @type {import('./$types').Actions} */
304310
export const actions = {
305311
logout: async (event) => {
306-
event.cookies.delete('sessionid');
312+
event.cookies.delete('sessionid', { path: base });
307313
event.locals.user = null;
308314
}
309315
};

documentation/docs/20-core-concepts/40-page-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Routes with `prerender = true` will be excluded from manifests used for dynamic
3131
export const prerender = 'auto';
3232
```
3333

34-
> If your entire app is suitable for prerendering, you can use [`adapter-static`](https://github.com/sveltejs/kit/tree/master/packages/adapter-static), which will output files suitable for use with any static webserver.
34+
> If your entire app is suitable for prerendering, you can use [`adapter-static`](https://github.com/sveltejs/kit/tree/main/packages/adapter-static), which will output files suitable for use with any static webserver.
3535
3636
The prerenderer will start at the root of your app and generate files for any prerenderable pages or `+server.js` routes it finds. Each page is scanned for `<a>` elements that point to other pages that are candidates for prerendering — because of this, you generally don't need to specify which pages should be accessed. If you _do_ need to specify which pages should be accessed by the prerenderer, you can do so with [`config.kit.prerender.entries`](configuration#prerender), or by exporting an [`entries`](#entries) function from your dynamic route.
3737

documentation/docs/25-build-and-deploy/20-adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Official adapters exist for a variety of platforms — these are documented on t
1313
- [`@sveltejs/adapter-static`](adapter-static) for static site generation (SSG)
1414
- [`@sveltejs/adapter-vercel`](adapter-vercel) for Vercel
1515

16-
Additional [community-provided adapters](https://sveltesociety.dev/components#adapters) exist for other platforms.
16+
Additional [community-provided adapters](https://sveltesociety.dev/packages#svelte-kit-adapters) exist for other platforms.
1717

1818
## Using adapters
1919

documentation/docs/25-build-and-deploy/30-adapter-auto.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: Zero-config deployments
33
---
44

5-
When you create a new SvelteKit project with `npm create svelte@latest`, it installs [`adapter-auto`](https://github.com/sveltejs/kit/tree/master/packages/adapter-auto) by default. This adapter automatically installs and uses the correct adapter for supported environments when you deploy:
5+
When you create a new SvelteKit project with `npm create svelte@latest`, it installs [`adapter-auto`](https://github.com/sveltejs/kit/tree/main/packages/adapter-auto) by default. This adapter automatically installs and uses the correct adapter for supported environments when you deploy:
66

77
- [`@sveltejs/adapter-cloudflare`](adapter-cloudflare) for [Cloudflare Pages](https://developers.cloudflare.com/pages/)
88
- [`@sveltejs/adapter-netlify`](adapter-netlify) for [Netlify](https://netlify.com/)
99
- [`@sveltejs/adapter-vercel`](adapter-vercel) for [Vercel](https://vercel.com/)
1010
- [`svelte-adapter-azure-swa`](https://github.com/geoffrich/svelte-adapter-azure-swa) for [Azure Static Web Apps](https://docs.microsoft.com/en-us/azure/static-web-apps/)
11-
- [`svelte-kit-sst`](https://github.com/serverless-stack/sst/tree/master/packages/svelte-kit-sst) for [AWS via SST](https://docs.sst.dev/start/svelte)
11+
- [`svelte-kit-sst`](https://github.com/serverless-stack/sst/tree/main/packages/svelte-kit-sst) for [AWS via SST](https://docs.sst.dev/start/svelte)
1212

1313
It's recommended to install the appropriate adapter to your `devDependencies` once you've settled on a target environment, since this will add the adapter to your lockfile and slightly improve install times on CI.
1414

@@ -18,4 +18,4 @@ To add configuration options, such as `{ edge: true }` in [`adapter-vercel`](ada
1818

1919
## Adding community adapters
2020

21-
You can add zero-config support for additional adapters by editing [adapters.js](https://github.com/sveltejs/kit/blob/master/packages/adapter-auto/adapters.js) and opening a pull request.
21+
You can add zero-config support for additional adapters by editing [adapters.js](https://github.com/sveltejs/kit/blob/main/packages/adapter-auto/adapters.js) and opening a pull request.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Node servers
33
---
44

5-
To generate a standalone Node server, use [`adapter-node`](https://github.com/sveltejs/kit/tree/master/packages/adapter-node).
5+
To generate a standalone Node server, use [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node).
66

77
## Usage
88

documentation/docs/25-build-and-deploy/50-adapter-static.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Static site generation
33
---
44

5-
To use SvelteKit as a static site generator (SSG), use [`adapter-static`](https://github.com/sveltejs/kit/tree/master/packages/adapter-static).
5+
To use SvelteKit as a static site generator (SSG), use [`adapter-static`](https://github.com/sveltejs/kit/tree/main/packages/adapter-static).
66

77
This will prerender your entire site as a collection of static files. If you'd like to prerender only some pages and dynamically server-render others, you will need to use a different adapter together with [the `prerender` option](page-options#prerender).
88

documentation/docs/25-build-and-deploy/60-adapter-cloudflare.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Cloudflare Pages
33
---
44

5-
To deploy to [Cloudflare Pages](https://developers.cloudflare.com/pages/), use [`adapter-cloudflare`](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare).
5+
To deploy to [Cloudflare Pages](https://developers.cloudflare.com/pages/), use [`adapter-cloudflare`](https://github.com/sveltejs/kit/tree/main/packages/adapter-cloudflare).
66

77
This adapter will be installed by default when you use [`adapter-auto`](adapter-auto). If you plan on staying with Cloudflare Pages you can switch from [`adapter-auto`](adapter-auto) to using this adapter directly so that type declarations will be automatically applied and you can set Cloudflare-specific options.
88

documentation/docs/25-build-and-deploy/70-adapter-cloudflare-workers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Cloudflare Workers
33
---
44

5-
To deploy to [Cloudflare Workers](https://workers.cloudflare.com/), use [`adapter-cloudflare-workers`](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare-workers).
5+
To deploy to [Cloudflare Workers](https://workers.cloudflare.com/), use [`adapter-cloudflare-workers`](https://github.com/sveltejs/kit/tree/main/packages/adapter-cloudflare-workers).
66

77
> Unless you have a specific reason to use `adapter-cloudflare-workers`, it's recommended that you use `adapter-cloudflare` instead. Both adapters have equivalent functionality, but Cloudflare Pages offers features like GitHub integration with automatic builds and deploys, preview deployments, instant rollback and so on.
88

documentation/docs/25-build-and-deploy/80-adapter-netlify.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Netlify
33
---
44

5-
To deploy to Netlify, use [`adapter-netlify`](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify).
5+
To deploy to Netlify, use [`adapter-netlify`](https://github.com/sveltejs/kit/tree/main/packages/adapter-netlify).
66

77
This adapter will be installed by default when you use [`adapter-auto`](adapter-auto), but adding it to your project allows you to specify Netlify-specific options.
88

documentation/docs/25-build-and-deploy/90-adapter-vercel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Vercel
33
---
44

5-
To deploy to Vercel, use [`adapter-vercel`](https://github.com/sveltejs/kit/tree/master/packages/adapter-vercel).
5+
To deploy to Vercel, use [`adapter-vercel`](https://github.com/sveltejs/kit/tree/main/packages/adapter-vercel).
66

77
This adapter will be installed by default when you use [`adapter-auto`](adapter-auto), but adding it to your project allows you to specify Vercel-specific options.
88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Writing adapters
33
---
44

5-
If an adapter for your preferred environment doesn't yet exist, you can build your own. We recommend [looking at the source for an adapter](https://github.com/sveltejs/kit/tree/master/packages) to a platform similar to yours and copying it as a starting point.
5+
If an adapter for your preferred environment doesn't yet exist, you can build your own. We recommend [looking at the source for an adapter](https://github.com/sveltejs/kit/tree/main/packages) to a platform similar to yours and copying it as a starting point.
66

77
Adapters packages must implement the following API, which creates an `Adapter`:
88

documentation/docs/30-advanced/10-advanced-routing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ If the number of route segments is unknown, you can use rest syntax — for exam
1010
/[org]/[repo]/tree/[branch]/[...file]
1111
```
1212

13-
...in which case a request for `/sveltejs/kit/tree/master/documentation/docs/04-advanced-routing.md` would result in the following parameters being available to the page:
13+
...in which case a request for `/sveltejs/kit/tree/main/documentation/docs/04-advanced-routing.md` would result in the following parameters being available to the page:
1414

1515
```js
1616
// @noErrors
1717
{
1818
org: 'sveltejs',
1919
repo: 'kit',
20-
branch: 'master',
20+
branch: 'main',
2121
file: 'documentation/docs/04-advanced-routing.md'
2222
}
2323
```

documentation/docs/30-advanced/60-images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ If you wish to add styles to your `<enhanced:img>`, you should add a `class` and
6767

6868
### Dynamically choosing an image
6969

70-
You can also manually import an image asset and pass it to an `<enhanced:img>`. This is useful when you have a collection of static images and would like to dynamically choose one or [iterate over them](https://github.com/sveltejs/kit/blob/master/sites/kit.svelte.dev/src/routes/home/Showcase.svelte). In this case you will need to update both the `import` statement and `<img>` element as shown below to indicate you'd like process them.
70+
You can also manually import an image asset and pass it to an `<enhanced:img>`. This is useful when you have a collection of static images and would like to dynamically choose one or [iterate over them](https://github.com/sveltejs/kit/blob/main/sites/kit.svelte.dev/src/routes/home/Showcase.svelte). In this case you will need to update both the `import` statement and `<img>` element as shown below to indicate you'd like process them.
7171

7272
```svelte
7373
<script>

documentation/docs/60-appendix/20-integrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Integrations
44

55
## Preprocessors
66

7-
Preprocessors transform your `.svelte` files before passing them to the compiler. For example, if your `.svelte` file uses TypeScript and PostCSS, it must first be transformed into JavaScript and CSS so that the Svelte compiler can handle it. There are many [available preprocessors](https://sveltesociety.dev/tools#preprocessors). The Svelte team maintains two official ones discussed below.
7+
Preprocessors transform your `.svelte` files before passing them to the compiler. For example, if your `.svelte` file uses TypeScript and PostCSS, it must first be transformed into JavaScript and CSS so that the Svelte compiler can handle it. There are many [available preprocessors](https://sveltesociety.dev/packages#preprocessors). The Svelte team maintains two official ones discussed below.
88

99
### `vitePreprocess`
1010

documentation/docs/60-appendix/30-migrating-to-sveltekit-2.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function load({ fetch }) {
6868

6969
## goto(...) changes
7070

71-
`goto(...)` no longer accepts external URLs. To navigate to an external URL, use `window.location = url`. The `state` option was removed in favor of [shallow routing](shallow-routing).
71+
`goto(...)` no longer accepts external URLs. To navigate to an external URL, use `window.location = url`. The `state` object now determines `$page.state` and must adhere to the `App.PageState` interface, if declared. See [shallow routing](shallow-routing) for more details.
7272

7373
## paths are now relative by default
7474

@@ -150,8 +150,13 @@ SvelteKit 2 requires Node `18.13` or higher, and the following minimum dependenc
150150
- `svelte@4`
151151
- `vite@5`
152152
- `typescript@5`
153-
- `@sveltejs/adapter-static@3` (if you're using it)
154153
- `@sveltejs/vite-plugin-svelte@3` (this is now required as a `peerDependency` of SvelteKit — previously it was directly depended upon)
154+
- `@sveltejs/adapter-cloudflare@3` (if you're using these adapters)
155+
- `@sveltejs/adapter-cloudflare-workers@2`
156+
- `@sveltejs/adapter-netlify@3`
157+
- `@sveltejs/adapter-node@2`
158+
- `@sveltejs/adapter-static@3`
159+
- `@sveltejs/adapter-vercel@4`
155160

156161
`svelte-migrate` will update your `package.json` for you.
157162

0 commit comments

Comments
 (0)