@zudojs/plugins 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -102,6 +102,24 @@ and the dependency itself. Cycles throw `PluginDependencyCycleError` with
102
102
  the cycle path. Optional dependencies that are present still participate in
103
103
  ordering; optional dependencies that are absent are ignored.
104
104
 
105
+ A dependency is optional when it is listed in `optionalDependencies` or
106
+ marked `optional: true` inside `dependencies` — the two forms are
107
+ equivalent:
108
+
109
+ ```typescript
110
+ manager.register({
111
+ metadata: { name: "@acme/api" },
112
+ dependencies: [
113
+ { name: "@acme/db" }, // required: start() throws if it is missing
114
+ { name: "@acme/metrics", optional: true }, // skipped when missing
115
+ ],
116
+ });
117
+ // Same as: optionalDependencies: [{ name: "@acme/metrics" }]
118
+ ```
119
+
120
+ When `@acme/metrics` is registered, `@acme/api` starts after it, and any
121
+ `version` constraint on it is enforced.
122
+
105
123
  Declared versions are enforced before any hook runs:
106
124
 
107
125
  ```typescript
@@ -41,7 +41,8 @@ export declare class DependencyResolver {
41
41
  * Optional dependencies that are present participate in ordering — a
42
42
  * plugin that optionally integrates with a peer must still start after
43
43
  * it — while optional dependencies that are absent are ignored rather
44
- * than reported missing.
44
+ * than reported missing. A dependency is optional when it is listed in
45
+ * `optionalDependencies` or carries `optional: true` in `dependencies`.
45
46
  */
46
47
  resolve(plugins: Map<string, ResolvablePlugin>): DependencyResolution;
47
48
  /**
@@ -9,14 +9,15 @@ export class DependencyResolver {
9
9
  * Optional dependencies that are present participate in ordering — a
10
10
  * plugin that optionally integrates with a peer must still start after
11
11
  * it — while optional dependencies that are absent are ignored rather
12
- * than reported missing.
12
+ * than reported missing. A dependency is optional when it is listed in
13
+ * `optionalDependencies` or carries `optional: true` in `dependencies`.
13
14
  */
14
15
  resolve(plugins) {
15
16
  const missingDetails = [];
16
17
  const cycles = [];
17
18
  for (const [name, plugin] of plugins) {
18
19
  for (const dep of plugin.dependencies ?? []) {
19
- if (!plugins.has(dep.name)) {
20
+ if (dep.optional !== true && !plugins.has(dep.name)) {
20
21
  missingDetails.push({ plugin: name, dependency: dep.name });
21
22
  }
22
23
  }
@@ -4,6 +4,11 @@
4
4
  export interface PluginDependency {
5
5
  readonly name: string;
6
6
  readonly version?: string;
7
+ /**
8
+ * When `true`, a missing plugin of this name is skipped instead of
9
+ * failing `start()`; when it is registered, the declaring plugin still
10
+ * starts after it. Equivalent to listing it in `optionalDependencies`.
11
+ */
7
12
  readonly optional?: boolean;
8
13
  }
9
14
  //# sourceMappingURL=pluginDependency.type.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/plugins",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Plugin system for extending Zudojs applications with modular capabilities.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,11 +24,11 @@
24
24
  "!dist/.tsbuildinfo"
25
25
  ],
26
26
  "dependencies": {
27
- "@zudojs/errors": "1.3.0"
27
+ "@zudojs/errors": "1.3.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^26.6.2",
31
- "@zudojs/events": "1.3.0",
31
+ "@zudojs/events": "1.3.2",
32
32
  "typescript": "7.0.2",
33
33
  "vitest": "^5.0.1"
34
34
  },