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

mongodb should be a dependency or peerDependency instead of devDependency #96

Open
crccheck opened this issue Jun 9, 2022 · 2 comments

Comments

@crccheck
Copy link

crccheck commented Jun 9, 2022

In /src/cache, dataloader and bson are dependencies, but mongodb is not:

import DataLoader from 'dataloader'
import { ObjectId } from 'mongodb'
import { EJSON } from 'bson'

Current dependencies:

"dependencies": {
"@types/mongodb": "^3.5.27",
"apollo-datasource": "^0.3.1",
"apollo-server-caching": "^0.3.1",
"apollo-server-errors": "^2.4.1",
"bson": "^4.1.0",
"dataloader": "^1.4.0"
},

That means if you install apollo-datasource-mongodb, then run npm prune --production, there's a chance that the mongodb package will be pruned and this package will error with:

Error: Cannot find module 'mongodb'
@crccheck
Copy link
Author

crccheck commented Jun 9, 2022

what's strange is I have mongoose as a dependency, so I should be getting mongodb via that: https://github.com/Automattic/mongoose/blob/b0043b7be02f846bb224e2332be0867aec058904/package.json#L24

edit:
I had mongoose which wanted [email protected] and mongodb-memory-server which wanted mongodb@^4.5.0, which resolved to v4.7.0. So when my build process ran npm prune, it deleted node_modules/mongodb as it should have and my error happened

@lorensr
Copy link
Member

lorensr commented Oct 8, 2022

peerDependency sounds good, PR welcome

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

No branches or pull requests

2 participants