Skip to content

Commit e9ecea5

Browse files
committed
merge main
2 parents d6cc6ec + 233ea22 commit e9ecea5

File tree

335 files changed

+14457
-4389
lines changed

Some content is hidden

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

335 files changed

+14457
-4389
lines changed

.github/copilot-instructions.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# SvelteKit Development Instructions
2+
3+
SvelteKit is a web application framework for building modern web applications with Svelte. This is a monorepo containing @sveltejs/kit, adapters, and related packages.
4+
5+
**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
6+
7+
## Working Effectively
8+
9+
### Prerequisites and Setup
10+
- Install Node.js 18+ (current tested versions: 18, 20, 22, 24)
11+
- Install pnpm globally: `npm install -g pnpm` (takes ~2 seconds)
12+
- Clone the repository: `git clone [email protected]:sveltejs/kit.git`
13+
- Navigate to the repository: `cd kit`
14+
15+
### Bootstrap and Build Commands
16+
- **CRITICAL**: Install dependencies: `pnpm install --frozen-lockfile`
17+
- **NEVER CANCEL**: Takes 3-4 minutes. Set timeout to 10+ minutes.
18+
- Sync generated files: `pnpm run sync-all` (takes <1 second)
19+
- Build all packages: `pnpm build` (takes ~1-2 seconds)
20+
21+
### Development Commands
22+
- **Format code**: `pnpm run format` (takes ~15 seconds)
23+
- **Lint code**: `pnpm run lint`
24+
- **NEVER CANCEL**: Takes 2-3 minutes. Set timeout to 5+ minutes.
25+
- **Type checking**: `pnpm run check`
26+
- **NEVER CANCEL**: Takes 3-4 minutes. Set timeout to 8+ minutes.
27+
- **Run unit tests**: `cd packages/kit && pnpm test:unit` (takes ~6 seconds)
28+
29+
### Testing Commands
30+
- **Unit tests only**: `cd packages/kit && pnpm test:unit` (takes ~6 seconds)
31+
- **Integration tests**: `pnpm test:kit`
32+
- **NEVER CANCEL**: Takes 10-30 minutes. Set timeout to 60+ minutes.
33+
- **Requires browser setup**: `pnpm playwright install chromium` first
34+
- **Other package tests**: `pnpm test:others`
35+
- **NEVER CANCEL**: Takes 5-15 minutes. Set timeout to 30+ minutes.
36+
- **Requires browser setup**: `pnpm playwright install chromium` first
37+
38+
### Development Server (Playground)
39+
- Navigate to playground: `cd playgrounds/basic`
40+
- Start dev server: `pnpm run dev`
41+
- Server starts at: `http://localhost:5173/`
42+
- Dev server starts in ~1-2 seconds
43+
44+
## Validation Requirements
45+
46+
### ALWAYS run these before submitting changes:
47+
1. `pnpm run format` - Auto-format all code
48+
2. `pnpm run lint` - Check code style (NEVER CANCEL - takes 2-3 minutes)
49+
3. `pnpm run check` - Type checking (NEVER CANCEL - takes 3-4 minutes)
50+
4. `cd packages/kit && pnpm test:unit` - Run unit tests
51+
5. **For changes to @sveltejs/kit**: `cd packages/kit && pnpm prepublishOnly` - Generate types
52+
53+
### Manual Testing Scenarios
54+
**ALWAYS test these scenarios after making changes:**
55+
56+
1. **Create a new SvelteKit app**:
57+
```bash
58+
cd /tmp
59+
npx sv create test-app --template minimal --no-install --no-types
60+
# Press Enter to skip additional packages
61+
cd test-app
62+
63+
# Use pnpm if available, otherwise fall back to npm
64+
if command -v pnpm &> /dev/null; then
65+
pnpm install
66+
# Link local @sveltejs/kit development version by adding pnpm overrides
67+
# Replace PATH_TO_KIT_REPO with the actual path to your kit repository
68+
npm pkg set 'pnpm.overrides.@sveltejs/kit'='link:PATH_TO_KIT_REPO/packages/kit'
69+
pnpm install --no-frozen-lockfile
70+
pnpm run dev
71+
else
72+
npm install
73+
# For npm, manually link the local package
74+
# Replace PATH_TO_KIT_REPO with the actual path to your kit repository
75+
npm link PATH_TO_KIT_REPO/packages/kit
76+
npm run dev
77+
fi
78+
```
79+
- Verify the app starts and loads at http://localhost:5173/
80+
- Verify it's using the local @sveltejs/kit version (check that `node_modules/@sveltejs/kit` is a symlink)
81+
82+
2. **Test the CLI**:
83+
```bash
84+
cd packages/kit
85+
node svelte-kit.js --help
86+
node svelte-kit.js sync --help
87+
```
88+
89+
3. **Test playground functionality**:
90+
```bash
91+
cd playgrounds/basic
92+
pnpm run dev
93+
```
94+
- Navigate to http://localhost:5173/
95+
- Test basic navigation and functionality
96+
97+
## Repository Structure
98+
99+
### Key Packages (`packages/` directory):
100+
- **@sveltejs/kit** - Main SvelteKit package (`packages/kit/`)
101+
- **Adapters**: adapter-auto, adapter-cloudflare, adapter-netlify, adapter-node, adapter-static, adapter-vercel
102+
- **@sveltejs/enhanced-img** - Enhanced image component
103+
- **@sveltejs/package** - Package building utilities
104+
- **@sveltejs/amp** - AMP support
105+
106+
### Key Directories:
107+
- `packages/kit/src/core/` - Build-time code
108+
- `packages/kit/src/runtime/` - Runtime code
109+
- `packages/kit/src/exports/vite/` - Vite plugin
110+
- `packages/kit/test/` - Integration tests
111+
- `playgrounds/basic/` - Development playground
112+
- `.github/workflows/` - CI/CD configuration
113+
114+
### Important Files:
115+
- `pnpm-workspace.yaml` - Workspace configuration
116+
- `package.json` - Root package with scripts
117+
- `packages/kit/svelte-kit.js` - CLI entry point
118+
- `packages/kit/package.json` - Main package configuration
119+
120+
## Common Tasks
121+
122+
### Working with Types
123+
- Generate types: `cd packages/kit && pnpm generate:types`
124+
- Check types: `cd packages/kit && pnpm prepublishOnly`
125+
- **CRITICAL**: Always commit generated type changes
126+
127+
### Testing Specific Changes
128+
- Link local changes to external project using `pnpm.overrides` in external project's package.json:
129+
```json
130+
{
131+
"pnpm": {
132+
"overrides": {
133+
"@sveltejs/kit": "link:../path/to/kit/packages/kit"
134+
}
135+
}
136+
}
137+
```
138+
139+
### Working with Adapters
140+
- Each adapter has its own test suite
141+
- Build adapter: `cd packages/adapter-[name] && pnpm build`
142+
- Test adapter: `cd packages/adapter-[name] && pnpm test`
143+
144+
## Timing Expectations
145+
146+
**Set these timeout values for long-running commands:**
147+
148+
| Command | Expected Time | Recommended Timeout |
149+
|---------|---------------|-------------------|
150+
| `pnpm install --frozen-lockfile` | 3-4 minutes | 10+ minutes |
151+
| `pnpm run lint` | 1-2 minutes | 5+ minutes |
152+
| `pnpm run check` | 3-4 minutes | 8+ minutes |
153+
| `pnpm test:kit` | 10-15 minutes | 30+ minutes |
154+
| `pnpm test:others` | 2-3 minutes | 10+ minutes |
155+
| `pnpm run format` | ~15 seconds | 2+ minutes |
156+
| `pnpm build` | 1-2 seconds | 2+ minutes |
157+
| Dev server startup | 1-2 seconds | 1+ minute |
158+
| Unit tests | ~6 seconds | 2+ minutes |
159+
160+
## Troubleshooting
161+
162+
### Browser Tests Fail
163+
- Install Playwright browsers: `pnpm playwright install chromium`
164+
- For full browser support: `pnpm playwright install`
165+
166+
### Build Failures
167+
- Ensure all dependencies installed: `pnpm install --frozen-lockfile`
168+
- Regenerate types: `cd packages/kit && pnpm prepublishOnly`
169+
- Check for TypeScript errors: `pnpm run check`
170+
171+
### Lint/Format Issues
172+
- Auto-fix formatting: `pnpm run format`
173+
- Check specific package: `cd packages/[name] && pnpm lint`
174+
175+
### Development Server Issues
176+
- Ensure sync is complete: `pnpm run sync-all`
177+
- Check for port conflicts (default: 5173)
178+
- Restart with clean cache: Clear node_modules and reinstall
179+
180+
## Git Hooks
181+
Configure git hooks for automatic validation:
182+
```bash
183+
git config core.hookspath .githooks
184+
```
185+
186+
## Output Examples
187+
188+
### Successful pnpm install completion:
189+
```
190+
Done in 2m 48.5s using pnpm v10.14.0
191+
```
192+
193+
### Successful dev server startup:
194+
```
195+
VITE v6.3.5 ready in 1145 ms
196+
➜ Local: http://localhost:5173/
197+
```
198+
199+
### CLI help output:
200+
```
201+
Usage
202+
$ svelte-kit <command> [options]
203+
204+
Available Commands
205+
sync Synchronise generated type definitions
206+
```

