Skip to content

fix: don't omit the dependency installation in both dependencies and peerdependencies - #8916

Closed
btea wants to merge 4 commits into
pnpm:mainfrom
btea:fix/autoInstallPeers-true-install-dependencies-error
Closed

btea wants to merge 4 commits into
pnpm:mainfrom
btea:fix/autoInstallPeers-true-install-dependencies-error

Conversation

@btea

@btea btea commented Dec 28, 2024

Copy link
Copy Markdown
Member

fix #8912

@btea
btea requested a review from zkochan as a code owner December 28, 2024 03:09
@btea btea changed the title fix: omit the dependency installation in both dependencies and peerdependencies fix: don't omit the dependency installation in both dependencies and peerdependencies Dec 28, 2024

@zkochan zkochan left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a test added. Also, the right solution is probably just to ignore the optional part, if the dependency is present in prod deps.

@btea

btea commented Dec 29, 2024

Copy link
Copy Markdown
Member Author

Do you mean no filtering is needed here?

dependencies: omit(Object.keys(pkg.peerDependencies), pkg.dependencies),

@zkochan

zkochan commented Dec 30, 2024

Copy link
Copy Markdown
Member

Maybe here https://github.com/pnpm/pnpm/blob/main/hooks/read-package-hook/src/createReadPackageHook.ts add a hook that removes peerDependenciesMeta.optional if the package is in prod deps.

@zkochan

zkochan commented Dec 30, 2024

Copy link
Copy Markdown
Member

or actually, no need to do it in the hook. Can be done at the same place in resolve dependencies.

peerOpts.optional = false
}
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still seems to have problems. For example, in the #8912 issue, the file line 1344 has deleted lightningcss in the dependencies. Even if the value is changed here, lightningcss will still not be downloaded.

@zkochan

zkochan commented Sep 24, 2026

Copy link
Copy Markdown
Member

Closing in favor of a new fix that covers both the TypeScript and Rust CLIs. Thanks for the investigation, btea.

The test fixture here declares the dependency only in peerDependenciesMeta, so it skips the step that loses the dependency. vite's manifest lists lightningcss in peerDependencies too, and that is the case that fails. Marking the peer as required also installs it with the peer range (^1.21.0), not the dependency range (^1.28.2). The new fix keeps an optional peer that the package also depends on as a regular dependency, unless the parent already provides it.


Written by an agent (Claude Code, claude-opus-5-5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transitive dependencies not installed for pkg.pr.new

2 participants