Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn plug and play and optional peerDependencies #3059

kapouer opened this issue Feb 19, 2019 · 2 comments · Fixed by #3081

yarn plug and play and optional peerDependencies #3059

kapouer opened this issue Feb 19, 2019 · 2 comments · Fixed by #3081


Copy link

@kapouer kapouer commented Feb 19, 2019


yarn --pnp is a really interesting thing to speedup module loading:
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:

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

var pg = require('knex')({
  client: 'pg',
  driver: require('pg'),
  connection: process.env.PG_CONNECTION_STRING,
  searchPath: ['knex', 'public'],
Copy link

@elhigu elhigu commented Mar 3, 2019

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 peerDependenciesMeta attribute there will break anything.

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?

Copy link

@kibertoad kibertoad commented Oct 29, 2019

Released in 0.20.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging a pull request may close this issue.

3 participants