Skip to content

Commit 3e4787a

Browse files
authored
Merge branch 'sveltejs:master' into fix/kv-error-cloudflare-workers
2 parents 56ae111 + 3a8195d commit 3e4787a

File tree

177 files changed

+3357
-3499
lines changed

Some content is hidden

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

177 files changed

+3357
-3499
lines changed

.changeset/fuzzy-coats-pay.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+
chore: revert undici pin and upgrade version

.changeset/smart-terms-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-svelte': patch
3+
---
4+
5+
feat: upgrade to Vite 4.3 for faster build times

.changeset/strong-bikes-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-svelte': patch
3+
---
4+
5+
fix: generate tsconfig/jsconfig correctly for library option

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,14 @@ jobs:
123123
retention-days: 3
124124
name: test-failure-cross-platform-${{ matrix.mode }}-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
125125
path: test-results-cross-platform-${{ matrix.mode }}.tar.gz
126+
Test-create-svelte:
127+
runs-on: ubuntu-latest
128+
steps:
129+
- uses: actions/checkout@v3
130+
- uses: pnpm/[email protected]
131+
- uses: actions/setup-node@v3
132+
with:
133+
node-version: 16
134+
cache: pnpm
135+
- run: pnpm install --frozen-lockfile
136+
- run: pnpm run test:create-svelte

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 });

0 commit comments

Comments
 (0)