Skip to content

Commit 7dd0759

Browse files
docs: Update CONTRIBUTING.md with Rust setup and turbo build info. (#741)
<!-- Thank you for submitting a pull request! We appreciate the time and effort you have invested in making these changes. Please ensure that you provide enough information to allow others to review your pull request. Upon submission, your pull request will be automatically assigned with reviewers. If you want to learn more about contributing to this project, please visit: https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md. --> ## Summary <!-- Can you explain the reasoning behind implementing this change? What problem or issue does this pull request resolve? --> This pull request updates `CONTRIBUTING.md` to address setup and build issues encountered by new contributors, resolving the problems documented in issue #710. **Problem:** Following the previous instructions in `CONTRIBUTING.md` (`pnpm install` -> `pnpm build` -> `pnpm test`) leads to test failures, specifically the `Could not resolve "./dist/vitest.config"` error. **Reasoning & Root Causes:** 1. **Missing Prerequisite:** The project requires a specific Rust toolchain version, **`1.81.0`**, as defined in the `rust-toolchain` file at the root, along with the `wasm32-unknown-unknown` target for compiling native code (WASM/NAPI). This requirement was not documented, causing build failures during the Rust compilation steps for users who only had a different version (like the latest stable `1.86.0`) installed. 2. **Incomplete Build Command:** The documented `pnpm build` command (which is an alias for `tsc --build`) only performs TypeScript compilation. It does *not* handle the necessary Rust compilation steps or other package-specific build scripts (like `rslib build` used by `@lynx-js/reactlynx-testing-library`) required to generate all artifacts needed for testing, including the missing `dist/vitest.config.js`. 3. **Correct Build Process:** The full project build needs to be orchestrated by Turborepo using the command `pnpm exec turbo run build`. This ensures all dependencies (including Rust components) are built in the correct order before dependent packages attempt to use them. **Solution Implemented in this PR:** * The `CONTRIBUTING.md` file has been updated to: * Clearly list Rust `1.81.0` and the `wasm32-unknown-unknown` target as prerequisites, including the `rustup` command needed to install them. * Revise the "Building" section to emphasize that `pnpm exec turbo run build` is the required command for a complete build that must be run before `pnpm test`. * Clarify the limited scope of the root `pnpm build` (`tsc --build`) command. These documentation changes will help future contributors set up their environment correctly and avoid the build/test failures initially reported. <!-- It would be helpful if you could provide any relevant context, such as GitHub issues or related discussions. --> close: #710 ## Checklist <!--- Check and mark with an "x" --> - [ ] Tests updated (or not required). **NOT REQUIRED** - [x] Documentation updated (or not required). **CONTRIBUTING.md UPDATED** cspell.jsonc: "rustup" added to **words** --------- Signed-off-by: Chthonic <devchthonic@protonmail.com> Signed-off-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com> Co-authored-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
1 parent 121ccd8 commit 7dd0759

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

CONTRIBUTING.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ _Node_: Check that Node is [installed](https://nodejs.org/en/download/) with ver
88

99
_pnpm_: Make sure that pnpm is available. You can use `corepack enable` to automatically setup pnpm.
1010

11+
_Rust_: ReactLynx utilizes SWC plugins, necessitating the Rust toolchain for building.
12+
13+
- Ensure you have [`rustup`](https://rustup.rs/) installed.
14+
- Install the required WASM target by running the following command (you only need to do this once):
15+
```sh
16+
rustup target add wasm32-unknown-unknown
17+
```
18+
- `rustup` will automatically use the correct toolchain when you run build commands inside this project, thanks to the `rust-toolchain` file.
19+
1120
### Setup
1221

1322
To setup the project, run:
@@ -18,31 +27,17 @@ pnpm install
1827

1928
### Building
2029

21-
To build the projects, run:
22-
23-
```sh
24-
pnpm build # An alias for `tsc --build`
25-
```
26-
27-
The project is managed using TypeScript's [Project Reference](https://www.typescriptlang.org/docs/handbook/project-references.html#handbook-content).
28-
29-
So running `tsc --build` at the repository root can build all projects.
30-
31-
Also, the repository can also be built with [`turborepo`]. Running:
32-
33-
```sh
34-
pnpm turbo build
35-
```
36-
37-
will built all the projects and it's dependencies recursively with cache enabled.
30+
**Full Build (Required for Tests)**
3831

39-
#### Build with Watching
32+
```sh
33+
pnpm turbo build
34+
```
4035

41-
To build the projects and incrementally build files on change, run:
36+
**Build with Watching (TypeScript Only)**
4237

43-
```sh
44-
pnpm build --watch
45-
```
38+
```sh
39+
pnpm turbo watch build
40+
```
4641

4742
### Running linting/tests
4843

@@ -142,6 +137,19 @@ You should always commit the change to git.
142137

143138
## Submitting
144139

140+
### Code Formatting
141+
142+
#### dprint
143+
144+
We use [dprint](https://dprint.dev/install/) for automatic code formatting to maintain a consistent style.
145+
Please ensure your code is formatted prior to submitting.
146+
147+
Just run:
148+
149+
```sh
150+
pnpm dprint fmt
151+
```
152+
145153
### Generating changesets
146154

147155
We use [🦋 Changesets](https://github.com/changesets/changesets?tab=readme-ov-file) to manage versioning and changelogs.

cspell.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
"lhci",
137137
"lh",
138138
"queueMicrotask",
139+
"rustup", // Rust installer/manager
139140
],
140141
// Glob
141142
"ignorePaths": [

0 commit comments

Comments
 (0)