Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Check which optional peers a new dependency drags into the production image
Package managers that auto-install peer dependencies will pull an entire framework runtime in behind a small library, and a production-only install keeps it because it resolved as a real dependency.
Bad example
| 1 | // package.json |
| 2 | { "dependencies": { "@startsiden/hegnar-logger": "^1.0.0" } } |
| 3 |
|
| 4 | // The logger declares an optional framework peer; auto-install resolves it, |
| 5 | // and the production install keeps ~13MB of framework runtime the service never imports. |
Explanation (EN)
Nothing in the diff mentions the framework, so the size regression is invisible in review and only shows up as a larger image and a longer cold start.
Objašnjenje (HR)
Nista u diffu ne spominje framework, pa je porast velicine nevidljiv u reviewu i pokazuje se tek kao veca slika i duze hladno pokretanje.
Good example
| 1 | // package.json |
| 2 | { |
| 3 | "dependencies": { "@startsiden/hegnar-logger": "^1.0.0" }, |
| 4 | "pnpm": { |
| 5 | "peerDependencyRules": { "ignoreMissing": ["@nestjs/common"] } |
| 6 | } |
| 7 | } |
Explanation (EN)
The unused optional peer is excluded explicitly, so the production image contains only what the service actually imports.
Objašnjenje (HR)
Neiskoristeni neobavezni peer izricito je iskljucen, pa produkcijska slika sadrzi samo ono sto servis stvarno uvozi.
Notes (EN)
After adding a dependency, run the production install and compare installed size. The lockfile entry shows which optional peers were resolved.
Bilješke (HR)
Nakon dodavanja ovisnosti pokreni produkcijsku instalaciju i usporedi velicinu. Zapis u lockfileu pokazuje koji su neobavezni peerovi razrijeseni.