Repository navigation
fix: hoist shared devDeps, remove unused deps, add knip config - #3
Conversation
Bundle Size Report
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (25)
📝 WalkthroughWalkthroughRemoved CommonJS outputs and mappings across the monorepo, pruned devDependencies, added a dependency-audit e2e test, introduced knip configuration for unused-dependency detection, adjusted turbo tasks, and made several CLI color helpers internal. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
e2e/dependency-audit.test.ts (3)
23-43: Consider consolidating repeatedreadPkgcalls within each test group.The tests for
@workkit/cacheand@workkit/cryptoeach callreadPkgtwice for the same package. This can be consolidated for efficiency and reduced I/O.♻️ Consolidated test structure example
describe('unused runtime dependencies are removed', () => { - it('@workkit/cache has no `@workkit/types` in dependencies', () => { - const pkg = readPkg('packages/cache') - expect(pkg.dependencies ?? {}).not.toHaveProperty('@workkit/types') - }) - - it('@workkit/cache has no `@workkit/errors` in dependencies', () => { + it('@workkit/cache has no `@workkit/types` or `@workkit/errors` in dependencies', () => { const pkg = readPkg('packages/cache') + expect(pkg.dependencies ?? {}).not.toHaveProperty('@workkit/types') expect(pkg.dependencies ?? {}).not.toHaveProperty('@workkit/errors') }) - it('@workkit/crypto has no `@workkit/types` in dependencies', () => { - const pkg = readPkg('packages/crypto') - expect(pkg.dependencies ?? {}).not.toHaveProperty('@workkit/types') - }) - - it('@workkit/crypto has no `@workkit/errors` in dependencies', () => { + it('@workkit/crypto has no `@workkit/types` or `@workkit/errors` in dependencies', () => { const pkg = readPkg('packages/crypto') + expect(pkg.dependencies ?? {}).not.toHaveProperty('@workkit/types') expect(pkg.dependencies ?? {}).not.toHaveProperty('@workkit/errors') }) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/dependency-audit.test.ts` around lines 23 - 43, In the "unused runtime dependencies are removed" tests, avoid calling readPkg twice per package; for each package (packages/cache and packages/crypto) call readPkg once and reuse the returned pkg variable in the two assertions. Locate the describe block and update the tests that reference readPkg('packages/cache') and readPkg('packages/crypto') so each it(...) first assigns const pkg = readPkg(...) and then performs expect(pkg.dependencies ?? {}).not.toHaveProperty(...) for both '@workkit/types' and '@workkit/errors'.
57-67: Same consolidation opportunity for remix tests.Similar to the cache/crypto tests, these two tests read the same
package.jsonseparately.♻️ Consolidated remix test
describe('@standard-schema/spec is a peerDep in remix, not a dep', () => { - it('@workkit/remix has `@standard-schema/spec` in peerDependencies', () => { - const pkg = readPkg('integrations/remix') - expect(pkg.peerDependencies).toHaveProperty('@standard-schema/spec') - }) - - it('@workkit/remix does not have `@standard-schema/spec` in dependencies', () => { + it('@workkit/remix has `@standard-schema/spec` in peerDependencies, not dependencies', () => { const pkg = readPkg('integrations/remix') + expect(pkg.peerDependencies).toHaveProperty('@standard-schema/spec') expect(pkg.dependencies ?? {}).not.toHaveProperty('@standard-schema/spec') }) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/dependency-audit.test.ts` around lines 57 - 67, The two tests under the describe block repeatedly call readPkg('integrations/remix'); consolidate by calling readPkg once (e.g., in a beforeAll or at the top of the describe) and reusing the resulting pkg for both assertions; update the tests that currently call readPkg (the it blocks checking expect(pkg.peerDependencies).toHaveProperty('@standard-schema/spec') and expect(pkg.dependencies ?? {}).not.toHaveProperty('@standard-schema/spec')) to use the shared pkg variable instead.
5-8: Consider usingimport.metafor ESM compatibility.
__dirnameis a CommonJS global not natively available in ESM modules. While Vitest's transformation typically provides it, this creates an implicit dependency on the test runner's behavior. For explicit ESM compatibility:♻️ Suggested ESM-native approach
import { describe, it, expect } from 'vitest' import { readFileSync } from 'fs' import path from 'path' +import { fileURLToPath } from 'url' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) function readPkg(relPath: string) { const full = path.resolve(__dirname, '..', relPath, 'package.json') return JSON.parse(readFileSync(full, 'utf-8')) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/dependency-audit.test.ts` around lines 5 - 8, The readPkg function uses the CommonJS __dirname which breaks in ESM; change it to derive the test file directory from import.meta.url by using fileURLToPath(import.meta.url) and path.dirname, then build the package.json path (replace the path.resolve(__dirname, ...) call in readPkg). Also add the import for fileURLToPath from 'url' at the top of the module and ensure readPkg still returns JSON.parse(readFileSync(full, 'utf-8')).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@knip.json`:
- Around line 8-9: The entry configuration currently includes "src/*.ts" which
is too broad and prevents dead-code detection; update the knip.json so that
"entry" only lists true public/runtime roots (keep "src/index.ts" but remove
"src/*.ts") and move implementation patterns like "src/*.ts" into the "project"
array (e.g., ensure "project" contains "src/**/*.ts" and/or "src/*.ts") so
per-file implementation files (client.ts, fallback.ts, retry.ts, stream.ts,
tokens.ts) are treated as project sources not entry roots.
---
Nitpick comments:
In `@e2e/dependency-audit.test.ts`:
- Around line 23-43: In the "unused runtime dependencies are removed" tests,
avoid calling readPkg twice per package; for each package (packages/cache and
packages/crypto) call readPkg once and reuse the returned pkg variable in the
two assertions. Locate the describe block and update the tests that reference
readPkg('packages/cache') and readPkg('packages/crypto') so each it(...) first
assigns const pkg = readPkg(...) and then performs expect(pkg.dependencies ??
{}).not.toHaveProperty(...) for both '@workkit/types' and '@workkit/errors'.
- Around line 57-67: The two tests under the describe block repeatedly call
readPkg('integrations/remix'); consolidate by calling readPkg once (e.g., in a
beforeAll or at the top of the describe) and reusing the resulting pkg for both
assertions; update the tests that currently call readPkg (the it blocks checking
expect(pkg.peerDependencies).toHaveProperty('@standard-schema/spec') and
expect(pkg.dependencies ?? {}).not.toHaveProperty('@standard-schema/spec')) to
use the shared pkg variable instead.
- Around line 5-8: The readPkg function uses the CommonJS __dirname which breaks
in ESM; change it to derive the test file directory from import.meta.url by
using fileURLToPath(import.meta.url) and path.dirname, then build the
package.json path (replace the path.resolve(__dirname, ...) call in readPkg).
Also add the import for fileURLToPath from 'url' at the top of the module and
ensure readPkg still returns JSON.parse(readFileSync(full, 'utf-8')).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d090b191-e6d2-432e-af3d-b67d7da4c393
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (46)
e2e/dependency-audit.test.tsintegrations/astro/bunup.config.tsintegrations/astro/package.jsonintegrations/hono/bunup.config.tsintegrations/hono/package.jsonintegrations/remix/bunup.config.tsintegrations/remix/package.jsonknip.jsonpackages/ai-gateway/bunup.config.tspackages/ai-gateway/package.jsonpackages/ai/bunup.config.tspackages/ai/package.jsonpackages/api/bunup.config.tspackages/api/package.jsonpackages/auth/bunup.config.tspackages/auth/package.jsonpackages/cache/bunup.config.tspackages/cache/package.jsonpackages/cli/bunup.config.tspackages/cli/package.jsonpackages/cli/src/utils.tspackages/cron/bunup.config.tspackages/cron/package.jsonpackages/crypto/bunup.config.tspackages/crypto/package.jsonpackages/d1/bunup.config.tspackages/d1/package.jsonpackages/do/bunup.config.tspackages/do/package.jsonpackages/env/bunup.config.tspackages/env/package.jsonpackages/errors/bunup.config.tspackages/errors/package.jsonpackages/kv/bunup.config.tspackages/kv/package.jsonpackages/queue/bunup.config.tspackages/queue/package.jsonpackages/r2/bunup.config.tspackages/r2/package.jsonpackages/ratelimit/bunup.config.tspackages/ratelimit/package.jsonpackages/testing/bunup.config.tspackages/testing/package.jsonpackages/types/bunup.config.tspackages/types/package.jsonturbo.json
💤 Files with no reviewable changes (3)
- packages/d1/package.json
- packages/queue/package.json
- packages/testing/package.json
- Remove `expect-type` from 18 packages (never used in any test file) - Hoist typescript, vitest, @cloudflare/workers-types, bunup to root package.json only (bun workspaces provides them to all packages) - Remove `export` from red/green/yellow/blue in packages/cli/src/utils.ts (only used internally by success/warn/error/info functions) - Add knip.json for ongoing dead code detection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The audit incorrectly flagged expect-type as unused. It's actually imported in 14 test files across 9 packages (api, cron, do, queue, ratelimit, types, astro, hono). Adding to root since devDeps were hoisted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove "src/*.ts" from entry — it was treating all top-level source files as entry points, preventing dead code detection. Implementation files (client.ts, retry.ts, etc.) are already covered by "project": ["src/**/*.ts"]. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a757602 to
5c7f46a
Compare
Summary
expect-typefrom 18 workspace packages (never imported in any test file)typescript,vitest,@cloudflare/workers-types, andbunupto rootpackage.jsononly — bun workspaces makes root devDeps available to all packages, eliminating duplication across 21 packagesexportkeyword fromred,green,yellow,blueinpackages/cli/src/utils.ts— these are only used internally bysuccess(),warn(),error(),info()functionsknip.jsonat project root for ongoing dead code detectione2e/dependency-audit.test.tsfor structural validation of dependency declarationsTest plan
bun install— lockfile regenerated successfullybun run typecheck— 25/25 tasks passbun run build— 21/21 tasks passbun run test— 21/21 tasks passbunx knip— runs with new config, fewer false positives🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
New Features
Chores