|
1 | 1 | # How to Contribute |
2 | 2 |
|
3 | | -1. Clone this repository: |
| 3 | +Thanks for helping out! This guide covers everything you need to get a local checkout running, send a PR, and (if you have publish access) cut a release. |
4 | 4 |
|
5 | | -```sh |
6 | | -git clone https://github.com/pmndrs/react-spring |
7 | | -cd react-spring |
8 | | -``` |
9 | | - |
10 | | -2. Enable Corepack so the pinned pnpm version activates automatically: `corepack enable`. (See `.nvmrc` for the matching Node version.) |
11 | | - |
12 | | -3. Install dependencies: `pnpm install` |
13 | | - |
14 | | -4. Let's get cooking! 👨🏻🍳🥓 |
15 | | - |
16 | | -## Guidelines |
17 | | - |
18 | | -Be sure your commit messages follow this specification: https://www.conventionalcommits.org/en/v1.0.0-beta.4/ |
19 | | - |
20 | | -### Windows permission errors |
21 | | - |
22 | | -Some Windows users may need to [enable developer mode](https://howtogeek.com/292914/what-is-developer-mode-in-windows-10) if experiencing `EPERM: operation not permitted, symlink` with Preconstruct. If this persists, you might be running on an unsupported drive/format. In which case, consider using [Docker](https://docs.docker.com/docker-for-windows). |
23 | | - |
24 | | -### Duplicate `react` errors |
25 | | - |
26 | | -React 16.8+ has global state to support its "hooks" feature, so you need to ensure only one copy of `react` exists in your program. Otherwise, you'll most likely see [this error](https://reactjs.org/warnings/invalid-hook-call-warning.html). Please try the following solutions, and let us know if it still doesn't work for you. |
| 5 | +## Prerequisites |
27 | 6 |
|
28 | | -- **For `create-react-app` users:** Follow this guide: https://github.com/facebook/react/issues/13991#issuecomment-496383268 |
29 | | - |
30 | | -- **For `webpack` users:** Add an alias to `webpack.config.js` like this: |
31 | | - |
32 | | - ```js |
33 | | - alias: { |
34 | | - react: path.resolve('node_modules/react'), |
35 | | - } |
| 7 | +- **Node**: see `.nvmrc` (`nvm use` or `fnm use` picks it up). `engines.node` is the same version. |
| 8 | +- **pnpm**: pinned via `packageManager` in the root `package.json`. Enable Corepack so the correct version activates automatically: |
| 9 | + ```sh |
| 10 | + corepack enable |
36 | 11 | ``` |
37 | 12 |
|
38 | | -- **For `gatsby` users:** Install `gatsby-plugin-alias-imports` and add this to your `gatsby-config.js` module: |
39 | | - ```js |
40 | | - { |
41 | | - resolve: `gatsby-plugin-alias-imports`, |
42 | | - options: { |
43 | | - alias: { |
44 | | - react: path.resolve('node_modules/react'), |
45 | | - }, |
46 | | - }, |
47 | | - }, |
48 | | - ``` |
| 13 | +## Getting started |
49 | 14 |
|
50 | | -# Publishing |
| 15 | +```sh |
| 16 | +git clone https://github.com/pmndrs/react-spring |
| 17 | +cd react-spring |
| 18 | +pnpm install |
| 19 | +pnpm exec playwright install chromium # one-off, needed for browser-mode Vitest |
| 20 | +``` |
51 | 21 |
|
52 | | -We use [`changesets`](https://github.com/atlassian/changesets) to publish our package now. |
53 | | -All our dependencies are fixed using ~ after [1414](https://github.com/pmndrs/react-spring/issues/1414) but luckily changesets will bump them for every minor version we release. |
| 22 | +Now you're cooking. 👨🏻🍳🥓 |
54 | 23 |
|
55 | | -## Simple release |
| 24 | +## Day-to-day commands |
56 | 25 |
|
57 | | -You want to release some new features that haven't been released yet: |
| 26 | +| Task | Command | |
| 27 | +| ------------------------ | ------------------------------------------------------- | |
| 28 | +| Watch-build all packages | `pnpm dev` | |
| 29 | +| Run the docs site | `pnpm docs:dev` | |
| 30 | +| Run the demo hub | `pnpm demo:dev` | |
| 31 | +| Full test suite | `pnpm test` (types + unit + e2e) | |
| 32 | +| Unit tests (watch) | `pnpm vitest --project unit` | |
| 33 | +| Single test file | `pnpm vitest run packages/core/src/SpringValue.test.ts` | |
| 34 | +| Type-check | `pnpm test:ts` | |
| 35 | +| Lint | `pnpm lint` | |
| 36 | +| Format | `pnpm format` | |
58 | 37 |
|
59 | | -```shell |
60 | | -pnpm changeset |
61 | | -``` |
| 38 | +Vitest aliases `@react-spring/*` to the package source, so unit tests don't need a prior build. Anything outside Vitest (docs, publishing) does — run `pnpm build` first. |
62 | 39 |
|
63 | | -Follow the prompt to flag which packages need to update although with `react-spring` we keep all our packages at the same version. |
| 40 | +> **pnpm isolation gotcha**: `node_modules` is non-hoisted. If you hit `Cannot find module 'foo'` after adding an import, add `foo` to the workspace's `package.json` — don't add a hoist rule. |
64 | 41 |
|
65 | | -Then you'll run: |
| 42 | +## Sending a PR |
66 | 43 |
|
67 | | -```shell |
68 | | -pnpm vers |
69 | | -``` |
| 44 | +- **Target branch**: `next` (the active line). `main` may exist but isn't the merge base. |
| 45 | +- **Commits**: follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `chore:`, …). commitlint enforces this on the `commit-msg` hook. |
| 46 | +- **Pre-commit**: `oxfmt --check` runs via husky. If it fails, run `pnpm format` and re-commit. |
| 47 | +- **Keep PRs small and focused** — easier to review, easier to land. |
70 | 48 |
|
71 | | -This will update all the packages correctly according to what version you just set with the `add` script & possibly update the deps within those packages. |
| 49 | +## Publishing |
72 | 50 |
|
73 | | -Finally: |
| 51 | +(Maintainers only — needs npm publish access.) We use [changesets](https://github.com/changesets/changesets). All packages are version-locked. |
74 | 52 |
|
75 | | -```shell |
76 | | -pnpm release |
77 | | -``` |
| 53 | +### Simple release |
78 | 54 |
|
79 | | -This will build the packages, publish them & push the tags to github to signify a new release. Please then update the `releases` on github & the changelog on `react-spring.dev` |
| 55 | +1. Add a changeset describing the change. With `react-spring` we bump every package to the same version, so flag them all: |
| 56 | + ```sh |
| 57 | + pnpm changeset |
| 58 | + ``` |
| 59 | +2. Apply the bump (updates package versions and internal deps): |
| 60 | + ```sh |
| 61 | + pnpm vers |
| 62 | + ``` |
| 63 | +3. Publish. This cleans, installs, builds, type-checks, runs unit tests, and publishes via changesets: |
| 64 | + ```sh |
| 65 | + pnpm release |
| 66 | + ``` |
| 67 | + Tags are not pushed automatically (`pnpm release` runs `changeset publish --no-git-tag`). After publishing, draft the GitHub release notes manually and update the changelog on `react-spring.dev`. |
80 | 68 |
|
81 | | -## Prerelease |
| 69 | +### Prerelease |
82 | 70 |
|
83 | | -Everything above applies but you must first run: |
| 71 | +Enter pre-mode first, then follow the simple release flow: |
84 | 72 |
|
85 | | -```shell |
86 | | -pnpm changeset pre enter beta | alpha | next |
| 73 | +```sh |
| 74 | +pnpm changeset pre enter beta # or alpha, next |
87 | 75 | ``` |
88 | 76 |
|
89 | | -If you find you're stuck in a prerelease and trying to do a Simple Release, try running: |
| 77 | +If you're stuck in pre-mode and need a normal release: |
90 | 78 |
|
91 | | -```shell |
| 79 | +```sh |
92 | 80 | pnpm changeset pre exit |
93 | 81 | ``` |
0 commit comments