You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+18-19Lines changed: 18 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,43 +74,52 @@ Unique to Preact we do support several ways to hook into our renderer. All our a
74
74
75
75
## Important Branches
76
76
77
-
We merge every PR into the `main` branch which is the one that we'll use to publish code to npm. For the previous Preact release line we have a branch called `8` which is in maintenance mode. As a new contributor you won't have to deal with that ;)
77
+
We have a couple of important branches to be aware of:
78
+
79
+
-`main` - This is the main development branch and represents the upcoming v11 release line.
80
+
-`v10.x` - This branch represents the current stable release line, v10.
81
+
82
+
As we have yet to release v11, contributors are welcome to use either branch to build upon. We will try to port changes between the branches when possible, to keep them in sync, but if you're feeling generous, we'd love if you'd submit PRs to both branches!
78
83
79
84
## Creating your first Pull-Request
80
85
81
86
We try to make it as easy as possible to contribute to Preact and make heavy use of GitHub's "Draft PR" feature which tags Pull-Requests (short = PR) as work in progress. PRs tend to be published as soon as there is an idea that the developer deems worthwhile to include into Preact and has written some rough code. The PR doesn't have to be perfect or anything really ;)
82
87
83
88
Once a PR or a Draft PR has been created our community typically joins the discussion about the proposed change. Sometimes that includes ideas for test cases or even different ways to go about implementing a feature. Often this also includes ideas on how to make the code smaller. We usually refer to the latter as "code-golfing" or just "golfing".
84
89
85
-
When everything is good to go someone will approve the PR and the changes will be merged into the `main`branch and we usually cut a release a few days/ a week later.
90
+
When everything is good to go someone will approve the PR and the changes will be merged into the `main`or `v10.x` branches and we usually cut a release a few days/ a week later.
86
91
87
92
_The big takeaway for you here is, that we will guide you along the way. We're here to help to make a PR ready for approval!_
88
93
89
94
The short summary is:
90
95
91
96
1. Make changes and submit a PR
92
97
2. Modify change according to feedback (if there is any)
93
-
3. PR will be merged into `main`
98
+
3. PR will be merged into `main` or `v10.x`
94
99
4. A new release will be cut (every 2-3 weeks).
95
100
96
101
## Commonly used scripts for contributions
97
102
98
-
Scripts can be executed via `npm run [script]` or `yarn [script]` respectively.
103
+
Scripts can be executed via `npm run [script]`.
99
104
100
105
-`build` - compiles all packages ready for publishing to npm
101
106
-`build:core` - builds just Preact itself
102
107
-`build:debug` - builds the debug addon only
108
+
-`build:devtools` - builds the devtools addon only
103
109
-`build:hooks` - builds the hook addon only
104
110
-`build:test-utils` - builds the test-utils addon only
111
+
-`build:compat` - builds the compat addon only
112
+
-`build:jsx` - builds the JSX runtime addon only
113
+
-`test` - Run all tests (linting, TypeScript definitions, unit/integration tests)
105
114
-`test:ts` - Run all tests for TypeScript definitions
106
-
-`test:karma` - Run all unit/integration tests.
107
-
-`test:karma:watch` - Same as above, but it will automatically re-run the test suite if a code change was detected.
115
+
-`test:vitest` - Run all unit/integration tests.
116
+
-`test:vitest:watch` - Same as above, but it will automatically re-run the test suite if a code change was detected.
108
117
109
-
But to be fair, the only ones we use ourselves are `build` and `test:karma:watch`. The other ones are mainly used on our CI pipeline and we rarely use them.
118
+
But to be fair, the ones we mostly use locally are `build` and `test:vitest:watch`. The other ones are mainly used on our CI pipeline.
110
119
111
-
_Note: Both `test:karma` and `test:karma:watch` listen to the environment variable `COVERAGE=true`. Disabling code coverage can significantly speed up the time it takes to complete the test suite._
120
+
_Note: Both `test:vitest` and `test:vitest:watch` listen to the environment variable `COVERAGE=true`. Disabling code coverage can significantly speed up the time it takes to complete the test suite._
112
121
113
-
_Note2: The test suite is based on `karma` and `mocha`. Individual tests can be executed by appending `.only`:_
122
+
_Note2: Individual tests can be executed by appending `.only`:_
114
123
115
124
```jsx
116
125
it.only('should test something', () => {
@@ -167,16 +176,6 @@ Check out the [official TypeScript documentation](https://www.typescriptlang.org
167
176
168
177
_Note that we have separate tests for our TypeScript definition files. We only use `ts-check` for local development and don't check it anywhere else like on the CI._
169
178
170
-
### Why does the code base often use `let` instead of `const`?
171
-
172
-
There is no real reason for that other a historical one. Back before auto-formatting via prettier was a thing and minifiers weren't as advanced as they are today we used a pretty terse code-style. The code-style deliberately was aimed at making code look as concise and short as possible. The `let` keyword is a bit shorter than `const` to write, so we only used that. This was done only for stylistic reasons.
173
-
174
-
This helped our minds to not lose sight of focusing on size, but made it difficult for newcomers to start contributing to Preact. For that reason alone we switched to `prettier` and loosened our rule regarding usage of `let` or `const`. Today we use both, but you can still find many existing places where `let` is still in use.
175
-
176
-
In the end there is no effect on size regardless if you use `const`, `let` or use both. Our code is downtranspiled to `ES5` for npm so both will be replaced with `var` anyways. Therefore it doesn't really matter at all which one is used in our codebase.
177
-
178
-
This will only become important once shipping modern JavaScript code on npm becomes a thing and bundlers follow suit.
179
-
180
179
## How to create a good bug report
181
180
182
181
To be able to fix issues we need to see them on our machine. This is only possible when we can reproduce the error. The easiest way to do that is narrow down the problem to specific components or combination of them. This can be done by removing as much unrelated code as possible.
0 commit comments