queckezz / koa-views

Template rendering middleware for koa (hbs, swig, pug, anything! :sparkles:)
MIT License
710 stars 87 forks source link

fix: specify types as optional peer dependency #158

Closed G-Rath closed 3 years ago

G-Rath commented 3 years ago

@types packages are only required for type-checking with TypeScript, so they shouldn't be included as direct dependencies since they're not required at runtime, nor required by folks that are not using TypeScript; doing so means that build environments that prune non-production dependencies (like Heroku) are not able to remove @types/koa.

As such, they should be marked as an optional peer dependency which means that they're not required (e.g. npm v7 won't automatically install them), but if they are used in a project then the package manager will ensure the constraint is matched.

This should not be a breaking change because anyone using TypeScript with Koa will need to be installing @types/koa anyway; it's possible that this could break builds if people don't have @types/koa specified as a direct dependency, but that'd mean they're relying on package managers to hoist the dependency from packages like this one which is bad anyway.

The "fix" for that situation is to add @types/koa as a direct dependency.

int64ago commented 3 years ago

thx