Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upyarn plug and play and optional peerDependencies #3059
Closed
Comments
This comment has been minimized.
This comment has been minimized.
That is interesting... If it can be setup to package.json without breaking npm functionality, I don't see why it couldn't be added. I don't think that just having However I still didn't understand how that should work in a way that only needed DB driver package would be included... could you elaborate it more how knex's package.json and parent projects package.json should look in that case? |
This comment has been minimized.
This comment has been minimized.
Released in 0.20.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
yarn --pnp
is a really interesting thing to speedup module loading:https://yarnpkg.com/en/docs/pnp
however it needs all modules to declare what they depend on to be able to work properly.
In the case of modules like knex, where one of the dependencies is declared by a parent module, the plug and play system fails (e.g. knex won't find pg).
pg, mysql2, sqlite3 (...) should be in peerDependencies, but optional.
This is precisely what yarn's peerDependenciesMeta field do:
yarnpkg/yarn@011a634
However i suppose it needs to be available in npm too before it can be added to knex's package.json.
Meanwhile, a simple solution would be to be able to pass knex the driver module itself, like