Clarification on Peer Dependencies in `@effect/platform-node` Package

Insight on
@effect/platform-node
package's peer dependencies


I discovered an interesting behavior related to the
@effect/platform-node
package and its peer dependencies:

Here's a snippet from the published package.json manifest:

"dependencies": {
    "mime": "^3.0.0",
    "undici": "^7.1.0",
    "ws": "^8.18.0",
    "@effect/platform-node-shared": "^0.35.0"
  },
  "peerDependencies": {
    "@effect/platform": "^0.82.3",
    "@effect/cluster": "^0.34.0",
    "@effect/sql": "^0.35.3",
    "@effect/rpc": "^0.59.4",
    "effect": "^3.15.2"
  },



As you can see, it lists "@effect/cluster" as a peer dependency, which causes some package managers (particularly pnpm with autoInstallPeers = true, which is the default) to install it even when the @effect/cluster package isn't actually used in your project.

Question

Does the
@effect/platform-node
package always require @effect/cluster?

Potential Solution

If @effect/cluster is not always needed, a cleaner solution would be to use the peerDependenciesMeta field to mark it as optional:

  "peerDependencies": {
    "@effect/platform": "^0.82.3",
    "@effect/cluster": "^0.34.0",
    "@effect/sql": "^0.35.3",
    "@effect/rpc": "^0.59.4",
    "effect": "^3.15.2"
  },
  "peerDependenciesMeta": {
    "@effect/cluster": {
       "optional": true
      },
    }


This would prevent package managers from automatically installing @effect/cluster when it's not needed while still preserving compatibility for projects that do use it.

WDYT?
Was this page helpful?