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

documentation/docs/30-advanced/40-service-workers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ self.addEventListener('fetch', (event) => {
6666

6767
// `build`/`files` can always be served from the cache
6868
if (ASSETS.includes(url.pathname)) {
69-
return cache.match(event.request);
69+
return cache.match(url.pathname);
7070
}
7171

7272
// for everything else, try the network first, but

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"description": "monorepo for @sveltejs/kit and friends",
55
"private": true,
66
"scripts": {
7-
"test": "pnpm test -r --filter=./packages/*",
7+
"test": "pnpm test -r --filter=./packages/* --filter=!./packages/create-svelte",
88
"test:cross-platform:dev": "pnpm run --dir packages/kit test:cross-platform:dev",
99
"test:cross-platform:build": "pnpm run --dir packages/kit test:cross-platform:build",
1010
"test:vite-ecosystem-ci": "pnpm test --dir packages/kit",
11+
"test:create-svelte": "pnpm run --dir packages/create-svelte test",
1112
"check": "pnpm -r check",
1213
"lint": "pnpm -r lint && eslint 'packages/**/*.js'",
1314
"format": "pnpm -r format",
@@ -41,9 +42,9 @@
4142
"tiny-glob": "^0.2.9",
4243
"typescript": "^4.9.4"
4344
},
44-
"packageManager": "pnpm@7.30.1",
45+
"packageManager": "pnpm@8.3.1",
4546
"engines": {
46-
"pnpm": "^7.0.0"
47+
"pnpm": "^8.0.0"
4748
},
4849
"type": "module"
4950
}

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-node/src/handler.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,19 @@ const ssr = async (req, res) => {
144144
function sequence(handlers) {
145145
/** @type {import('polka').Middleware} */
146146
return (req, res, next) => {
147-
/** @param {number} i */
147+
/**
148+
* @param {number} i
149+
* @returns {ReturnType<import('polka').Middleware>}
150+
*/
148151
function handle(i) {
149-
handlers[i](req, res, () => {
150-
if (i < handlers.length) handle(i + 1);
151-
else next();
152-
});
152+
if (i < handlers.length) {
153+
return handlers[i](req, res, () => handle(i + 1));
154+
} else {
155+
return next();
156+
}
153157
}
154158

155-
handle(0);
159+
return handle(0);
156160
};
157161
}
158162

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: 3 additions & 2 deletions
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",
@@ -35,7 +36,7 @@
3536
"svelte": "^3.56.0",
3637
"typescript": "^4.9.4",
3738
"uvu": "^0.5.6",
38-
"vite": "^4.2.0"
39+
"vite": "^4.3.0"
3940
},
4041
"peerDependencies": {
4142
"@sveltejs/kit": "^1.5.0"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"devDependencies": {
1111
"@sveltejs/kit": "workspace:^",
1212
"svelte": "^3.56.0",
13-
"vite": "^4.2.0"
13+
"vite": "^4.3.0"
1414
},
1515
"type": "module"
1616
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@sveltejs/kit": "workspace:^",
1313
"sirv-cli": "^2.0.2",
1414
"svelte": "^3.56.0",
15-
"vite": "^4.2.0"
15+
"vite": "^4.3.0"
1616
},
1717
"type": "module"
1818
}

0 commit comments

Comments
 (0)