This is a monorepo, meaning the repo holds multiple packages. It requires the use of pnpm. You can install pnpm with:
npm i -g pnpmpnpm commands run in the project's root directory will run on all sub-projects. You can checkout the code and build all sub-projects with:
git clone git@github.com:sveltejs/kit.git
cd kit
pnpm install
pnpm buildYou can now run SvelteKit by linking it into your project with pnpm overrides as demonstrated in the sandbox example or by running one of the test projects as described in the testing section below.
Entry points to be aware of are:
packages/create-svelte- code that's run when you create a new project withnpm init svelte@nextpackages/kit/src/packaging- for thesvelte-kit packagecommandpackages/kit/src/core/dev/index.js- for the dev-mode serverpackages/kit/src/core/build/index.js- for the production serverpackages/adapter-[platform]- for the various SvelteKit-provided adapters
Most code called at build-time or from the CLI entry point lives in packages/kit/src/core. Code that runs for rendering and routing lives in packages/kit/src/runtime. Most changes to SvelteKit itself would involve code in these two directories.
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.
You can run the tests for only a single package by first moving to that directory. E.g. cd packages/kit.
You must rebuild each time before running the tests if you've made code changes.
To run a single integration test or otherwise control the running of the tests locally see the Playwright CLI docs. Note that you will need to run these commands from the test project directory such as packages/kit/test/apps/basics.
You can run the test server with cd packages/kit/test/apps/basics; pnpm run dev to hit it with your browser. The Playwright Inspector offers similar functionality.
You may need to install some dependencies first, e.g. with npx playwright install-deps (which only works on Ubuntu).
If you would like to test local changes to Vite or another dependency, you can build it and then use pnpm.overrides. Please note that pnpm.overrides must be specified in the root package.json and you must first list the package as a dependency in the root package.json:
All documentation for SvelteKit is in the documentation directory, and any improvements should be made as a Pull Request to this repository. The documentation is served via an API; the site itself is located in the sites repository.
If you wish to preview documentation changes locally, please follow the instructions here: Previewing local docs changes.
There are a few guidelines we follow:
- Internal variables are written with
snake_casewhile external APIs are written withcamelCase - Provide a single object as the argument to public APIs. This object can have multiple properties
- Avoid creating new test projects under
packages/kit/test/appsbut reuse an existing one when possible - Ensure
pnpm lintandpnpm checkpass. You can runpnpm formatto format the code
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:
git config core.hookspath .githooksFor changes to be reflected in package changelogs, run pnpx changeset and follow the prompts. All changesets should be patch until SvelteKit 1.0
The Changesets GitHub action will create and update a PR that applies changesets and publishes new versions of changed packages to npm.
It uses
pnpm publishrather thanpnpx changeset publishso that we can use the--filterand (while in beta)--tagflags — though perhaps they work withpnpx changeset publish?
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:
npm publish --access=public
{ // ... "dependencies": { "vite": "^2.0.0" }, "pnpm": { "overrides": { "vite": "link:../path/to/vite/packages/vite" } } }