Skip to content

Commit 4c4d4bd

Browse files
authored
docs: update CONTRIBUTING (#55)
1 parent 515bfd9 commit 4c4d4bd

File tree

2 files changed

+117
-5
lines changed

2 files changed

+117
-5
lines changed

CONTRIBUTING.md

Lines changed: 116 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,125 @@
11
# Rslib Contributing Guide
22

3-
## Setup the Environment
3+
Thanks for that you are interested in contributing to Rslib. Before starting your contribution, please take a moment to read the following guidelines.
44

5-
TODO
5+
## Install Node.js
66

7-
## Caveats
7+
Use [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm) to run the command below. This will switch to the Node.js version (currently 18) specified in the project's `.nvmrc` file.
8+
9+
```bash
10+
# with fnm
11+
fnm use
12+
13+
# with nvm
14+
nvm use
15+
```
16+
17+
## Install Dependencies
18+
19+
Enable [pnpm](https://pnpm.io/) with corepack:
20+
21+
```bash
22+
corepack enable
23+
```
24+
25+
Install dependencies:
26+
27+
```bash
28+
pnpm install
29+
```
30+
31+
What this will do:
32+
33+
- Install all dependencies.
34+
- Create symlinks between packages in the monorepo
35+
- Run the prepare script to build all packages, powered by [nx](https://nx.dev/).
36+
37+
## Making Changes and Building
38+
39+
Once you have set up the local development environment in your forked repo, we can start development.
40+
41+
### Checkout A New Branch
42+
43+
It is recommended to develop on a new branch, as it will make things easier later when you submit a pull request:
44+
45+
```sh
46+
git checkout -b MY_BRANCH_NAME
47+
```
48+
49+
### Build the Package
50+
51+
Use [nx build](https://nx.dev/nx-api/nx/documents/run) to build the package you want to change:
52+
53+
```sh
54+
npx nx build @rslib/core
55+
```
56+
57+
Build all packages:
58+
59+
```sh
60+
pnpm run build
61+
```
62+
63+
You can also use the watch mode to automatically rebuild the package when you make changes:
864

9-
The project is still under development, so it possible dependents on unstable Rsbuild / Rspack versions.
65+
```sh
66+
npx nx build @rslib/core --watch
67+
```
68+
69+
## Testing
70+
71+
### Add New Tests
72+
73+
If you've fixed a bug or added code that should be tested, then add some tests.
74+
75+
You can add unit test cases in the `<PACKAGE_DIR>/tests` folder. The test runner is based on [Vitest](https://vitest.dev/).
76+
77+
### Run Unit Tests
78+
79+
Before submitting a pull request, it's important to make sure that the changes haven't introduced any regressions or bugs. You can run the unit tests for the project by executing the following command:
80+
81+
```sh
82+
pnpm run test:unit
83+
```
84+
85+
You can also run the unit tests of single package:
86+
87+
```sh
88+
pnpm run test:unit packages/core
89+
```
90+
91+
### Run artifact tests
92+
93+
Rslib will also verify the correctness of generated artifacts. You can run the artifact tests by executing the following command:
94+
95+
```sh
96+
pnpm run test:artifact
97+
```
98+
99+
If you need to run a specified test, you can add keywords to filter:
100+
101+
```sh
102+
# Only run test cases which contains `dts` keyword in file path
103+
pnpm test:artifact dts
104+
# Only run test cases which contains `dts` keyword in test name
105+
pnpm test:artifact -t dts
106+
```
107+
108+
## Linting
109+
110+
To help maintain consistency and readability of the codebase, we use [Biome](https://github.com/biomejs/biome) to lint the codes.
111+
112+
You can run the linters by executing the following command:
113+
114+
```sh
115+
pnpm run lint
116+
```
117+
118+
For VS Code users, you can install the [Biome VS Code extension](https://marketplace.visualstudio.com/items?itemName=biomejs.biome) to see lints while typing.
119+
120+
## Caveats
10121

11-
Current unstable versions are:
122+
The project is still in its early stages and under active development, so it possible dependents on Rsbuild or Rspack canary versions to test the latest features. The current canary versions are:
12123

13124
| Package | Link |
14125
| ------------ | ------------------------------------------------------- |

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"test:artifact:watch": "vitest --project artifact",
1515
"test:e2e": "cd e2e && pnpm run test",
1616
"test:unit": "vitest run --project unit",
17+
"test:unit:watch": "vitest --project unit",
1718
"watch": "pnpm build --watch"
1819
},
1920
"simple-git-hooks": {

0 commit comments

Comments
 (0)