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: docs/config-dependencies.md
+38-25Lines changed: 38 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,49 +1,60 @@
1
1
---
2
2
id: config-dependencies
3
-
title: Config dependencies
3
+
title: Config Dependencies
4
4
---
5
5
6
-
Config dependencies are installed before all the other types of dependencies (before "dependencies", "devDependencies", "optionalDependencies").
6
+
Config dependencies allow you to share and centralize configuration files, settings, and hooks across multiple projects. They are installed before all regular dependencies ("dependencies", "devDependencies", "optionalDependencies"), making them ideal for setting up custom hooks, patches, and catalog entries.
7
7
8
-
Config dependencies cannot have dependencies of their own or lifecycle scripts. They should be added using exact version and the integrity checksum. Example:
8
+
Config dependencies help you keep all the hooks, settings, patches, overrides, catalogs, rules in a single place and use them across multiple repositories.
9
+
10
+
## How to Add a Config Dependency
11
+
12
+
Config dependencies are defined in your `pnpm-workspace.yaml` and must be installed using an exact version and an integrity checksum.
You may load a list of package names that are allowed to be built via config dependencies and the [`onlyBuiltDependenciesFile`] setting. For example, you may publish a package with an `allow.json` file in its root directory:
30
+
You can load a list of package names that are allowed to be built, using the [`onlyBuiltDependenciesFile`] setting.
20
31
21
-
```json
32
+
Example `allow.json` file inside a config dependency:
33
+
34
+
```json title="allow.json"
22
35
[
23
36
"esbuild",
24
37
"fsevents"
25
38
]
26
39
```
27
40
28
-
Let's say this package is called `my-configs`, then your project's `pnpm-workspace.yaml` will look like this:
Config dependencies are installed before the hooks from [`.pnpmfile.cjs`] are loaded, so you can use them as dependencies for your hooks.
53
+
Config dependencies are installed **before** hooks from your [`.pnpmfile.cjs`] are loaded, allowing you to import logic from config packages.
43
54
44
-
For instance, you may have a config dependency called "my-hooks" that exports a `readPackage` hook. In this case, you can import it into your `.pnpmfile.cjs` like this:
Using the [`updateConfig`] hook, you can dynamically update any configuration settings used by pnpm. Because hooks can be loaded from config dependencies, you can also share settings across projects by publishing them as config dependencies.
71
+
Using the [`updateConfig`] hook, you can dynamically update pnpm’s settings using config dependencies.
61
72
62
-
For example, the following pnpmfile defines a hook that adds a new [catalog] entry to pnpm's configuration. This allows you to refer to the catalog entry when specifying dependency versions:
73
+
For example, the following `pnpmfile` adds a new [catalog] entry to pnpm's configuration:
63
74
64
75
```js title="my-catalogs/pnpmfile.cjs"
65
76
module.exports = {
@@ -73,21 +84,21 @@ module.exports = {
73
84
}
74
85
```
75
86
76
-
You can publish this pnpmfile inside a config dependency. Once published and installed, you can load it by specifying the following settings in your `pnpm-workspace.yaml`:
You can reference [patch files] stored inside config dependencies.
106
119
107
-
You can reference [patch files] installed via config dependencies. For instance, if you have a config dependency called "my-patches", you can load patches from it:
0 commit comments