Skip to content

Clarify timing and limitations of hooks in docs #9752

@TrevorBurnham

Description

@TrevorBurnham

Contribution

Describe the user story

I've been working on trying to bridge pnpm with an internal package system by telling pnpm to install some packages from local tarballs instead of a registry. While the pnpmfile hooks are quite powerful, I've run into several surprising limitations. For instance, it seems unfortunate that preResolution can't be used to force pnpm to reinstall an already-installed package, since I think that's a strong use case for the hook: #9516

My biggest recent surprise is the timing of the afterAllResolved hook. The docs say:

Allows you to mutate the lockfile output before it is serialized.

That phrasing suggests to me that the hook should only affect what pnpm emits to pnpm-lock.yaml, not its installation behavior. But in fact the hook runs between resolution and installation, and the lockfile returned from the function is used for installation. There are certainly valid use cases for that timing, but the docs don't explain that.

For my use case, a true "runs right before pnpm-lock.yaml is serialized" hook would be useful (afterAllInstalled?), because I want to clean up the local tarball paths injected by earlier hooks. (Those paths would be different across systems, creating noisy git diffs.)

Describe the solution you'd like

The pnpmfile docs should explain the full install lifecycle and how the hooks fit into that lifecycle. They should also describe at least one use case for each hook.

Describe the drawbacks of your solution

No response

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions