Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Jun 5, 2025

Important

Fix file caching issue by removing incorrect condition in ResolverGeneric::require and add test for extension aliasing.

  • Behavior:
    • Remove condition in ResolverGeneric::require in src/lib.rs that returned cached paths without considering extension aliases.
    • Add test case in extension_alias.rs to verify correct resolution of .js to .ts and .d.ts using extension aliases.
  • Setup:
    • Add yarn fixture with .gitignore, .yarnrc.yml, and package.json for testing purposes.
    • Update action.yml and justfile to include yarn installation steps.

This description was created by Ellipsis for 2744c26. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features
    • Added a new project fixture using Yarn with custom configuration and dependencies.
  • Bug Fixes
    • Improved module resolution to better handle extension aliasing for nested module paths.
  • Tests
    • Expanded test coverage for extension aliasing to verify correct resolution of .js to .ts and .d.ts files in the new Yarn fixture.
  • Chores
    • Updated installation scripts and workflows to support the new Yarn-based fixture setup.

@JounQin JounQin requested a review from Copilot June 5, 2025 18:41
@JounQin JounQin self-assigned this Jun 5, 2025
@JounQin JounQin added the bug Something isn't working label Jun 5, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 5, 2025

Walkthrough

The changes introduce a new fixtures/yarn directory with configuration files and a package manifest. The installation process in both the GitHub Actions workflow and the justfile is updated to include this directory. The resolver logic is slightly modified, and a new test case is added to verify extension aliasing behavior for module resolution.

Changes

Files/Groups Change Summary
.github/actions/pnpm/action.yml, justfile Updated to include running yarn install in the new fixtures/yarn directory as part of the installation steps.
fixtures/yarn/.gitignore, .yarnrc.yml, package.json Added new directory with configuration for Yarn, including .gitignore, Yarn settings, and a package.json for testing.
src/lib.rs Modified resolver logic to always attempt file loading with extensions, removing an early return when certain conditions met.
src/tests/extension_alias.rs Added a new test case verifying extension aliasing for .js to .ts/.d.ts in nested module resolution under fixtures/yarn.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner as Test Runner
    participant Resolver as Resolver
    participant FileSystem as File System

    TestRunner->>Resolver: resolve("typescript/lib/typescript.js", root="fixtures/yarn")
    Resolver->>FileSystem: check for typescript.js
    alt .js extension aliasing enabled
        Resolver->>FileSystem: check for typescript.d.ts
        alt typescript.d.ts exists
            Resolver-->>TestRunner: return path to typescript.d.ts
        else typescript.d.ts does not exist
            Resolver->>FileSystem: check for typescript.ts
            alt typescript.ts exists
                Resolver-->>TestRunner: return path to typescript.ts
            else
                Resolver-->>TestRunner: resolution failed
            end
        end
    else
        Resolver-->>TestRunner: return path to typescript.js or fail
    end
Loading

Poem

In the yarn-filled warren, new configs appear,
Installers now hop to a fresh directory near.
The resolver sniffs deeper, no shortcuts allowed,
While aliasing extensions makes this rabbit quite proud.
With each test case added, our garden grows bright—
Hopping forward in code, everything feels right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 5, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that extension aliases are always considered by removing a premature file-cache shortcut, and it adds a Yarn‐based fixture with tests and CI updates to validate .js.d.ts resolution.

  • Removed the early return in lib.rs so extension_alias is applied even when a file exists.
  • Introduced a new Yarn fixture under fixtures/yarn and a corresponding test for .js.d.ts.
  • Updated build scripts (justfile and GitHub Actions) to install the new fixture.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib.rs Removed shortcut is_file check to allow extension_alias logic
src/tests/extension_alias.rs Added test for .js.d.ts resolution with multiple aliases
justfile Added cd fixtures/yarn && yarn to the install recipe
fixtures/yarn/package.json New fixture’s package.json
fixtures/yarn/.yarnrc.yml Yarn config for the fixture
fixtures/yarn/.gitignore Gitignore for the fixture
.github/actions/pnpm/action.yml CI updated to run yarn install in fixtures/yarn
Comments suppressed due to low confidence (2)

src/lib.rs:843

  • Consider restoring a fast path that skips load_as_file only when neither alias_fields nor extension_alias is configured, to avoid extra filesystem checks when no aliases are in use.
