nest
nest copied to clipboard
unpin fastify/express hard dependency from `@nestjs/platform-*`
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Is your feature request related to a problem? Please describe it
When we install @nestjs/[email protected] we'll get fastify v4.27.0 because this version is pinned
https://github.com/nestjs/nest/blob/15cb568e40f42fb3c40c4cb2ad432b23a5ec7bcd/packages/platform-fastify/package.json#L20-L28
but when we want have fastify as hard dep of our project, we'll download its latest version (v4.28.0)
And so our dependency graph (npm ls fastify) will look like this:
meaning that we have 2 versions of fastify installed instead of just the latest one.
This will lead to build problems when we want (for whatever reason) to use types from ./node_modules/fastify against types from ./node_modules/@nestjs/platform-fastify/fastify
like this one:
because of this:
in the above case we can safely drop the explicit typing because the .getInstance() method will return a proper type definition (FastifyInstance from the nested version of fastify).
Describe the solution you'd like
Changing "fastify": "4.28.0" to "fastify": "^4.28.0" should be enough. Same for express.
We'd have to configure the Renovatebot to prevent it from reverting this change.
Teachability, documentation, adoption, migration strategy
N/A
What is the motivation / use case for changing the behavior?
DX improvements:
- People will face those errors and might not understand why is that
- People won't need to rely on upgrades on
@nestjs/platform-fastify/@nestjs/platform-expresswhen they want to upgradefastify/expresson their side (as long as they respect the major slice), avoiding issues like #13607 and questions at our Discord community