Closed mekwall closed 4 years ago
I don't think this is correct. It is actually a mistake to use fastify-plugin
without a parent fastify
instance, i.e. the tree should always look like app => fastify => plugin => fastify-plugin
.
This issue also exhibits itself when using pnpm to install modules. In this case, the warning is nothing more than an annoyance.
The solution we decided upon, and no one has had time to implement yet, was discussed in https://github.com/fastify/fastify/issues/1780#issuecomment-569044068
const fastify = require(require.resolve('fastify', {paths: [require.main.filename]}))
This PR adds fastify as a peer dependency so that it works properly with Yarn v2 without having to override the package. Without it you'll get the following message in your log for every plugin since it is trying to require
fastify/package.json
:Yarn v2 enforces packages to list all dependencies that are used by that package. In this case, fastify is provided by the user so it should be a peer dependency.
Checklist
npm run test
andnpm run benchmark