fix: add fastify as a peer dependency#216
Open
adriano-tirloni wants to merge 1 commit intofastify:mainfrom
Open
fix: add fastify as a peer dependency#216adriano-tirloni wants to merge 1 commit intofastify:mainfrom
adriano-tirloni wants to merge 1 commit intofastify:mainfrom
Conversation
Without a declared peerDependency on fastify, strict package managers like pnpm cannot resolve fastify from @fastify/sensible's own node_modules. This causes TypeScript errors in pnpm monorepos where multiple fastify versions are installed, as the type declarations import from a different fastify instance than the consuming project. This aligns with other @fastify/* plugins (cors, cookie, helmet, etc.) that already declare fastify as a peer dependency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fastifyas apeerDependency(>=5.0.0) to fix type resolution issues in strict package managers like pnpm@fastify/sensibleimports types fromfastifyin its type declarations (types/index.d.ts) but only lists it indevDependenciesFastifyInstancetypes and TypeScript errorsProblem
In pnpm (which uses strict isolated
node_modules),@fastify/sensiblecannot resolvefastifyfrom its ownnode_modulessince it's not a declared dependency. Node's resolution algorithm walks up the directory tree and can land on a different version of fastify installed by another workspace package, causing errors like:Steps to reproduce
@fastify/sensiblein one of themapp.register(fastifySensible)in a TypeScript file withskipLibCheck: falseFix
This is consistent with other
@fastify/*plugins like@fastify/cors,@fastify/cookie,@fastify/helmet, etc. that already declare fastify as a peer dependency.Test plan
npm test)