-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: import resolve find in paths's node_modules #35
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request introduces an enhancement to the Changes
Sequence DiagramsequenceDiagram
participant Resolver as Module Resolver
participant NodeModules as node_modules Directory
participant DebugLogger as Debug Logger
Resolver->>NodeModules: Attempt to resolve module path
alt Module Found
NodeModules-->>Resolver: Return module file path
Resolver->>DebugLogger: Log resolution details
else Module Not Found
Resolver->>Resolver: Continue with existing resolution logic
end
Possibly related PRs
Poem
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 (
|
commit: |
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
🧹 Nitpick comments (2)
src/import.ts (1)
205-215
: Well-structured extension for node_modules resolution
The loop correctly attempts to resolve the requested module fromnode_modules
paths. It short-circuits once a valid file is found, meeting the PR objective of enhanced import resolution.You might also consider gracefully handling cases where
node_modules
may not exist or be inaccessible, e.g., checking its presence before attempting resolution, to optimize performance and error handling further.test/import.test.ts (1)
30-34
: Test coverage for CommonJS module resolution
This test case effectively verifies loading a CommonJS package from{paths}/node_modules
.A negative test scenario (e.g., module not found in
node_modules
) could further strengthen test coverage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
test/fixtures/cjs/node_modules/inject/index.js
is excluded by!**/node_modules/**
test/fixtures/cjs/node_modules/inject/package.json
is excluded by!**/node_modules/**
test/fixtures/esm/node_modules/inject/index.js
is excluded by!**/node_modules/**
test/fixtures/esm/node_modules/inject/package.json
is excluded by!**/node_modules/**
📒 Files selected for processing (2)
src/import.ts
(1 hunks)test/import.test.ts
(2 hunks)
🔇 Additional comments (1)
test/import.test.ts (1)
58-62
: Test coverage for ESM module resolution
This test ensures that an ESM package can also be successfully resolved from {paths}/node_modules
, paralleling the CommonJS flow.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
==========================================
- Coverage 89.78% 87.50% -2.29%
==========================================
Files 6 6
Lines 685 696 +11
Branches 120 120
==========================================
- Hits 615 609 -6
- Misses 70 87 +17 ☔ View full report in Codecov by Sentry. |
[skip ci] ## [4.2.2](v4.2.1...v4.2.2) (2024-12-30) ### Bug Fixes * import resolve find in paths's node_modules ([#35](#35)) ([bd772af](bd772af))
Summary by CodeRabbit
New Features
node_modules
directoryTests