Skip to content

Commit ba5642e

Browse files
UlisesGasconctcpipwesleytodd
authored
docs: add policy on using caret (^) or tilde (~) with dependencies (#290)
Signed-off-by: Ulises Gascon <ulisesgascongonzalez@gmail.com> Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com> Co-authored-by: Wes Todd <wes@wesleytodd.com>
1 parent 2f80a63 commit ba5642e

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# ADR 002: Policy on Using Caret (`^`) or tilde (`~`) with Dependencies in `package.json`
2+
3+
## Status
4+
Proposed
5+
6+
## Submitters
7+
- Ulises Gascón (@UlisesGascon)
8+
9+
## Decision Owners
10+
- Express TC (@expressjs/express-tc)
11+
12+
## Context
13+
Historically, the Express project has avoided using the caret (`^`) in the `package.json` files for its own dependencies. This proposal aims to review whether this practice should continue or if adjustments are needed.
14+
15+
**Why do we need this decision?**
16+
Clarifying the policy on using caret (`^`) helps to ensure consistency across the Express ecosystem, reduce unnecessary maintenance, and prevent unexpected dependency updates. It also addresses concerns about the balance between keeping dependencies up-to-date and avoiding regressions.
17+
18+
**What problem does it solve or avoid?**
19+
This decision aims to reduce the maintenance burden of frequently updating pinned dependencies.
20+
21+
**Are there any existing issues/discussions/pull requests related to this?**
22+
- [Discussion: Using caret (^) with our own dependencies #279](https://github.com/expressjs/discussions/issues/279)
23+
- [expressjs/express#6017 (comment)](https://github.com/expressjs/express/issues/6017)
24+
25+
## Decision
26+
We will adopt a policy where the caret (`^`) symbol is used for dependencies all dependencies.
27+
28+
**What will be done?**
29+
- Update the `package.json` files to use `^` for all dependencies (both prod and dev).
30+
31+
**Note on `^` vs. `~`:**
32+
- `^` allows updates to the most recent minor or patch version, offering greater flexibility and reducing the need for frequent manual updates. For example, `^1.2.3` will accept updates to `1.3.0`, `1.4.0`, but not `2.0.0`.
33+
- `~` is more conservative, only allowing updates to patch versions. For example, `~1.2.3` will accept updates to `1.2.4`, `1.2.5`, but not `1.3.0`. Some Node.js legacy versions only support this, like Node@0.8.
34+
35+
**What will not be done?**
36+
- We won't force to use `^` or `~` for any dependency if there is a reason to use a pinned version and it is properly documented.
37+
38+
## Rationale
39+
40+
**Alternatives Considered:**
41+
- **Alternative:** Continue pinning all dependencies, including internal ones, to specific versions.
42+
- **Reason for rejection:** This approach requires frequent updates and increases the maintenance burden, as each minor or patch update requires a new release.
43+
44+
**Pros and Cons**:
45+
46+
**Pros**:
47+
- Reduces the number of PRs for updating our own dependencies.
48+
- Allows for quicker adoption of minor and patch updates within the Express ecosystem.
49+
- Users are still protected by lockfiles, mitigating the risk of regressions.
50+
51+
**Cons**:
52+
- There is still a risk of minor regressions from updates, even within internally managed dependencies.
53+
- Requires discipline in maintaining lockfiles to ensure stability for end users.
54+
55+
**Why is this decision the best option?**
56+
This decision strikes a balance between reducing maintenance effort and managing risk. It allows Express to leverage the benefits of semver for our own dependencies while maintaining control over external libraries that could introduce breaking changes.
57+
58+
## Consequences
59+
60+
**Positive Impact**:
61+
- Fewer manual updates required for internally managed dependencies.
62+
- Users benefit from improvements and fixes in internal packages more quickly.
63+
64+
**Negative Impact**:
65+
- Potential risk of regressions if an internal dependency introduces a breaking change in a minor update.
66+
- Users relying on strict version control may need to adjust their expectations when using our own dependencies.
67+
68+
**Mitigations**:
69+
- Strong test coverage and CI checks will help catch potential issues early.
70+
- Clear communication in documentation and release notes to inform users of the updated dependency policy.
71+
- Ensure that we are following strict semver when releasing our own libraries.
72+
73+
## Implementation
74+
75+
- **Phase 1**: Update `package.json` files across all packages to apply `^` for all dependencies which support greater than node@0.10.0.
76+
- **Phase 2**: Review and adjust documentation to include the new policy on dependency versioning.
77+
78+
## References
79+
- [NPM semver documentation](https://docs.npmjs.com/cli/v6/using-npm/semver)
80+
81+
## Changelog
82+
- **[2024-10-22]**: @UlisesGascon - Initial draft of ADR for using caret (`^`) or tilde (`~`) with our own dependencies.

0 commit comments

Comments
 (0)