Skip to content

Commit ad3f298

Browse files
author
Rich Harris
committed
merge master
2 parents fd250ff + a243aa6 commit ad3f298

File tree

132 files changed

+2878
-2879
lines changed

Some content is hidden

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

132 files changed

+2878
-2879
lines changed

.changeset/curly-items-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: provide better error when prerendered routes conflict with each other

.changeset/flat-trainers-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: prevent false positive warnings for fetch in Firefox and Safari

.changeset/late-toes-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: allow embedding two pages generated into the same page in "embedded" mode

.changeset/old-teachers-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: don't include prerendered routes in default generateManifest

.changeset/tall-bags-sparkle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: better error messages for handleable prerender failures

documentation/docs/10-getting-started/30-project-structure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ The `src` directory contains the meat of your project. Everything except `src/ro
5454
- `hooks.server.js` contains your server [hooks](/docs/hooks)
5555
- `service-worker.js` contains your [service worker](/docs/service-workers)
5656

57-
You can use `.ts` files instead of `.js` files, if using TypeScript.
57+
(Whether the project contains `.js` or `.ts` files depends on whether you opt to use TypeScript when you create your project. You can switch between JavaScript and TypeScript in the documentation using the toggle at the bottom of this page.)
5858

59-
If you added [Vitest](https://vitest.dev) when you set up your project, your unit tests will live in the `src` directory with a `.test.js` (or `.test.ts`) extension.
59+
If you added [Vitest](https://vitest.dev) when you set up your project, your unit tests will live in the `src` directory with a `.test.js` extension.
6060

6161
### static
6262

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ A `+page.svelte` component defines a page of your app. By default, pages are ren
4646
4747
### +page.js
4848

49-
Often, a page will need to load some data before it can be rendered. For this, we add a `+page.js` (or `+page.ts`, if you're TypeScript-inclined) module that exports a `load` function:
49+
Often, a page will need to load some data before it can be rendered. For this, we add a `+page.js` module that exports a `load` function:
5050

5151
```js
5252
/// file: src/routes/blog/[slug]/+page.js
@@ -248,7 +248,7 @@ Like `+layout.js`, `+layout.server.js` can export [page options](page-options)
248248

249249
## +server
250250

251-
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 (or `+server.ts`) exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT`, `DELETE`, and `OPTIONS` that take a `RequestEvent` argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
251+
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`, and `OPTIONS` that take a `RequestEvent` argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
252252

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

