-
-
Notifications
You must be signed in to change notification settings - Fork 107
fix: VSCode extension fails to resolve imports from npm packages in pnpm workspaces #1779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe pull request introduces modifications to the Changes
Assessment against linked issues
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/schema/src/utils/ast-utils.ts (1)
187-196
: LGTM: Import resolution logic improved.The changes enhance the handling of import paths, particularly for npm packages in pnpm workspaces. The use of
path.isAbsolute()
is consistent with the updated import statement, and the added context path improves the resolution of relative imports.The console log statement provides useful debugging information, which is helpful for traceability.
Consider adding error handling for the case where
imp.$container.$document
is undefined:const contextPath = imp.$container.$document - ? path.dirname(imp.$container.$document.uri.fsPath) - : process.cwd(); + ? path.dirname(imp.$container.$document.uri.fsPath) + : (() => { + console.warn('Document URI not available, falling back to current working directory'); + return process.cwd(); + })();This change would provide more context if the document URI is unexpectedly unavailable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/schema/src/utils/ast-utils.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
packages/schema/src/utils/ast-utils.ts (2)
33-33
: LGTM: Import statement updated correctly.The change to use a default import with the
node:
prefix for thepath
module aligns with best practices for Node.js built-in modules.To ensure consistency, let's verify the usage of
path
methods throughout the file:✅ Verification successful
Verified:
path
methods are used correctly throughout the file.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining named imports of 'path' and verify correct usage of path methods rg --type typescript 'path\.' packages/schema/src/utils/ast-utils.tsLength of output: 105
Script:
#!/bin/bash # Description: Check for any remaining named imports of 'path' and verify correct usage of path methods rg --glob '*.ts' 'path\.' packages/schema/src/utils/ast-utils.tsLength of output: 295
Line range hint
1-332
: Verification: No other changes detected.I've reviewed the entire file, and no other changes were detected beyond the import statement and the
resolveImportUri
function modifications.To ensure we haven't missed any changes, let's run a final verification:
This command will show any additions or deletions in the file, helping us catch any overlooked modifications.
Fixes #1760 #1627