@stephansama/pnpm-hooks
@stephansama/pnpm-hooks
Section titled “@stephansama/pnpm-hooks”preconfigured pnpm hooks and types for pnpmfile
Table of contents
Section titled “Table of contents”Open Table of contents
Installation
Section titled “Installation”pnpm install @stephansama/pnpm-hookspnpmfile hooks are useful, but the types and small reusable hook helpers are easy to reimplement in every workspace. This package collects both:
- ready-to-use pnpm hook implementations
- exported TypeScript types for authoring your own
pnpmfilehooks
What this package exports
Section titled “What this package exports”The package exposes two top-level namespaces:
readPackageHooksprebuiltreadPackagehook utilitiestypespnpm hook types includingPnpmFileHooks,ReadPackageHook,BeforePackingHook,AfterAllResolvedHook,ImportPackageHook,PreResolutionHook, andUpdateConfigHook
Included hooks
Section titled “Included hooks”The sections below are organized so each hook can carry its own behavior notes and example output as the package grows.
readPackageHooks.pinAllDependencies
Section titled “readPackageHooks.pinAllDependencies”Pins dependency ranges by removing leading ^ and ~ prefixes from:
dependenciesdevDependenciesoptionalDependencies
This runs on every manifest processed by pnpm through the readPackage hook, which makes it useful for workspaces that want consistently pinned transitive and nested dependency ranges during resolution.
Hook examples
Section titled “Hook examples”readPackageHooks.pinAllDependencies
Section titled “readPackageHooks.pinAllDependencies”Given a dependency manifest like this:
{ "dependencies": { "react": "^19.1.0" }, "devDependencies": { "typescript": "~5.9.2" }, "optionalDependencies": { "@types/node": "^24.0.0" }}pinAllDependencies rewrites it to:
{ "dependencies": { "react": "19.1.0" }, "devDependencies": { "typescript": "5.9.2" }, "optionalDependencies": { "@types/node": "24.0.0" }}Requirements
Section titled “Requirements”- Node.js
>=24 - a pnpm setup that loads a
pnpmfile
import { readPackageHooks, type types } from "@stephansama/pnpm-hooks";
export const hooks = { readPackage: readPackageHooks.pinAllDependencies,} satisfies types.PnpmFileHooks;Modules
Section titled “Modules”| Module | Description |
|---|---|
|
‐ |
|
|
‐ |
|
|
‐ |