documentation/docs/20-core-concepts/20-load.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Before a [`+page.svelte`](routing#page-page-svelte) component (and its containin
66

77
## Page data
88

9-
A `+page.svelte` file can have a sibling `+page.js` (or `+page.ts`) that exports a `load` function, the return value of which is available to the page via the `data` prop:
9+
A `+page.svelte` file can have a sibling `+page.js` that exports a `load` function, the return value of which is available to the page via the `data` prop:
1010

1111
```js
1212
/// file: src/routes/blog/[slug]/+page.js

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ For that reason among others, it's recommended that you always include a file ex
7878

7979
For _pages_, we skirt around this problem by writing `foo/index.html` instead of `foo`.
8080

81-
Note that this will disable client-side routing for any navigation from this page, regardless of whether the router is already active.
82-
8381
### Troubleshooting
8482

8583
If you encounter an error like 'The following routes were marked as prerenderable, but were not prerendered' it's because the route in question (or a parent layout, if it's a page) has `export const prerender = true` but the page wasn't actually prerendered, because it wasn't reached by the prerendering crawler.

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

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ You will have to prevent GitHub's provided Jekyll from managing your site by put
8989
A config for GitHub Pages might look like the following:
9090

9191
```js
92-
// @errors: 2307
92+
// @errors: 2307 2322
9393
/// file: svelte.config.js
9494
import adapter from '@sveltejs/adapter-static';
9595

@@ -100,8 +100,71 @@ const config = {
100100
kit: {
101101
adapter: adapter(),
102102
paths: {
103-
base: dev ? '' : '/your-repo-name',
103+
base: dev ? '' : process.env.BASE_PATH,
104104
}
105105
}
106106
};
107107
```
108+
109+
You can use GitHub actions to automatically deploy your site to GitHub Pages when you make a change. Here's an example workflow:
110+
111+
```yaml
112+
/// file: .github/workflows/deploy.yml
113+
name: Deploy to GitHub Pages
114+
115+
on:
116+
push:
117+
branches: 'main'
118+
119+
jobs:
120+
build_site:
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Checkout
124+
uses: actions/checkout@v3
125+
126+
# If you're using pnpm, add this step then change the commands and cache key below to use `pnpm`
127+
# - name: Install pnpm
128+
# uses: pnpm/action-setup@v2
129+
# with:
130+
# version: 8
131+
132+
- name: Install Node.js
133+
uses: actions/setup-node@v3
134+
with:
135+
node-version: 18
136+
cache: npm
137+
138+
- name: Install dependencies
139+
run: npm install
140+
141+
- name: build
142+
env:
143+
BASE_PATH: '/your-repo-name'
144+
run: |
145+
npm run build
146+
touch build/.nojekyll
147+
148+
- name: Upload Artifacts
149+
uses: actions/upload-pages-artifact@v1
150+
with:
151+
# this should match the `pages` option in your adapter-static options
152+
path: 'build/'
153+
154+
deploy:
155+
needs: build_site
156+
runs-on: ubuntu-latest
157+
158+
permissions:
159+
pages: write
160+
id-token: write
161+
162+
environment:
163+
name: github-pages
164+
url: ${{ steps.deployment.outputs.page_url }}
165+
166+
steps:
167+
- name: Deploy
168+
id: deployment
169+
uses: actions/deploy-pages@v1
170+
```

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ For example, your `load` function might make a request to a public URL like `htt
9999
```js
100100
/// file: src/hooks.server.js
101101
/** @type {import('@sveltejs/kit').HandleFetch} */
102-
export function handleFetch({ request, fetch }) {
102+
export async function handleFetch({ request, fetch }) {
103103
if (request.url.startsWith('https://api.yourapp.com/')) {
104104
// clone the original request, but change the URL
105105
request = new Request(
@@ -124,7 +124,7 @@ If your app and your API are on sibling subdomains — `www.my-domain.com` and `
124124
/// file: src/hooks.server.js
125125
// @errors: 2345
126126
/** @type {import('@sveltejs/kit').HandleFetch} */
127-
export function handleFetch({ event, request, fetch }) {
127+
export async function handleFetch({ event, request, fetch }) {
128128
if (request.url.startsWith('https://api.my-domain.com/')) {
129129
request.headers.set('cookie', event.request.headers.get('cookie'));
130130
}
@@ -177,7 +177,7 @@ import crypto from 'crypto';
177177
Sentry.init({/*...*/})
178178

179179
/** @type {import('@sveltejs/kit').HandleServerError} */
180-
export function handleError({ error, event }) {
180+
export async function handleError({ error, event }) {
181181
const errorId = crypto.randomUUID();
182182
// example integration with https://sentry.io/
183183
Sentry.captureException(error, { event, errorId });
@@ -205,7 +205,7 @@ import * as Sentry from '@sentry/svelte';
205205
Sentry.init({/*...*/})
206206

207207
/** @type {import('@sveltejs/kit').HandleClientError} */
208-
export function handleError({ error, event }) {
208+
export async function handleError({ error, event }) {
209209
const errorId = crypto.randomUUID();
210210
// example integration with https://sentry.io/
211211
Sentry.captureException(error, { event, errorId });

documentation/docs/30-advanced/70-packaging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ You should ship type definitions for your library even if you don't use TypeScri
132132

133133
If you have something else than a root export however — for example providing a `your-library/foo` import — you need to take additional care for providing type definitions. Unfortunately, TypeScript by default will _not_ resolve the `types` condition for an export like `{ "./foo": { "types": "./dist/foo.d.ts", ... }}`. Instead, it will search for a `foo.d.ts` relative to the root of your library (i.e. `your-library/foo.d.ts` instead of `your-library/dist/foo.d.ts`). To fix this, you have two options:
134134

135-
The first option is to require people using your library to set the `moduleResolution` option in their `tsconfig/jsconfig.json` to `bundler` (available since TypeScript 5, the best and recommended option in the future), `node16` or `nodenext`. This opts TypeScript into actually looking at the exports map and resolving the types correctly.
135+
The first option is to require people using your library to set the `moduleResolution` option in their `tsconfig.json` (or `jsconfig.json`) to `bundler` (available since TypeScript 5, the best and recommended option in the future), `node16` or `nodenext`. This opts TypeScript into actually looking at the exports map and resolving the types correctly.
136136

137137
The second option is to (ab)use the `typesVersions` feature from TypeScript to wire up the types. This is a field inside `package.json` TypeScript uses to check for different type definitions depending on the TypeScript version, and also contains a path mapping feature for that. We leverage that path mapping feature to get what we want. For the mentioned `foo` export above, the corresponding `typesVersions` looks like this:
138138

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"tiny-glob": "^0.2.9",
4242
"typescript": "^4.9.4"
4343
},
44-
"packageManager": "pnpm@7.30.0",
44+
"packageManager": "pnpm@8.2.0",
4545
"engines": {
46-
"pnpm": "^7.0.0"
46+
"pnpm": "^8.0.0"
4747
},
4848
"type": "module"
4949
}

packages/adapter-auto/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-auto",
33
"version": "2.0.0",
4+
"description": "Automatically chooses the SvelteKit adapter for your current environment, if possible.",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",

packages/adapter-cloudflare-workers/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-cloudflare-workers",
33
"version": "1.1.0",
4+
"description": "SvelteKit adapter that creates a Cloudflare Workers site using a function for dynamic server rendering",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",

packages/adapter-cloudflare/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-cloudflare",
33
"version": "2.2.0",
4+
"description": "Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",
@@ -33,7 +34,7 @@
3334
"dependencies": {
3435
"@cloudflare/workers-types": "^4.20221111.1",
3536
"esbuild": "^0.16.3",
36-
"worktop": "0.8.0-next.14"
37+
"worktop": "0.8.0-next.15"
3738
},
3839
"devDependencies": {
3940
"@types/node": "^16.18.6",

packages/adapter-netlify/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-netlify",
33
"version": "2.0.6",
4+
"description": "A SvelteKit adapter that creates a Netlify app",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",
@@ -44,7 +45,7 @@
4445
"@sveltejs/kit": "workspace:^",
4546
"@types/node": "^16.18.6",
4647
"@types/set-cookie-parser": "^2.4.2",
47-
"rimraf": "^4.0.0",
48+
"rimraf": "^5.0.0",
4849
"rollup": "^3.7.0",
4950
"typescript": "^4.9.4",
5051
"uvu": "^0.5.6"

packages/adapter-node/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-node",
33
"version": "1.2.3",
4+
"description": "Adapter for SvelteKit apps that generates a standalone Node server",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",
@@ -37,7 +38,7 @@
3738
"@types/node": "^16.18.6",
3839
"c8": "^7.12.0",
3940
"polka": "^1.0.0-next.22",
40-
"rimraf": "^4.0.0",
41+
"rimraf": "^5.0.0",
4142
"sirv": "^2.0.2",
4243
"typescript": "^4.9.4",
4344
"uvu": "^0.5.6"

packages/adapter-static/CHANGELOG.md

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

3+
## 2.0.2
4+
5+
### Patch Changes
6+
7+
- fix: update broken link in error message ([`118ce5a0`](https://github.com/sveltejs/kit/commit/118ce5a07a3a984353c3fc858b34c67e9e560fa0))
8+
9+
- Updated dependencies [[`748a8720`](https://github.com/sveltejs/kit/commit/748a8720fea8ea938576041207b81e19bb8f7dff)]:
10+
- @sveltejs/kit@1.15.3
11+
312
## 2.0.1
413

514
### Patch Changes

packages/adapter-static/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function (options) {
2525
${builder.routes.map((route) => ` - ${path.posix.join(prefix, route.id)}`).join('\n')}
2626
2727
You have the following options:
28-
- set the \`fallback\` option — see https://github.com/sveltejs/kit/tree/master/packages/adapter-static#spa-mode for more info.
28+
- set the \`fallback\` option — see https://kit.svelte.dev/docs/single-page-apps#usage for more info.
2929
- add \`export const prerender = true\` to your root \`+layout.js/.ts\` or \`+layout.server.js/.ts\` file. This will try to prerender all pages.
3030
- add \`export const prerender = true\` to any \`+server.js/ts\` files that are not fetched by page \`load\` functions.
3131
${config_option}

packages/adapter-static/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-static",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
4+
"description": "Adapter for SvelteKit apps that prerenders your entire site as a collection of static files",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",

packages/adapter-vercel/CHANGELOG.md

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

3+
## 2.4.1
4+
5+
### Patch Changes
6+
7+
- fix: create separate functions for ISR routes ([#9504](https://github.com/sveltejs/kit/pull/9504))
8+
39
## 2.4.0
410

511
### Minor Changes

packages/adapter-vercel/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ function hash_config(config) {
353353
config.external ?? '',
354354
config.regions ?? '',
355355
config.memory ?? '',
356-
config.maxDuration ?? ''
356+
config.maxDuration ?? '',
357+
!!config.isr // need to distinguish ISR from non-ISR functions, because ISR functions can't use streaming mode
357358
].join('/');
358359
}
359360

packages/adapter-vercel/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/adapter-vercel",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
4+
"description": "A SvelteKit adapter that creates a Vercel app",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",

packages/amp/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@sveltejs/amp",
33
"version": "1.0.2",
4+
"description": "AMP integration for SvelteKit",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",

packages/create-svelte/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# create-svelte
22

3+
## 3.3.0
4+
5+
### Minor Changes
6+
7+
- feat: ignore test files in library skeleton package.json ([#9584](https://github.com/sveltejs/kit/pull/9584))
8+
39
## 3.2.0
410

511
### Minor Changes

packages/create-svelte/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "create-svelte",
3-
"version": "3.2.0",
3+
"version": "3.3.0",
4+
"description": "A CLI for creating new SvelteKit projects",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/sveltejs/kit",

packages/create-svelte/templates/skeletonlib/package.template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"svelte": "./dist/index.js"
1515
}
1616
},
17-
"files": ["dist"],
17+
"files": ["dist", "!dist/**/*.test.*", "!dist/**/*.spec.*"],
1818
"peerDependencies": {
1919
"svelte": "^3.54.0"
2020
},

0 commit comments

Comments
 (0)