-
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: try resolve by file no matter dir exists or not #30
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning Rate limit exceeded@fengmk2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 54 seconds before requesting another review. ⌛ 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. 📒 Files selected for processing (1)
WalkthroughThe pull request introduces modifications to the module resolution process in Changes
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: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #30 +/- ##
==========================================
+ Coverage 87.27% 88.34% +1.06%
==========================================
Files 6 6
Lines 605 609 +4
Branches 95 100 +5
==========================================
+ Hits 528 538 +10
+ Misses 77 71 -6 ☔ View full report in Codecov by Sentry. |
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 (3)
src/import.ts (2)
165-169
: Ensure consistent fallback logic when resolving files.
You calltryToResolveByDirname
first, thentryToResolveFromFile
. Consider clarifying what happens if the file name also happens to be a directory or if multiple matches exist. Documenting this behavior would help future maintainers.
173-181
: Consider potential ESM JSON imports.
Currently, JSON is exclusively resolved viarequire
if not absolute or if the environment is CommonJS. As of Node 20, ESM supports JSON imports without experimental flags. If you want broader future-proofing, consider allowing ESM’s native JSON import.test/import.test.ts (1)
38-40
: Excellent check for default.js
resolution.
This test ensures that a directory path (/path/app
) correctly resolves to/path/app.js
. You could consider adding variants for.ts
or.mjs
to expand coverage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/import.ts
(1 hunks)test/fixtures/framework-egg-default/app.js
(1 hunks)test/fixtures/framework-egg-default/app/router.js
(1 hunks)test/import.test.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- test/fixtures/framework-egg-default/app.js
- test/fixtures/framework-egg-default/app/router.js
🔇 Additional comments (3)
src/import.ts (2)
154-157
: Check Node.js version compatibility for fs.statSync
with throwIfNoEntry
.
This option was introduced in newer Node.js versions—verify it won’t cause compatibility issues on older runtimes. Otherwise, the stat
object will be undefined on missing files, which you already handle with optional chaining.
182-182
: Watch out for Windows paths with file://
scheme.
If the resolved path is a Windows drive-based URL, it will start with file:///C:/...
. The current string check still works but might be fragile if node changes the scheme format in future releases.
test/import.test.ts (1)
32-36
: Good job adding coverage for JSON resolution.
These lines confirm correct path resolution to egg/package.json
. Including negative or edge cases (e.g., non-existent JSON) can further bolster test robustness.
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/[email protected] |
[skip ci] ## [4.1.4](v4.1.3...v4.1.4) (2024-12-25) ### Bug Fixes * try resolve by file no matter dir exists or not ([#30](#30)) ([4605e3a](4605e3a))
Summary by CodeRabbit
app.js
androuter.js
for future enhancements.importResolve()
to verify functionality withpackage.json
and file path resolutions.package.json
.