Skip to content

chore: set up Knip - #506

Merged
antfu merged 2 commits into
mainfrom
chore/setup-knip
Aug 3, 2026
Merged

chore: set up Knip#506
antfu merged 2 commits into
mainfrom
chore/setup-knip

Conversation

@antfubot

@antfubot antfubot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds Knip to find unused files, dependencies and exports across the workspace.

  • Adds knip to the devtools catalog and a root knip script (pnpm knip).
  • Adds knip.jsonc, tuned for this repo's monorepo structure:
    • Per-workspace entry overrides only where they're not already covered by package.json#exports/bin (which Knip resolves back to source via sourcemaps) — e.g. the standalone client dev app in packages/core, webext's flat src/*.ts build, and the examples' playground/ dev apps.
    • nuxt/unocss config path overrides for packages/{oxc,rolldown,vite}, whose Nuxt apps live nested under src/ (srcDir: 'app') rather than at the workspace root.
    • ignoreFiles for fixtures/snapshots, plus the packages/{oxc,rolldown,vite}/src/app/** Nuxt app trees — Knip's Nuxt plugin registers its component/composable auto-import compilers relative to the workspace root rather than the resolved nuxt.config location, so anything consumed only via Nuxt's auto-import (template tags, unimport) in these nested apps can't be traced back to source and is misreported as unused. src/node/**, src/modules/** and src/shared/** are unaffected.
  • Fixes the handful of dependency-hygiene issues Knip's plugin detection surfaced along the way:
    • packages/rolldown and packages/vite invoke the nuxi CLI in their own build scripts without declaring nuxt.
    • packages/core's standalone client imports unocss/vite without declaring unocss.
    • packages/ui uses @floating-ui/dom without declaring it — added as a peerDependency, matching its other UI peer deps.
  • Wires a Knip step into CI (non-blocking via continue-on-error, since the repo has pre-existing findings — see below).

With this config, Knip reports a clean, structural baseline plus a small set of real, pre-existing findings left for a follow-up cleanup pass rather than folded into this setup PR: 2 dead files, 70 unused devDependencies, 82 unlisted dependencies, 53 unused exports, 44 unused exported types, 1 duplicate export, 1 unresolved import, 2 unlisted binaries, and 6 unused catalog entries.

Linked Issues

Additional context

Run pnpm knip to see the current findings. Once they're triaged (fixed or added to ignore*/ignoreFiles), the CI step's continue-on-error: true can be dropped to make it blocking.


This PR was created with the help of an agent.

Add Knip (https://knip.dev) to find unused files, dependencies and
exports across the workspace.

- Add knip as a devtools catalog dependency and a `knip` root script.
- Add knip.jsonc tuned for this monorepo's structure: per-workspace
  entry overrides for build entries not covered by package.json
  exports/bin, nuxt.config/uno.config paths for the packages/{oxc,
  rolldown,vite} Nuxt apps nested under src/, and ignoreFiles for
  fixtures/snapshots and Nuxt auto-import trees that Knip's Nuxt
  plugin can't trace back to source given the nested srcDir layout.
- Fix the dependency-hygiene issues Knip's plugin detection surfaced
  along the way: packages/rolldown and packages/vite use the nuxi CLI
  without declaring nuxt; packages/core imports unocss/vite without
  declaring unocss; packages/ui uses @floating-ui/dom without
  declaring it (as a peerDependency, matching its other UI peers).
- Wire a non-blocking Knip step into CI so findings surface in every
  build; flipping it to blocking is a follow-up once the existing
  findings below are triaged.

Knip now reports a small set of real, pre-existing findings (2 dead
files, 70 unused devDependencies, 82 unlisted dependencies, 53 unused
exports, 44 unused exported types, 1 duplicate export, 1 unresolved
import, 2 unlisted binaries, 6 unused catalog entries) — left as-is
for a follow-up cleanup pass rather than folded into this setup.

This PR was created with the help of an agent.
@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@506

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@506

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@506

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@506

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@506

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@506

commit: e50cdb9

@antfu
antfu merged commit 393a136 into main Aug 3, 2026
10 checks passed
@antfu
antfu deleted the chore/setup-knip branch August 3, 2026 06:07
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.

2 participants