.github/workflows/audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
if: github.repository == 'sveltejs/kit'
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v5
2121
- uses: pnpm/[email protected]
2222
- uses: actions/setup-node@v4
2323
with:

.github/workflows/ci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
pkg-pr-new:
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v5
2626
- uses: pnpm/[email protected]
2727
- uses: actions/setup-node@v4
2828
with:
@@ -34,7 +34,7 @@ jobs:
3434
lint-all:
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@v4
37+
- uses: actions/checkout@v5
3838
- uses: pnpm/[email protected]
3939
- uses: actions/setup-node@v4
4040
with:
@@ -64,7 +64,7 @@ jobs:
6464
KIT_E2E_BROWSER: ${{matrix.e2e-browser}}
6565
steps:
6666
- run: git config --global core.autocrlf false
67-
- uses: actions/checkout@v4
67+
- uses: actions/checkout@v5
6868
- uses: pnpm/[email protected]
6969
- uses: actions/setup-node@v4
7070
with:
@@ -74,6 +74,8 @@ jobs:
7474
- run: pnpm playwright install ${{ matrix.e2e-browser }}
7575
- run: pnpm run sync-all
7676
- run: pnpm test:kit
77+
env:
78+
NODE_OPTIONS: ${{matrix.node-version == 22 && '--experimental-strip-types' || ''}} # allows loading svelte.config.ts
7779
- name: Print flaky test report
7880
run: node scripts/print-flaky-test-report.js
7981
- name: Archive test results
@@ -122,7 +124,7 @@ jobs:
122124
KIT_E2E_BROWSER: ${{matrix.e2e-browser}}
123125
steps:
124126
- run: git config --global core.autocrlf false
125-
- uses: actions/checkout@v4
127+
- uses: actions/checkout@v5
126128
- uses: pnpm/[email protected]
127129
- uses: actions/setup-node@v4
128130
with:
@@ -156,7 +158,7 @@ jobs:
156158
- mode: 'build'
157159
steps:
158160
- run: git config --global core.autocrlf false
159-
- uses: actions/checkout@v4
161+
- uses: actions/checkout@v5
160162
- uses: pnpm/[email protected]
161163
- uses: actions/setup-node@v4
162164
with:
@@ -181,14 +183,19 @@ jobs:
181183
path: test-results-server-side-route-resolution-${{ matrix.mode }}.tar.gz
182184
test-others:
183185
runs-on: ubuntu-latest
186+
strategy:
187+
matrix:
188+
node-version: [18, 20, 22, 24]
184189
steps:
185-
- uses: actions/checkout@v4
190+
- uses: actions/checkout@v5
186191
- uses: pnpm/[email protected]
187192
- uses: actions/setup-node@v4
188193
with:
189-
node-version: 18
194+
node-version: ${{matrix.node-version}}
190195
cache: pnpm
191196
- run: pnpm install --frozen-lockfile
192197
- run: pnpm playwright install chromium
193198
- run: cd packages/kit && pnpm prepublishOnly
194199
- run: pnpm run test:others
200+
env:
201+
NODE_OPTIONS: ${{matrix.node-version == 22 && '--experimental-strip-types' || ''}} # allows loading svelte.config.ts

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout Repo
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222
with:
2323
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
2424
fetch-depth: 0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ vite.config.js.timestamp-*
1919
.test-tmp
2020
symlink-from
2121
.idea/
22+
_tmp_flaky_test_output.txt

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
link-workspace-packages = true
2+
shell-emulator = true

.prettierrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
"**/.custom-out-dir/**",
2727
"**/build/**",
2828
"**/test-results/**",
29+
"**/.wrangler/**",
2930
"documentation/**/*.md",
3031
"packages/package/test/fixtures/**/expected/**/*",
3132
"packages/package/test/watch/expected/**/*",
3233
"packages/package/test/watch/package/**/*",
33-
"packages/kit/src/core/postbuild/fixtures/**/*"
34+
"packages/kit/src/core/postbuild/fixtures/**/*",
35+
"packages/adapter-cloudflare/test/apps/workers/dist/**/*"
3436
],
3537
"options": {
3638
"rangeEnd": 0

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
This is a monorepo, meaning the repo holds multiple packages. It requires the use of [pnpm](https://pnpm.io/). You can [install pnpm](https://pnpm.io/installation) with:
66

7-
```bash
7+
```sh
88
npm i -g pnpm
99
```
1010

1111
`pnpm` commands run in the project's root directory will run on all sub-projects. You can checkout the code and install the dependencies with:
1212

13-
```bash
13+
```sh
1414
git clone [email protected]:sveltejs/kit.git
1515
cd kit
1616
pnpm install
@@ -69,7 +69,7 @@ Issues with the [**soon**](https://github.com/sveltejs/kit/issues?q=is%3Aissue+i
6969

7070
## Testing
7171

72-
Run `pnpm test` to run the tests from all subpackages. Browser tests live in subdirectories of `packages/kit/test` such as `packages/kit/test/apps/basics`.
72+
Run `pnpm test:kit` to run the tests from the `packages/kit` directory. You can also run `pnpm test:others` to run tests from all packages __except__ the `packages/kit` directory. Browser tests live in subdirectories of `packages/kit/test` such as `packages/kit/test/apps/basics`.
7373

7474
You can run the tests for only a single package by first moving to that directory. E.g. `cd packages/kit`.
7575

@@ -124,7 +124,7 @@ There are a few guidelines we follow:
124124

125125
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:
126126

127-
```bash
127+
```sh
128128
git config core.hookspath .githooks
129129
```
130130

@@ -142,6 +142,6 @@ The [Changesets GitHub action](https://github.com/changesets/action#with-publish
142142

143143
New packages will need to be published manually the first time if they are scoped to the `@sveltejs` organisation, by running this from the package directory:
144144

145-
```bash
145+
```sh
146146
npm publish --access=public
147147
```

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ title: Creating a project
44

55
The easiest way to start building a SvelteKit app is to run `npx sv create`:
66

7-
```bash
7+
```sh
88
npx sv create my-app
99
cd my-app
10-
npm install
1110
npm run dev
1211
```
1312

14-
The first command will scaffold a new project in the `my-app` directory asking you if you'd like to set up some basic tooling such as TypeScript. See [integrations](./integrations) for pointers on setting up additional tooling. The subsequent commands will then install its dependencies and start a server on [localhost:5173](http://localhost:5173).
13+
The first command will scaffold a new project in the `my-app` directory asking if you'd like to set up some basic tooling such as TypeScript. See [the CLI docs](/docs/cli/overview) for information about these options and [the integrations page](./integrations) for pointers on setting up additional tooling. `npm run dev` will then start the development server on [localhost:5173](http://localhost:5173) - make sure you install dependencies before running this if you didn't do so during project creation.
1514

1615
There are two basic concepts:
1716

0 commit comments

Comments
 (0)