|
1 | 1 | # Repository guidelines
|
2 | 2 |
|
| 3 | +## Setup environment |
| 4 | + |
| 5 | +1. Install [fnm](https://github.com/Schniz/fnm) and run `fnm install`/`fnm use` to match the Node.js version in `.nvmrc` (`v24.5.0`). |
| 6 | +2. Enable Corepack (`corepack enable`) and then activate pnpm via `corepack prepare` (the pnpm version is specified in `packageManager` field in `package.json`). |
| 7 | +3. Clone the repository and install dependencies with `pnpm install` from the repository root. |
| 8 | + |
3 | 9 | ## Project structure & module organization
|
4 | 10 |
|
5 |
| -- Monorepo via `pnpm` + `Nx`. |
6 |
| -- Packages: `packages/core` (CLI + `@rslib/core`), `packages/plugin-dts` (DTS plugin), `packages/create-rslib` (scaffolder). |
7 |
| -- Tests: `packages/*/tests` (unit) and `tests/` (`integration`, `e2e`, `benchmark`); examples in `examples/`. |
8 |
| -- Key config: `nx.json`, `biome.json`, `.prettierrc.json`, `rslint.jsonc`, `pnpm-workspace.yaml`. |
| 11 | +- Monorepo via the `pnpm` workspace. |
| 12 | +- `packages/core` (`@rslib/core`): CLI entry (`rslib build`, `--watch`) and programmatic helpers (`build`, `defineConfig`, `loadConfig`). |
| 13 | +- `packages/plugin-dts` (`rsbuild-plugin-dts`): provides the `dts` configuration hook (e.g., `{ dts: { bundle: true } }`). |
| 14 | +- `packages/create-rslib` (`create-rslib`): scaffolds new projects via `pnpm dlx create-rslib` or `npx create-rslib`. |
| 15 | +- Tests live in `packages/*/tests` (unit) and `tests/` (`integration`, `e2e`, `benchmark`); examples in `examples/`. |
| 16 | +- Key configuration files: `nx.json`, `biome.json`, `.prettierrc.json`, `rslint.jsonc`, `pnpm-workspace.yaml`. |
9 | 17 |
|
10 | 18 | ## Build, test, and development commands
|
11 | 19 |
|
12 |
| -- Install: `pnpm install` (Node >= 18.12, pnpm >= 10.15). |
| 20 | +- Install: `pnpm install` (all packages will be built in postinstall). |
13 | 21 | - Build: `pnpm build` (all) and `pnpm build:examples`.
|
14 | 22 | - Watch dev: `pnpm -C packages/core dev` (or other package).
|
15 | 23 | - Lint/format: `pnpm lint`; auto-fix: `pnpm format`.
|
16 | 24 | - Type-check: `pnpm type-check`.
|
17 |
| -- Tests: `pnpm test`; targeted: `test:unit|:integration|:e2e|:benchmark`; update snapshots: `pnpm testu`. |
| 25 | +- Tests: |
| 26 | + - `pnpm test` runs the entire suites. |
| 27 | + - `pnpm test:unit` scopes to unit tests. |
| 28 | + - `pnpm test:integration` scopes to integration tests; add `<pattern>` to match specific cases. |
| 29 | + - `pnpm test:e2e` runs end-to-end tests. |
18 | 30 |
|
19 | 31 | ## Coding style & naming conventions
|
20 | 32 |
|
21 | 33 | - TypeScript + ESM; spaces; single quotes.
|
22 | 34 | - Biome is canonical linter/formatter; Prettier formats MD/CSS/JSON and `package.json`.
|
| 35 | +- Run `pnpm biome check --write --unsafe` on modified source files; when `package.json` changes, also run `prettier --write package.json`. |
23 | 36 | - Filenames: `camelCase` or `PascalCase` (Biome enforced).
|
24 | 37 |
|
25 | 38 | ## Testing guidelines
|
26 | 39 |
|
27 | 40 | - Unit/integration: `@rstest/core`; E2E: `@playwright/test`.
|
28 | 41 | - Naming: `*.test.ts`/`*.test.tsx`; snapshots in `__snapshots__/`.
|
29 | 42 | - Placement: unit under `packages/*/tests`; integration under `tests/integration`; e2e under `tests/e2e`.
|
| 43 | +- Target specific integration cases: `pnpm test:integration <pattern>` (faster than the full suite). |
30 | 44 |
|
31 | 45 | ## Commit & pull request guidelines
|
32 | 46 |
|
33 | 47 | - Conventional Commits (e.g., `fix(dts): ...`); keep commits focused; run lint + tests.
|
34 | 48 | - User-facing changes need a Changeset (`pnpm changeset`); PRs should include description, linked issues, and doc/example updates when needed.
|
35 | 49 |
|
36 |
| -## Architecture overview |
37 |
| - |
38 |
| -- `packages/core` (`@rslib/core`): CLI `rslib build` (add `--watch`), config via `rslib.config.ts` using `defineConfig`; programmatic `import { build, defineConfig, loadConfig } from '@rslib/core'`. |
39 |
| -- `packages/plugin-dts` (`rsbuild-plugin-dts`): detail implementation of `dts` in `rslib.config.ts` (e.g., `{ dts: { bundle: true } }`); |
40 |
| -- `packages/create-rslib` (`create-rslib`): scaffold new projects/templates with `pnpm dlx create-rslib` (or `npx create-rslib`). |
41 |
| - |
42 | 50 | ## Security & configuration tips
|
43 | 51 |
|
44 | 52 | - Do not commit build artifacts (`dist/`, `compiled/`).
|
|
0 commit comments