Skip to content

Commit 79804ba

Browse files
committed
chore: update CONTRIBUTING
1 parent 3d0ca63 commit 79804ba

2 files changed

Lines changed: 84 additions & 92 deletions

File tree

CONTRIBUTING.md

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,81 @@
11
# How to Contribute
22

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.
44

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
276

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
3611
```
3712

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
4914

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+
```
5121

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. 👨🏻‍🍳🥓
5423

55-
## Simple release
24+
## Day-to-day commands
5625

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` |
5837

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.
6239

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.
6441
65-
Then you'll run:
42+
## Sending a PR
6643

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.
7048

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
7250

73-
Finally:
51+
(Maintainers only — needs npm publish access.) We use [changesets](https://github.com/changesets/changesets). All packages are version-locked.
7452

75-
```shell
76-
pnpm release
77-
```
53+
### Simple release
7854

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`.
8068

81-
## Prerelease
69+
### Prerelease
8270

83-
Everything above applies but you must first run:
71+
Enter pre-mode first, then follow the simple release flow:
8472

85-
```shell
86-
pnpm changeset pre enter beta | alpha | next
73+
```sh
74+
pnpm changeset pre enter beta # or alpha, next
8775
```
8876

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:
9078

91-
```shell
79+
```sh
9280
pnpm changeset pre exit
9381
```

demo/CONTRIBUTING.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
# Contributing a new demo
22

3-
## Preface
3+
Thanks for the interest! Before reading on, have a look at the repo's [contribution guide](../CONTRIBUTING.md).
44

5-
Thanks for being interested in contributing a demo! Before you read more, have you read the [contribution guide](https://github.com/pmndrs/react-spring/blob/main/CONTRIBUTING.md) for the repo? If not, give it a look first!
5+
## What's required
66

7-
## What is required
7+
Demos are based on the CodeSandbox `react-typescript` template. You can either copy an existing demo and tweak it, or build one in CodeSandbox and export the code into `demo/src/sandboxes/<your-demo>/`.
88

9-
All our demos are based on codesandbox templates for react-typescript. If you're going to contribute a
10-
demo, you can either copy an existing demo and tweak it or create a new one in codesandbox, export the
11-
code and add it to the repo.
12-
13-
You should ensure your demo follows the same structure as the other ones:
9+
Each demo follows this structure:
1410

1511
```
16-
- public
17-
- src
18-
- - App.tsx
19-
- - index.tsx
20-
- .pretterrc
21-
- package.json
22-
- tsconfig.json // I would copy this from an existing one
23-
- thumbnail.png
12+
demo/src/sandboxes/<your-demo>/
13+
├── public/
14+
│ └── index.html
15+
├── src/
16+
│ ├── App.tsx # entry point — imported by the demo hub
17+
│ └── index.tsx
18+
├── package.json
19+
├── thumbnail.png # 16:9, shown on the website
20+
└── tsconfig.json # copy from an existing demo
2421
```
2522

26-
This is the minimum we require as the `App.tsx` is used to integrate with our demo hub via vite in the repo.
23+
`App.tsx` is the entry the demo hub renders via Vite, so it must export a default component.
24+
25+
### `package.json`
2726

28-
A few other things to remember
27+
- Set a clear `name` and `description` — both surface on the website.
28+
- List the react-spring hooks you used in `keywords`.
2929

3030
### Thumbnail
3131

32-
This should be included to showcase your work best! Make sure it's a 16:9 ratio.
32+
A 16:9 PNG saved as `thumbnail.png` next to `package.json`. Make it count — this is what people see first.
33+
34+
## Running it locally
3335

34-
### Package.json
36+
From the repo root:
37+
38+
```sh
39+
pnpm demo:dev
40+
```
3541

36-
Ensure there's a clear name and description as these appear on the website. You should also use `tags` to highlight keywords
37-
especially the `react-spring` hooks you've used.
42+
This serves the demo hub via Vite and picks up your new sandbox automatically.
3843

39-
## When you're ready
44+
## Opening the PR
4045

41-
When you've finished adding your code, open a PR explaining the example, why you think it should be included
42-
and most importantly, include a sandbox link so it can be looked at and admired!
46+
Include a CodeSandbox link, a short explanation of the demo, and why it belongs in the hub.

0 commit comments

Comments
 (0)