Skip to content

fix: declare optional peer types#606

Merged
antfu merged 3 commits into
unjs:mainfrom
cyphercodes:fix-optional-peer-types
Jun 24, 2026
Merged

fix: declare optional peer types#606
antfu merged 3 commits into
unjs:mainfrom
cyphercodes:fix-optional-peer-types

Conversation

@cyphercodes

@cyphercodes cyphercodes commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the bundler/runtime packages referenced by unplugin's generated declaration files as optional peer dependencies, including the existing Bun type package.

This lets strict package managers surface the optional type packages instead of leaving consumers with unresolved imports from dist/index.d.mts.

Fixes #605

Test plan

  • pnpm run typecheck
  • pnpm run lint
  • pnpm test
  • git diff --check

Summary by CodeRabbit

  • Chores
    • Updated package dependency declarations to treat several build-tool libraries as optional peer dependencies.
    • Adjusted development tooling sourcing for type support and bundling to align with the updated optional peer dependency strategy.
    • Reorganized the workspace dependency catalog so optional vs. required relationships are reflected more accurately.
    • Updated the type-check configuration to ignore an unused warning for one type-support package.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3a39118-6adc-4ec0-96cd-01da4aab8e24

📥 Commits

Reviewing files that changed from the base of the PR and between 314c65d and b498739.

📒 Files selected for processing (2)
  • pnpm-workspace.yaml
  • tsdown.config.ts
💤 Files with no reviewable changes (1)
  • pnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (1)
  • tsdown.config.ts

📝 Walkthrough

Walkthrough

Updated dependency configurations to mark build tool types as optional peer dependencies. peerDependenciesMeta in package.json declares build tool peers as optional, bun-types-no-globals and esbuild are relocated from the dev catalog to the peer catalog in pnpm-workspace.yaml, and tsdown configuration excludes bun-types-no-globals from unused checks.

Changes

Optional Peer Dependencies for Build Tools

Layer / File(s) Summary
Declare optional peer dependencies in package.json
package.json
peerDependencies and peerDependenciesMeta entries mark @farmfe/core, @rspack/core, bun-types-no-globals, esbuild, rolldown, rollup, unloader, vite, and webpack as optional. devDependencies and esbuild resolutions for bun-types-no-globals and esbuild are updated to reference catalog:peer instead of catalog:dev.
Reorganize pnpm catalog structure
pnpm-workspace.yaml
bun-types-no-globals and esbuild are relocated within catalogs.dev.peer from their earlier position before eslint to immediately before rolldown.
Configure tsdown to ignore optional peer types
tsdown.config.ts
bun-types-no-globals is added to the unused.ignore list to exclude it from unused-check warnings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hopping through dependencies with care so deep,
Build tool types now marked as optional peer,
No stricter resolver's frown will make us weep,
Types cascade down when dev deps appear,
A cleaner config makes the vision clear! 🔧

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: declare optional peer types' directly describes the main change: declaring optional peer dependencies for type packages to resolve import failures.
Linked Issues check ✅ Passed All code changes comprehensively address issue #605 by declaring bundler/runtime type packages as optional peer dependencies and excluding unused type-only packages from linting.
Out of Scope Changes check ✅ Passed All changes are directly scoped to declaring optional peer dependencies and related configuration updates; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cyphercodes

Copy link
Copy Markdown
Contributor Author

Pushed a focused follow-up for the CI failures after the base merge:

  • removed duplicate unused dev catalog entries for bun-types-no-globals / esbuild
  • ignored bun-types-no-globals in unplugin-unused since it is an optional type-only peer package

Verified locally:

  • pnpm install --frozen-lockfile --ignore-scripts
  • pnpm run build
  • pnpm run typecheck
  • pnpm run lint
  • pnpm run test
  • git diff --check

@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unplugin@606

commit: b498739

@antfu antfu merged commit cc05acd into unjs:main Jun 24, 2026
11 checks passed
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.

missing optional peer

2 participants