if self.options.alias_fields.is_empty() && self.cache.is_file(&cached_path, ctx) {

src/tests/extension_alias.rs:38

  • [nitpick] Consider adding a test case where a .js file resolves to .ts when it exists, to verify that the first alias in the list is preferred.
extension_alias: vec![(".js".into(), vec![".ts".into(), ".d.ts".into()])],

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 2744c26 in 1 minute and 12 seconds. Click for details.
  • Reviewed 89 lines of code in 7 files
  • Skipped 2 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. .github/actions/pnpm/action.yml:37
  • Draft comment:
    New yarn install steps for fixtures/global-pnp and fixtures/yarn added. Ensure these directories exist in all environments.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to ensure that certain directories exist in all environments. This falls under the rule of not asking the author to ensure something is tested or verified, which is not allowed.
2. justfile:15
  • Draft comment:
    Added 'cd fixtures/yarn && yarn' in install target. Verify it aligns with your project setup.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. src/lib.rs:315
  • Draft comment:
    Removed early return caching logic for alias_fields; ensure this fix correctly prevents caching of invalid files without impacting performance on resolutions without aliasing.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. src/tests/extension_alias.rs:20
  • Draft comment:
    Extension alias tests look comprehensive. They verify both successful alias resolution and proper error when fallback isn’t allowed.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_v1i7WVm7QXsFMyzG

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
fixtures/yarn/.gitignore (1)

1-2: Unignore release files properly
The pattern !.yarn/releases re-includes the directory but not its contents. To ensure the release binaries (e.g., .cjs files) are tracked, update to:

!.yarn/releases/
!.yarn/releases/*.cjs
fixtures/yarn/package.json (1)

1-7: Add version and private fields
Yarn expects a version field and adding "private": true prevents accidental publishes. Consider:

{
  "name": "extension-alias",
+ "version": "0.0.0",
+ "private": true,
  "packageManager": "[email protected]",
  "devDependencies": {
    "typescript": "^5.8.3"
  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 934bb46 and 2744c26.

⛔ Files ignored due to path filters (2)
  • fixtures/yarn/.yarn/releases/yarn-4.9.2.cjs is excluded by !**/.yarn/**
  • fixtures/yarn/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (7)
  • .github/actions/pnpm/action.yml (1 hunks)
  • fixtures/yarn/.gitignore (1 hunks)
  • fixtures/yarn/.yarnrc.yml (1 hunks)
  • fixtures/yarn/package.json (1 hunks)
  • justfile (1 hunks)
  • src/lib.rs (0 hunks)
  • src/tests/extension_alias.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • src/lib.rs
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: JounQin
PR: unrs/unrs-resolver#75
File: fixtures/pnp/package.json:11-14
Timestamp: 2025-04-21T08:11:41.469Z
Learning: The project uses a justfile with an `install` task that includes running yarn in the fixtures/pnp directory to install dependencies with the command: `cd fixtures/pnp && yarn`.
justfile (2)
Learnt from: JounQin
PR: unrs/unrs-resolver#75
File: fixtures/pnp/package.json:11-14
Timestamp: 2025-04-21T08:11:41.469Z
Learning: The project uses a justfile with an `install` task that includes running yarn in the fixtures/pnp directory to install dependencies with the command: `cd fixtures/pnp && yarn`.
Learnt from: JounQin
PR: unrs/unrs-resolver#40
File: src/tests/resolve.rs:121-136
Timestamp: 2025-03-29T04:14:03.715Z
Learning: For tests involving npm/yarn package resolution in the unrs-resolver project, dependencies must be installed first using the appropriate package manager commands (pnpm i, yarn) in both the root directory and fixture directories like fixtures/pnp and fixtures/misc/nested-package-json.
.github/actions/pnpm/action.yml (2)
Learnt from: JounQin
PR: unrs/unrs-resolver#75
File: fixtures/pnp/package.json:11-14
Timestamp: 2025-04-21T08:11:41.469Z
Learning: The project uses a justfile with an `install` task that includes running yarn in the fixtures/pnp directory to install dependencies with the command: `cd fixtures/pnp && yarn`.
Learnt from: JounQin
PR: unrs/unrs-resolver#40
File: src/tests/resolve.rs:121-136
Timestamp: 2025-03-29T04:14:03.715Z
Learning: For tests involving npm/yarn package resolution in the unrs-resolver project, dependencies must be installed first using the appropriate package manager commands (pnpm i, yarn) in both the root directory and fixture directories like fixtures/pnp and fixtures/misc/nested-package-json.
🧬 Code Graph Analysis (1)
src/tests/extension_alias.rs (2)
src/options.rs (1)
  • default (476-502)
src/tests/mod.rs (1)
  • fixture_root (32-34)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
justfile (1)

19-19: Align with fixture installation pattern
Adding cd fixtures/yarn && yarn mirrors the existing steps for other fixtures and ensures local environments are correctly prepared.

.github/actions/pnpm/action.yml (1)

39-41: Include Yarn fixture in CI installs
The new cd ../yarn && yarn install step ensures that the fixtures/yarn dependencies are installed during CI, aligning with the local justfile.

fixtures/yarn/.yarnrc.yml (1)

1-4: Pin Yarn and enforce node-modules linker
The .yarnrc.yml correctly configures nodeLinker: node-modules and points yarnPath to the pinned release .yarn/releases/yarn-4.9.2.cjs, guaranteeing consistent installs.

@codecov
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.39%. Comparing base (934bb46) to head (2744c26).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #136      +/-   ##
==========================================
- Coverage   93.40%   93.39%   -0.01%     
==========================================
  Files          13       13              
  Lines        2894     2890       -4     
==========================================
- Hits         2703     2699       -4     
  Misses        191      191              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 5, 2025

CodSpeed Performance Report

Merging #136 will not alter performance

Comparing fix/incorrect_file_cache (2744c26) with main (934bb46)

Summary

✅ 3 untouched benchmarks

@JounQin JounQin merged commit 1bfa253 into main Jun 5, 2025
22 checks passed
@JounQin JounQin deleted the fix/incorrect_file_cache branch June 5, 2025 19:00
@JounQin JounQin mentioned this pull request Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants