Skip to content

Commit f991ec3

Browse files
committed
Merge branch 'master' into gh-6868
2 parents 24b9462 + 6afc01c commit f991ec3

File tree

117 files changed

+2568
-2170
lines changed

Some content is hidden

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

117 files changed

+2568
-2170
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,10 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
node-version: [16]
42-
os: [ubuntu-latest, windows-latest]
43-
e2e-browser: ['chromium']
4441
include:
4542
- node-version: 16
4643
os: ubuntu-latest
47-
e2e-browser: 'firefox'
48-
- node-version: 16
49-
os: macOS-latest
50-
e2e-browser: 'webkit'
44+
e2e-browser: 'chromium'
5145
- node-version: 18
5246
os: ubuntu-latest
5347
e2e-browser: 'chromium'
@@ -76,3 +70,41 @@ jobs:
7670
retention-days: 3
7771
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
7872
path: test-results.tar.gz
73+
Cross-browser-test:
74+
runs-on: ${{ matrix.os }}
75+
timeout-minutes: 30
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
include:
80+
- node-version: 16
81+
os: windows-2019 # slowness reported on newer versions https://github.com/actions/runner-images/issues/5166
82+
e2e-browser: 'firefox'
83+
- node-version: 16
84+
os: macOS-latest
85+
e2e-browser: 'webkit'
86+
env:
87+
TURBO_CACHE_KEY: ${{ matrix.os }}-${{ matrix.node-version }}
88+
KIT_E2E_BROWSER: ${{matrix.e2e-browser}}
89+
steps:
90+
- run: git config --global core.autocrlf false
91+
- uses: actions/checkout@v3
92+
- uses: pnpm/[email protected]
93+
- uses: actions/setup-node@v3
94+
with:
95+
node-version: ${{ matrix.node-version }}
96+
cache: pnpm
97+
- run: pnpm install --frozen-lockfile
98+
- run: pnpm playwright install ${{ matrix.e2e-browser }}
99+
- run: pnpm test:cross-platform
100+
- name: Archive test results
101+
if: failure()
102+
shell: bash
103+
run: find packages -type d -name test-results -not -empty | tar -czf test-results-cross-platform.tar.gz --files-from=-
104+
- name: Upload test results
105+
if: failure()
106+
uses: actions/upload-artifact@v3
107+
with:
108+
retention-days: 3
109+
name: test-failure-cross-platform-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
110+
path: test-results-cross-platform.tar.gz

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ You can run the test server with `cd packages/kit/test/apps/basics; pnpm run dev
4444

4545
You may need to install some dependencies first, e.g. with `npx playwright install-deps` (which only works on Ubuntu).
4646

47-
If there are tests that fail on the CI, you can retrieve the failed screenshots by going to the summary page of the CI run. You can usually find this by clicking on "Details" of the check results, click "Summary" at the top-left corner, and then scroll to the bottom "Artifacts" section to download the archive.
47+
If there are tests that fail on the CI, you can retrieve the failed screenshots by going to the summary page of the CI run. You can usually find this by clicking on "Details" of the check results, clicking "Summary" at the top-left corner, and then scrolling to the bottom "Artifacts" section to download the archive.
4848

4949
It is very easy to introduce flakiness in a browser test. If you try to fix the flakiness in a test, you can run it until failure to gain some confidence you've fixed the test with a command like:
5050

@@ -85,15 +85,15 @@ There are a few guidelines we follow:
8585
- Avoid creating new test projects under `packages/kit/test/apps` but reuse an existing one when possible
8686
- Ensure `pnpm lint` and `pnpm check` pass. You can run `pnpm format` to format the code
8787

88-
To use the git hooks in the repo, which will save you waiting for CI to tell you that you forgot to lint, run this:
88+
To use the git hooks in the repo, which will save you from waiting for CI to tell you that you forgot to lint, run this:
8989

9090
```bash
9191
git config core.hookspath .githooks
9292
```
9393

9494
### Generating changelogs
9595

96-
For changes to be reflected in package changelogs, run `pnpm changeset` and follow the prompts. All changesets should be `patch` until SvelteKit 1.0
96+
For changes to be reflected in package changelogs, run `pnpm changeset` and follow the prompts.
9797

9898
## Releases
9999

documentation/docs/10-getting-started/10-introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ title: Introduction
1010
1111
## What is SvelteKit?
1212

13-
SvelteKit is a framework for rapidly developing robust, performant web applications using [Svelte](https://svelte.dev/).
13+
SvelteKit is a framework for rapidly developing robust, performant web applications using [Svelte](https://svelte.dev/). If you're coming from React, SvelteKit is similar to Next. If you're coming from Vue, SvelteKit is similar to Nuxt.
1414

1515
## What is Svelte?
1616

@@ -20,6 +20,6 @@ In short, Svelte is a way of writing user interface components — like a naviga
2020

2121
Svelte renders UI components. You can compose these components and render an entire page with just Svelte, but you need more than just Svelte to write an entire app.
2222

23-
SvelteKit provides basic functionality like a [router](/docs/glossary#routing) — which updates the UI when a link is clicked — and [server-side rendering (SSR)](/docs/glossary#ssr). But beyond that, building an app with all the modern best practices is fiendishly complicated. Those practices include [build optimizations](https://vitejs.dev/guide/features.html#build-optimizations), so that you load only the minimal required code; [offline support](/docs/service-workers); [preloading](/docs/link-options#data-sveltekit-preload-data) pages before the user initiates navigation; [configurable rendering](/docs/page-options) that allows you to render different parts of your app on the server with [SSR](/docs/glossary#ssr), in the browser [client-side rendering](/docs/glossary#csr-and-spa), or at build-time with [prerendering](/docs/glossary#prerendering); and many other things. SvelteKit does all the boring stuff for you so that you can get on with the creative part.
23+
SvelteKit provides basic functionality like a [router](glossary#routing) — which updates the UI when a link is clicked — and [server-side rendering (SSR)](glossary#ssr). But beyond that, building an app with all the modern best practices is fiendishly complicated. Those practices include [build optimizations](https://vitejs.dev/guide/features.html#build-optimizations), so that you load only the minimal required code; [offline support](service-workers); [preloading](link-options#data-sveltekit-preload-data) pages before the user initiates navigation; [configurable rendering](page-options) that allows you to render different parts of your app on the server with [SSR](glossary#ssr), in the browser [client-side rendering](glossary#csr), or at build-time with [prerendering](glossary#prerendering); and many other things. SvelteKit does all the boring stuff for you so that you can get on with the creative part.
2424

25-
It uses [Vite](https://vitejs.dev/) with a [Svelte plugin](https://github.com/sveltejs/vite-plugin-svelte) to provide a lightning-fast and feature-rich development experience with [Hot Module Replacement (HMR)](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#hot), where changes to your code are reflected in the browser instantly.
25+
It reflects changes to your code in the browser instantly to provide a lightning-fast and feature-rich development experience by leveraging [Vite](https://vitejs.dev/) with a [Svelte plugin](https://github.com/sveltejs/vite-plugin-svelte) to do [Hot Module Replacement (HMR)](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#hot).

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ my-project/
1717
│ │ └ [your routes]
1818
│ ├ app.html
1919
│ ├ error.html
20-
│ └ hooks.js
20+
│ ├ hooks.client.js
21+
│ └ hooks.server.js
2122
├ static/
2223
│ └ [your static assets]
2324
├ tests/
@@ -34,22 +35,24 @@ You'll also find common files like `.gitignore` and `.npmrc` (and `.prettierrc`
3435

3536
### src
3637

37-
The `src` directory contains the meat of your project.
38+
The `src` directory contains the meat of your project. Everything except `src/routes` and `src/app.html` is optional.
3839

39-
- `lib` contains your library code (utilities and components), which can be imported via the [`$lib`](/docs/modules#$lib) alias, or packaged up for distribution using [`svelte-package`](/docs/packaging)
40-
- `server` contains your server-only library code. It can be imported by using the [`$lib/server`](/docs/server-only-modules) alias. SvelteKit will prevent you from importing these in client code.
41-
- `params` contains any [param matchers](/docs/advanced-routing#matching) your app needs
42-
- `routes` contains the [routes](/docs/routing) of your application. You can also colocate other components that are only used within a single route here
40+
- `lib` contains your library code (utilities and components), which can be imported via the [`$lib`](modules#$lib) alias, or packaged up for distribution using [`svelte-package`](packaging)
41+
- `server` contains your server-only library code. It can be imported by using the [`$lib/server`](server-only-modules) alias. SvelteKit will prevent you from importing these in client code.
42+
- `params` contains any [param matchers](advanced-routing#matching) your app needs
43+
- `routes` contains the [routes](routing) of your application. You can also colocate other components that are only used within a single route here
4344
- `app.html` is your page template — an HTML document containing the following placeholders:
4445
- `%sveltekit.head%``<link>` and `<script>` elements needed by the app, plus any `<svelte:head>` content
4546
- `%sveltekit.body%` — the markup for a rendered page. This should live inside a `<div>` or other element, rather than directly inside `<body>`, to prevent bugs caused by browser extensions injecting elements that are then destroyed by the hydration process. SvelteKit will warn you in development if this is not the case
46-
- `%sveltekit.assets%` — either [`paths.assets`](/docs/configuration#paths), if specified, or a relative path to [`paths.base`](/docs/configuration#paths)
47-
- `%sveltekit.nonce%` — a [CSP](/docs/configuration#csp) nonce for manually included links and scripts, if used
48-
- `error.html` (optional) is the page that is rendered when everything else fails. It can contain the following placeholders:
47+
- `%sveltekit.assets%` — either [`paths.assets`](configuration#paths), if specified, or a relative path to [`paths.base`](configuration#paths)
48+
- `%sveltekit.nonce%` — a [CSP](configuration#csp) nonce for manually included links and scripts, if used
49+
- `%sveltekit.env.[NAME]%` - this will be replaced at render time with the `[NAME]` environment variable, which must begin with the [`publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (usually `PUBLIC_`). It will fallback to `''` if not matched.
50+
- `error.html` is the page that is rendered when everything else fails. It can contain the following placeholders:
4951
- `%sveltekit.status%` — the HTTP status
5052
- `%sveltekit.error.message%` — the error message
51-
- `hooks.js` (optional) contains your application's [hooks](/docs/hooks)
52-
- `service-worker.js` (optional) contains your [service worker](/docs/service-workers)
53+
- `hooks.client.js` contains your client [hooks](/docs/hooks)
54+
- `hooks.server.js` contains your server [hooks](/docs/hooks)
55+
- `service-worker.js` contains your [service worker](/docs/service-workers)
5356

