Skip to content

Commit 4f3c3d2

Browse files
committed
[WIP] work through rewriting the guides
1 parent 744f1d8 commit 4f3c3d2

File tree

3 files changed

+69
-263
lines changed

3 files changed

+69
-263
lines changed

site/astro.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export default defineConfig({
3737
const linksById = {
3838
CONFIG_CUSTOM_TYPES: '/syncpack/config/custom-types/',
3939
GUIDE_DEPENDENCY_TYPES: '/syncpack/guide/dependency-types/',
40+
GUIDE_PEER_DEPENDENCIES: '/syncpack/guide/peer-dependencies/',
41+
GUIDE_SEMVER_GROUPS: '/syncpack/guide/semver-groups/',
4042
GUIDE_SPECIFIER_TYPES: '/syncpack/guide/specifier-types/',
43+
GUIDE_VERSION_GROUPS: '/syncpack/guide/version-groups/',
4144
HREF_ANSI: 'https://en.wikipedia.org/wiki/ANSI_escape_code',
4245
HREF_AWS_SDK: 'https://aws.amazon.com/sdk-for-javascript/',
4346
HREF_CONDITIONAL_EXPORTS: 'https://nodejs.org/api/packages.html#conditional-exports',
@@ -118,6 +121,7 @@ export default defineConfig({
118121
{ slug: 'guide/dependency-types' },
119122
{ slug: 'guide/glossary' },
120123
{ slug: 'guide/local-package-versions' },
124+
{ slug: 'guide/peer-dependencies' },
121125
{ slug: 'guide/semver-groups' },
122126
{ slug: 'guide/specifier-types' },
123127
{ slug: 'status', label: 'Status Codes' },
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Peer Dependencies
3+
---
4+
5+
If any of your packages define [`peerDependencies`](HREF_PEER_DEPENDENCIES) (find out with `syncpack list --dependency-types peer`) it's really important that we understand them as they have a very different role.
6+
7+
[`dependencies`](HREF_DEPENDENCIES) tend to be exact (`1.2.3`) or clamped within the patch `~1.2.0` or sometimes even minor `^1.2.0` ranges. They're narrower in scope because there we are a **consumer** and we want higher confidence over knowing what we are running.
8+
9+
[`peerDependencies`](HREF_PEER_DEPENDENCIES) tend to be far broader in scope because in those scenarios we are a **provider** and we want our package to be suitable for as many consuming projects as possible. These versions tend to span entire majors (`^1`) and sometimes multiple majors (`>=6.0.0 <9.0.0`).
10+
11+
:::note[Why this matters]
12+
13+
Unless your project is well-organised using [Version Groups](GUIDE_VERSION_GROUPS), it is very likely that at some point you will see a version mismatch because a peer dependency is not equal to a production dependency.
14+
15+
Here's a common example:
16+
17+
1. One of the packages you develop is an ESLint Plugin and in its `peerDependencies` you define a range of `"eslint": ">=6.0.0 <9.0.0"` for the ESLint versions it is compatible with.
18+
1. Elsewhere you have `"eslint": "8.53.0"` installed under `devDependencies` because you use ESLint to lint the monorepo.
19+
20+
Syncpack will report a version mismatch because ESLint is referenced twice with wildly different versions.
21+
22+
That we don't consider this particular mismatch to be a problem is domain knowledge about our specific project. Syncpack needs us to share with it that domain knowledge via its [Configuration file](/syncpack/config/syncpackrc/).
23+
24+
:::

0 commit comments

Comments
 (0)