fix(config,vitest-environment): directly import peerDeps#1617
fix(config,vitest-environment): directly import peerDeps#1617
Conversation
|
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. 📝 WalkthroughWalkthroughAdds Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 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)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/environments/vitest/env/jsdom.ts (1)
7-7: Add error handling for missingjsdomoptional peer dependency to match the existing pattern used for other optional peers (likeplaywright-coreinsrc/e2e/browser.ts).At Line 7, wrap the import in a try-catch block and throw a descriptive error with installation guidance if the module is not found:
Proposed patch
- const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom') + let jsdomModule: typeof import('jsdom') + try { + jsdomModule = await import('jsdom') + } + catch (error) { + throw new Error( + 'Missing optional peer dependency "jsdom". Install it in your project (e.g. `pnpm add -D jsdom`).', + { cause: error as Error }, + ) + } + const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = jsdomModuleNote:
src/environments/vitest/env/happy-dom.tshas the same issue and should receive the same treatment.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/environments/vitest/env/jsdom.ts` at line 7, Wrap the dynamic import of jsdom in a try-catch so missing optional peer dependency is handled: replace the direct await import('jsdom') that destructures CookieJar, JSDOM, ResourceLoader, VirtualConsole with a try block and in catch throw a descriptive Error advising to install jsdom (e.g. "jsdom is required for this environment — install with `npm i -D jsdom`"), preserving original variable names (CookieJar, JSDOM, ResourceLoader, VirtualConsole) for use after the import; apply the identical try-catch pattern to the similar import in the happy-dom environment file as well.pnpm-workspace.yaml (1)
22-22: Document the rationale forignoreWorkspaceRootCheck: trueto prevent accidental root-level dependency drift.At Line 22, disabling this guard allows
pnpm add ...to modify the workspace rootpackage.jsonwithout the explicit-w/--workspace-rootflag. While this reduces friction if root-level tooling dependencies are intentional, it increases the risk of silently accumulating dependencies that should be scoped to specific packages, weakening workspace boundaries. Add a comment inpnpm-workspace.yamlor update contributing docs to clarify why this is disabled.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pnpm-workspace.yaml` at line 22, Add a short rationale near the existing setting by commenting why ignoreWorkspaceRootCheck: true is enabled: state that it permits intentional root-level tooling installs (e.g., CI/tools) and that contributors should prefer package-scoped dependencies unless adding global workspace tools; also reference the contributing docs where you describe the policy and the required use of -w/--workspace-root when adding root deps. Update the pnpm-workspace.yaml to include this explanatory comment adjacent to ignoreWorkspaceRootCheck: true and add or update the contributing guide section on workspace root dependency policy to prevent accidental root-level dependency drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pnpm-workspace.yaml`:
- Line 22: Add a short rationale near the existing setting by commenting why
ignoreWorkspaceRootCheck: true is enabled: state that it permits intentional
root-level tooling installs (e.g., CI/tools) and that contributors should prefer
package-scoped dependencies unless adding global workspace tools; also reference
the contributing docs where you describe the policy and the required use of
-w/--workspace-root when adding root deps. Update the pnpm-workspace.yaml to
include this explanatory comment adjacent to ignoreWorkspaceRootCheck: true and
add or update the contributing guide section on workspace root dependency policy
to prevent accidental root-level dependency drift.
In `@src/environments/vitest/env/jsdom.ts`:
- Line 7: Wrap the dynamic import of jsdom in a try-catch so missing optional
peer dependency is handled: replace the direct await import('jsdom') that
destructures CookieJar, JSDOM, ResourceLoader, VirtualConsole with a try block
and in catch throw a descriptive Error advising to install jsdom (e.g. "jsdom is
required for this environment — install with `npm i -D jsdom`"), preserving
original variable names (CookieJar, JSDOM, ResourceLoader, VirtualConsole) for
use after the import; apply the identical try-catch pattern to the similar
import in the happy-dom environment file as well.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3daf8177-ec84-48a4-a061-fbd6ac725862
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
pnpm-workspace.yamlsrc/environments/vitest/env/happy-dom.tssrc/environments/vitest/env/jsdom.tssrc/vitest-wrapper/cli.ts
# Conflicts: # src/environments/vitest/env/jsdom.ts
commit: |
🔗 Linked issue
📚 Description
this aims to resolve issues with pnpm's https://pnpm.io/11.x/global-virtual-store and importing 'unexpectedly' a dependency that hasn't been declared with a peerDep entry.