koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 117 forks source link

[feat] add koa as peerDependencies #157

Closed imballinst closed 6 months ago

imballinst commented 11 months ago

Describe the feature

Currently, koa is listed as devDependencies here (as it should).

https://github.com/koajs/bodyparser/blob/664cd7c413250d5e12eb5bb0fbf4e52d31ef24f5/package.json#L59

However, given that koa is also needed when using this package, I somewhat feel like it's a good idea to put it in peerDependencies, just in case? I stumbled upon this error where koa dependency inside this part can't be found:

https://github.com/koajs/bodyparser/blob/664cd7c413250d5e12eb5bb0fbf4e52d31ef24f5/src/body-parser.ts#L2

I am using Yarn 3.6.4 with nodeLinker: pnpm with rather strict setup, so a package needs to be specified explicitly otherwise it can't be "linked". So in this case, since koa is neither added as dependencies or peerDependencies, Yarn can't resolve it, hence making the declare module "koa" not affecting the actual application.

I propose to add this:

"peerDependencies": {
  "koa": "^2.14.1"
}

into package.json, so that stricter package managers can pick the module up from inside node_modules. Let me know what you think. Thanks!

Checklist