You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: .github/contributing.md
+41-5
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,9 @@
1
1
# Vite Contributing Guide
2
2
3
-
Hi! I'm really excited that you are interested in contributing to Vite.js. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:
Hi! We are really excited that you are interested in contributing to Vite. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:
7
4
## Pull Request Guidelines
8
5
9
-
- Checkout a topic branch from a base branch, e.g. `master`, and merge back against that branch.
6
+
- Checkout a topic branch from a base branch, e.g. `main`, and merge back against that branch.
10
7
11
8
- If adding a new feature:
12
9
@@ -26,3 +23,42 @@ Hi! I'm really excited that you are interested in contributing to Vite.js. Befor
26
23
- Commit messages must follow the [commit message convention](./commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [yorkie](https://github.com/yyx990803/yorkie)).
27
24
28
25
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [yorkie](https://github.com/yyx990803/yorkie)).
26
+
27
+
## Maintenance Guidelines
28
+
29
+
> The following section is mostly for maintainers who have commit access, but it's helpful to go through if you intend to make non-trivial contributions to the codebase.
30
+
31
+
Vite aims to be lightweight, and this includes being aware of the number of npm dependencies and their size.
32
+
33
+
We use rollup to pre-bundle most dependencies before publishing! Therefore most dependencies, even used in src code, should be added under `devDependencies` by default. This also creates a number of constraints that we need to be aware of in the codebase:
34
+
35
+
### Usage of `require()`
36
+
37
+
In some cases we intentionally lazy-require some dependencies to improve startup performance. However, note that we cannot use simple `require('somedep')` calls since these are ignored in ESM files so the dependency won't be included in the bundle, and the actual dependency won't even be there when published since they are in `devDependencies`.
38
+
39
+
Instead, use `(await import('somedep')).default`.
40
+
41
+
### Think before adding a dependency
42
+
43
+
Most deps should be added to `devDependencies` even if they are needed at runtime. Some exceptions are:
44
+
45
+
- Type packages. Example: `@types/*`.
46
+
- Deps that cannot be properly bundled due to binary files. Example: `esbuild`.
47
+
- Deps that ships its own types and its type is used in vite's own public types. Example: `rollup`.
48
+
49
+
Avoid deps that has large transitive dependencies that results in bloated size compared to the functionality it provides. For example, `http-proxy` itself plus `@types/http-proxy` is a little over 1MB in size, but `http-proxy-middleware` pulls in a ton of dependencies that makes it 7MB(!) when a minimal custom middleware on top of `http-proxy` only requires a couple lines of code.
50
+
51
+
### Ensure type support
52
+
53
+
Vite aims to be fully usable as a dependency in a TypeScript project (e.g. it should provide proper typings for VitePress), and also in `vite.config.ts`. This means technically a dependency whose types are exposed needs to be part of `dependencies` instead of `devDependencies`. However, these means we won't be able to bundle it.
54
+
55
+
To get around this, we inline some of these dependencies' types in `packages/vite/types`. This way we can still expose the typing but bundle the dependency's source code.
56
+
57
+
### Think before adding yet another option
58
+
59
+
We already have many config options, and we should avoid fixing an issue by adding yet another one. Before adding an option, try to think about:
60
+
61
+
- Whether the problem is really worth addressing
62
+
- Whether the problem can be fixed with a smarter default
63
+
- Whether the problem has workaround using existing options
64
+
- Whether the problem can be addressed with a plugin instead
0 commit comments