5457
You can use `.ts` files instead of `.js` files, if using TypeScript.
5558

@@ -71,18 +74,18 @@ When you create a project with `npm create svelte@latest`, you'll also notice th
7174

7275
### svelte.config.js
7376

74-
This file contains your Svelte and SvelteKit [configuration](/docs/configuration).
77+
This file contains your Svelte and SvelteKit [configuration](configuration).
7578

7679
### tsconfig.json
7780

7881
This file (or `jsconfig.json`, if you prefer type-checked `.js` files over `.ts` files) configures TypeScript, if you added typechecking during `npm create svelte@latest`. Since SvelteKit relies on certain configuration being set a specific way, it generates its own `.svelte-kit/tsconfig.json` file which your own config `extends`.
7982

8083
### vite.config.js
8184

82-
A SvelteKit project is really just a [Vite](https://vitejs.dev) project that uses the [`@sveltejs/kit/vite`](/docs/modules#sveltejs-kit-vite) plugin, along with any other [Vite configuration](https://vitejs.dev/config/).
85+
A SvelteKit project is really just a [Vite](https://vitejs.dev) project that uses the [`@sveltejs/kit/vite`](modules#sveltejs-kit-vite) plugin, along with any other [Vite configuration](https://vitejs.dev/config/).
8386

8487
## Other files
8588

8689
### .svelte-kit
8790

88-
As you develop and build your project, SvelteKit will generate files in a `.svelte-kit` directory (configurable as [`outDir`](/docs/configuration#outdir)). You can ignore its contents, and delete them at any time (they will be regenerated when you next `dev` or `build`).
91+
As you develop and build your project, SvelteKit will generate files in a `.svelte-kit` directory (configurable as [`outDir`](configuration#outdir)). You can ignore its contents, and delete them at any time (they will be regenerated when you next `dev` or `build`).

documentation/docs/10-getting-started/40-web-standards.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ title: Web standards
44

55
Throughout this documentation, you'll see references to the standard [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) that SvelteKit builds on top of. Rather than reinventing the wheel, we _use the platform_, which means your existing web development skills are applicable to SvelteKit. Conversely, time spent learning SvelteKit will help you be a better web developer elsewhere.
66

7-
These APIs are available in all modern browsers and in many non-browser environments like Cloudflare Workers, Deno and Vercel Edge Functions. During development, and in [adapters](/docs/adapters) for Node-based environments (including AWS Lambda), they're made available via polyfills where necessary (for now, that is — Node is rapidly adding support for more web standards).
7+
These APIs are available in all modern browsers and in many non-browser environments like Cloudflare Workers, Deno and Vercel Edge Functions. During development, and in [adapters](adapters) for Node-based environments (including AWS Lambda), they're made available via polyfills where necessary (for now, that is — Node is rapidly adding support for more web standards).
88

99
In particular, you'll get comfortable with the following:
1010

1111
## Fetch APIs
1212

13-
SvelteKit uses [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) for getting data from the network. It's available in [hooks](/docs/hooks) and [server routes](/docs/routing#server) as well as in the browser.
13+
SvelteKit uses [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) for getting data from the network. It's available in [hooks](hooks) and [server routes](routing#server) as well as in the browser.
1414

15-
> A special version of `fetch` is available in [`load`](/docs/load) functions, [server hooks](/docs/hooks#server-hooks) and [API routes](/docs/routing#server) for invoking endpoints directly during server-side rendering, without making an HTTP call, while preserving credentials. (To make credentialled fetches in server-side code outside `load`, you must explicitly pass `cookie` and/or `authorization` headers.) It also allows you to make relative requests, whereas server-side `fetch` normally requires a fully qualified URL.
15+
> A special version of `fetch` is available in [`load`](load) functions, [server hooks](hooks#server-hooks) and [API routes](routing#server) for invoking endpoints directly during server-side rendering, without making an HTTP call, while preserving credentials. (To make credentialled fetches in server-side code outside `load`, you must explicitly pass `cookie` and/or `authorization` headers.) It also allows you to make relative requests, whereas server-side `fetch` normally requires a fully qualified URL.
1616
1717
Besides `fetch` itself, the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) includes the following interfaces:
1818

1919
### Request
2020

21-
An instance of [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) is accessible in [hooks](/docs/hooks) and [server routes](/docs/routing#server) as `event.request`. It contains useful methods like `request.json()` and `request.formData()` for getting data that was posted to an endpoint.
21+
An instance of [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) is accessible in [hooks](hooks) and [server routes](routing#server) as `event.request`. It contains useful methods like `request.json()` and `request.formData()` for getting data that was posted to an endpoint.
2222

2323
### Response
2424

@@ -74,7 +74,7 @@ Most of the time, your endpoints will return complete data, as in the `userAgent
7474
7575
## URL APIs
7676
77-
URLs are represented by the [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) interface, which includes useful properties like `origin` and `pathname` (and, in the browser, `hash`). This interface shows up in various places — `event.url` in [hooks](/docs/hooks) and [server routes](/docs/routing#server), [`$page.url`](/docs/modules#$app-stores) in [pages](/docs/routing#page), `from` and `to` in [`beforeNavigate` and `afterNavigate`](/docs/modules#$app-navigation) and so on.
77+
URLs are represented by the [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) interface, which includes useful properties like `origin` and `pathname` (and, in the browser, `hash`). This interface shows up in various places — `event.url` in [hooks](hooks) and [server routes](routing#server), [`$page.url`](modules#$app-stores) in [pages](routing#page), `from` and `to` in [`beforeNavigate` and `afterNavigate`](modules#$app-navigation) and so on.
7878
7979
### URLSearchParams
8080
@@ -95,7 +95,7 @@ const foo = url.searchParams.get('foo');
9595
9696
## Web Crypto
9797
98-
The [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is made available via the `crypto` global. It's used internally for [Content Security Policy](/docs/configuration#csp) headers, but you can also use it for things like generating UUIDs:
98+
The [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is made available via the `crypto` global. It's used internally for [Content Security Policy](configuration#csp) headers, but you can also use it for things like generating UUIDs:
9999
100100
```js
101101
const uuid = crypto.randomUUID();

0 commit comments

Comments
 (0)