Skip to content

Commit 03d27db

Browse files
authored
[docs] separate out contributing guide (sveltejs#3055)
1 parent 77c57b5 commit 03d27db

File tree

2 files changed

+134
-103
lines changed

2 files changed

+134
-103
lines changed

CONTRIBUTING.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# SvelteKit Contributing Guide
2+
3+
## Building and Running
4+
5+
This is a monorepo, meaning the repo holds multiple packages. It requires the use of [pnpm](https://pnpm.js.org/en/). You can [install pnpm](https://pnpm.io/installation) with:
6+
7+
```bash
8+
npm i -g pnpm
9+
```
10+
11+
`pnpm` 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:
12+
13+
```bash
14+
git clone [email protected]:sveltejs/kit.git
15+
cd kit
16+
pnpm install
17+
pnpm build
18+
```
19+
20+
You should now be able to run [the example](examples/hn.svelte.dev) with:
21+
22+
```bash
23+
cd examples/hn.svelte.dev
24+
pnpm dev
25+
```
26+
27+
Run `pnpm dev` inside the `packages/kit` directory to continually rebuild `@sveltejs/kit` as you make changes to SvelteKit. Restarting the example/test apps will cause the newly built version to be used.
28+
29+
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:
30+
31+
```bash
32+
git config core.hookspath .githooks
33+
```
34+
35+
## Code structure
36+
37+
Entry points to be aware of are:
38+
- [`packages/create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) - code that's run when you create a new project with `npm init svelte@next`
39+
- [`packages/kit/src/packaging`](https://github.com/sveltejs/kit/tree/master/packages/kit/src/packaging) - for the `svelte-kit package` command
40+
- [`packages/kit/src/core/dev/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/core/dev/index.js) - for the dev-mode server
41+
- [`packages/kit/src/core/build/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/core/build/index.js) - for the production server
42+
- [`packages/adapter-[platform]`](https://github.com/sveltejs/kit/tree/master/packages) - for the various SvelteKit-provided adapters
43+
44+
Most code called at build-time or from the CLI entry point lives in [packages/kit/src/core](https://github.com/sveltejs/kit/tree/master/packages/kit/src/core). Code that runs for rendering and routing lives in [packages/kit/src/runtime](https://github.com/sveltejs/kit/tree/master/packages/kit/src/runtime). Most changes to SvelteKit itself would involve code in these two directories.
45+
46+
## Testing
47+
48+
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`.
49+
50+
You can run the tests for only a single package by first moving to that directory. E.g. `cd packages/kit`.
51+
52+
You must rebuild each time before running the tests if you've made code changes.
53+
54+
To run a single integration test, provide the `FILTER` env var with the test name. E.g. `FILTER="includes paths" pnpm test:integration`. You can also open up the file and change `test` to `test.only`.
55+
56+
You can run the test server with `cd packages/kit/test/apps/basics; pnpm run dev` to hit it with your browser.
57+
58+
You may need to install some dependencies first, e.g. with `npx playwright install-deps` (which only works on Ubuntu).
59+
60+
## Working on Vite and other dependencies
61+
62+
If you would like to test local changes to Vite or another dependency, you can build it and then use [`pnpm.overrides`](https://pnpm.io/package_json#pnpmoverrides). 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`:
63+
64+
```jsonc
65+
{
66+
// ...
67+
"dependencies": {
68+
"vite": "^2.0.0"
69+
},
70+
"pnpm": {
71+
"overrides": {
72+
"vite": "link:../path/to/vite/packages/vite"
73+
}
74+
}
75+
}
76+
```
77+
78+
## Documentation changes
79+
80+
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](https://github.com/sveltejs/api.svelte.dev); the site itself is located in the [`sites` repository](https://github.com/sveltejs/sites).
81+
82+
If you wish to preview documentation changes locally, please follow the instructions here: [Previewing local docs changes](https://github.com/sveltejs/sites/blob/master/sites/kit.svelte.dev/README.md#previewing-local-docs-changes).
83+
84+
## Sending PRs
85+
86+
### Coding style
87+
88+
There are a few guidelines we follow:
89+
- Internal variables are written with `snake_case` while external APIs are written with `camelCase`
90+
- Provide a single object as the argument to public APIs. This object can have multiple properties
91+
- Avoid creating new test projects under `packages/kit/test/apps` but reuse an existing one when possible
92+
- Ensure `pnpm lint` and `pnpm check` pass. You can run `pnpm format` to format the code
93+
94+
### Generating changelogs
95+
96+
For changes to be reflected in package changelogs, run `pnpx changeset` and follow the prompts. All changesets should be `patch` until SvelteKit 1.0
97+
98+
## Releases
99+
100+
The [Changesets GitHub action](https://github.com/changesets/action#with-publishing) will create and update a PR that applies changesets and publishes new versions of changed packages to npm.
101+
102+
> It uses `pnpm publish` rather than `pnpx changeset publish` so that we can use the `--filter` and (while in beta) `--tag` flags — though perhaps they work with `pnpx changeset publish`?
103+
104+
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:
105+
106+
```bash
107+
npm publish --access=public
108+
```

README.md

+26-103
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
[![Chat](https://img.shields.io/discord/457912077277855764?label=chat&logo=discord)](https://svelte.dev/chat)
2+
13
# READ THIS FIRST!
24

35
SvelteKit is still in beta. Expect bugs! Read more [here](https://svelte.dev/blog/sveltekit-beta), and track progress towards 1.0 [here](https://github.com/sveltejs/kit/issues?q=is%3Aopen+is%3Aissue+milestone%3A1.0).
46

7+
## Overview
8+
9+
The Fastest Way to Build Svelte Apps
10+
11+
- 💨 Blazing-Fast Production Sites
12+
- 🛠️ SSR, SPA, SSG, and In-Between
13+
- ⚡️ Instantly Visible Code Changes
14+
- 🔩 Existing Universe of Plugins
15+
- 🔑 Fully Typed APIs
16+
517
## Documentation
618

719
Please see [the documentation](https://kit.svelte.dev/docs) for information about getting started and developing with SvelteKit.
@@ -21,120 +33,31 @@ Please see [the documentation](https://kit.svelte.dev/docs) for information abou
2133

2234
The SvelteKit community also makes additional [SvelteKit adapters available for use](https://sveltesociety.dev/components#adapters).
2335

36+
### Migrating from Sapper
37+
38+
Check out the [Migration Guide](https://kit.svelte.dev/migrating) if you are upgrading from Sapper.
39+
2440
## Bug reporting
2541

26-
Please make sure the issue you're reporting involves SvelteKit. Many issues related to how a project builds originate from [Vite](https://vitejs.dev/), which SvelteKit uses to build a project. It's important to note that new Vite projects don't use SSR by default, and so if you create a new Vite project from scratch, many issues won't reproduce even though Vite causes them. You should thus start with a project that utilizes SSR, such as:
42+
Please make sure the issue you're reporting involves SvelteKit. Many issues related to how a project builds originate from [Vite](https://vitejs.dev/), which is used to build a SvelteKit project. It's important to note that new Vite projects don't use SSR by default, and so if you create a new Vite project from scratch, many issues won't reproduce. You should thus start with a project that utilizes SSR, such as:
2743

2844
- https://github.com/GrygrFlzr/vite-ssr-d3
2945
- https://github.com/sveltejs/vite-plugin-svelte/tree/main/packages/e2e-tests/vite-ssr
3046

31-
If Vite causes an issue, please report in the [Vite issue tracker](https://github.com/vitejs/vite/issues).
32-
33-
## Developing
34-
35-
### Building and Running
36-
37-
This is a monorepo, meaning the repo holds multiple packages. It requires the use of [pnpm](https://pnpm.js.org/en/). You can [install pnpm](https://pnpm.io/installation) with:
38-
39-
```bash
40-
npm i -g pnpm
41-
```
42-
43-
`pnpm` 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:
44-
45-
```bash
46-
git clone [email protected]:sveltejs/kit.git
47-
cd kit
48-
pnpm install
49-
pnpm build
50-
```
51-
52-
You should now be able to run [the example](examples/hn.svelte.dev) with:
53-
54-
```bash
55-
cd examples/hn.svelte.dev
56-
pnpm dev
57-
```
58-
59-
Run `pnpm dev` inside the `packages/kit` directory to continually rebuild `@sveltejs/kit` as you make changes to SvelteKit. Restarting the example/test apps will cause the newly built version to be used.
60-
61-
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:
62-
63-
```bash
64-
git config core.hookspath .githooks
65-
```
66-
67-
### Code structure
68-
69-
Entry points to be aware of are:
70-
- [`packages/create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) - code that's run when you create a new project with `npm init svelte@next`
71-
- [`packages/kit/src/packaging`](https://github.com/sveltejs/kit/tree/master/packages/kit/src/packaging) - for the `svelte-kit package` command
72-
- [`packages/kit/src/core/dev/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/core/dev/index.js) - for the dev-mode server
73-
- [`packages/kit/src/core/build/index.js`](https://github.com/sveltejs/kit/blob/master/packages/kit/src/core/build/index.js) - for the production server
74-
- [`packages/adapter-[platform]`](https://github.com/sveltejs/kit/tree/master/packages) - for the various SvelteKit-provided adapters
75-
76-
Most code called at build-time or from the CLI entry point lives in [packages/kit/src/core](https://github.com/sveltejs/kit/tree/master/packages/kit/src/core). Code that runs for rendering and routing lives in [packages/kit/src/runtime](https://github.com/sveltejs/kit/tree/master/packages/kit/src/runtime). Most changes to SvelteKit itself would involve code in these two directories.
77-
78-
### Testing
79-
80-
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`.
81-
82-
You can run the tests for only a single package by first moving to that directory. E.g. `cd packages/kit`.
83-
84-
You must rebuild each time before running the tests if you've made code changes.
85-
86-
To run a single integration test, provide the `FILTER` env var with the test name. E.g. `FILTER="includes paths" pnpm test:integration`. You can also open up the file and change `test` to `test.only`.
87-
88-
You can run the test server with `cd packages/kit/test/apps/basics; pnpm run dev` to hit it with your browser.
89-
90-
You may need to install some dependencies first, e.g. with `npx playwright install-deps` (which only works on Ubuntu).
91-
92-
### Working on Vite and other dependencies
93-
94-
If you would like to test local changes to Vite or another dependency, you can build it and then use [`pnpm.overrides`](https://pnpm.io/package_json#pnpmoverrides). 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`:
95-
96-
```jsonc
97-
{
98-
// ...
99-
"dependencies": {
100-
"vite": "^2.0.0"
101-
},
102-
"pnpm": {
103-
"overrides": {
104-
"vite": "link:../path/to/vite/packages/vite"
105-
}
106-
}
107-
}
108-
```
109-
110-
### Documentation changes
111-
112-
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](https://github.com/sveltejs/api.svelte.dev); the site itself is located in the [`sites` repository](https://github.com/sveltejs/sites).
113-
114-
If you wish to preview documentation changes locally, please follow the instructions here: [Previewing local docs changes](https://github.com/sveltejs/sites/blob/master/sites/kit.svelte.dev/README.md#previewing-local-docs-changes).
115-
116-
### Sending PRs
117-
118-
#### Coding style
47+
If an issue originates from Vite, please report in the [Vite issue tracker](https://github.com/vitejs/vite/issues).
11948

120-
There are a few guidelines we follow:
121-
- Internal variables are written with `snake_case` while external APIs are written with `camelCase`
122-
- Provide a single object as the argument to public APIs. This object can have multiple properties
123-
- Avoid creating new test projects under `packages/kit/test/apps` but reuse an existing one when possible
124-
- Ensure `pnpm lint` and `pnpm check` pass. You can run `pnpm format` to format the code
49+
## Changing SvelteKit locally
12550

126-
#### Generating changelogs
51+
See the [Contributing Guide](./CONTRIBUTING.md).
12752

128-
For changes to be reflected in package changelogs, run `pnpx changeset` and follow the prompts. All changesets should be `patch` until SvelteKit 1.0
53+
## Supporting Svelte
12954

130-
## Releases
55+
Svelte is an MIT-licensed open source project with its ongoing development made possible entirely by fantastic volunteers. If you'd like to support their efforts, please consider:
13156

132-
The [Changesets GitHub action](https://github.com/changesets/action#with-publishing) will create and update a PR that applies changesets and publishes new versions of changed packages to npm.
57+
- [Becoming a backer on Open Collective](https://opencollective.com/svelte).
13358

134-
> It uses `pnpm publish` rather than `pnpx changeset publish` so that we can use the `--filter` and (while in beta) `--tag` flags — though perhaps they work with `pnpx changeset publish`?
59+
Funds donated via Open Collective will be used for compensating expenses related to Svelte's development such as hosting costs. If sufficient donations are received, funds may also be used to support Svelte's development more directly.
13560

136-
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:
61+
## License
13762

138-
```bash
139-
npm publish --access=public
140-
```
63+
[MIT](https://github.com/sveltejs/kit/blob/master/LICENSE)

0 commit comments

Comments
 (0)