Skip to content

test: add nested package json case #40

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

Merged
merged 3 commits into from
Mar 29, 2025
Merged

test: add nested package json case #40

merged 3 commits into from
Mar 29, 2025

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Mar 29, 2025

Summary by CodeRabbit

  • Chores

    • Introduced new configuration files for improved dependency management, including .gitignore, .yarnrc.yml, and multiple package.json files for nested packages.
    • Updated installation commands in the workflow to accommodate new nested package structures.
  • Tests

    • Added a new test case to validate the resolution of nested package dependencies.

Copy link

coderabbitai bot commented Mar 29, 2025

Walkthrough

This update introduces new configuration and package definition files for a nested package setup using Yarn. In the fixtures/misc/nested-package-json directory, .gitignore, .yarnrc.yml, and various package.json files are added to manage package dependencies, entry points, and Yarn settings. The fixtures/pnp/package.json file is updated to use Yarn 4.8.0, and the justfile now runs Yarn in the nested directory. Additionally, the pnpm-workspace.yaml configuration includes an ignored dependency, and a new test in src/tests/resolve.rs verifies path resolution in the nested structure.

Changes

File(s) Change Summary
fixtures/misc/nested-package-json/.gitignore
fixtures/misc/nested-package-json/.yarnrc.yml
New configuration files added. The .gitignore excludes the .yarn directory (except specific subdirectories), while .yarnrc.yml disables telemetry and sets nodeLinker to node-modules.
fixtures/misc/nested-package-json/package.json
fixtures/misc/nested-package-json/package/package.json
fixtures/misc/nested-package-json/package/nested/package.json
New package configuration files created for nested packages. They define package names, versions, entry points (main and types), and a local dependency link, with one file specifying Yarn as the package manager (v4.8.0).
fixtures/pnp/package.json Updated the packageManager field to use Yarn 4.8.0 (from 4.7.0).
justfile Added a command to navigate to the nested package directory and run Yarn as part of the installation process.
pnpm-workspace.yaml Introduced a new key ignoredBuiltDependencies listing esbuild as an ignored dependency during builds.
src/tests/resolve.rs Added a new test function, resolve_nested_dir_with_package_json, to assert accurate path resolution in a nested package JSON structure.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test (resolve_nested_dir_with_package_json)
    participant R as Resolver
    participant FS as Filesystem

    T->>R: Initialize Resolver with default options
    loop For each test case
        T->>R: Request resolution [path, request]
        R->>FS: Look up nested package.json configuration
        FS-->>R: Return resolved output path
        R-->>T: Provide resolved path
        T->>T: Assert equality with expected result
    end
Loading

Poem

I'm a little rabbit, hopping through code all day,
Skipping over .yarn files in a very neat array.
My paws tap on new configs and packages with glee,
As tests ensure each path is as right as can be.
With each command and key, I hop and I play,
Celebrating these changes in a bunny-coded ballet!
🐰✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8d3dd2 and 4cca871.

📒 Files selected for processing (1)
  • .github/actions/pnpm/action.yml (1 hunks)
🔇 Additional comments (2)
.github/actions/pnpm/action.yml (2)

31-37: Clarify the Yarn PnP Step.
The renaming to "yarn pnp" clearly indicates that this step handles a Yarn Plug'n'Play environment. The commands (changing to fixtures/pnp, enabling corepack, and running yarn install) are consistent and correctly set up the environment.


38-43: Add and Validate Nested Package JSON Installation Step.
The new "nested-package-json" step is properly configured to change into the nested directory (fixtures/misc/nested-package-json), enable corepack, and install dependencies via Yarn. This aligns with the PR objective of testing a nested package JSON setup. Consider verifying the directory structure exists at runtime or adding minimal error handling if the directory might be missing in some scenarios, although this is optional.


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 96e08b4 and c8d3dd2.

⛔ Files ignored due to path filters (2)
  • fixtures/misc/nested-package-json/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • fixtures/misc/nested-package-json/.gitignore (1 hunks)
  • fixtures/misc/nested-package-json/.yarnrc.yml (1 hunks)
  • fixtures/misc/nested-package-json/package.json (1 hunks)
  • fixtures/misc/nested-package-json/package/nested/package.json (1 hunks)
  • fixtures/misc/nested-package-json/package/package.json (1 hunks)
  • fixtures/pnp/package.json (1 hunks)
  • justfile (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
  • src/tests/resolve.rs (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/tests/resolve.rs (5)
src/tests/resolution.rs (1)
  • test (6-18)
src/tests/mod.rs (1)
  • fixture_root (31-33)
src/tests/tsconfig_paths.rs (5)
  • resolver (344-368)
  • default (316-340)
  • expected (151-151)
  • expected (176-176)
  • expected (210-210)
src/lib.rs (2)
  • new (150-157)
  • default (143-145)
src/options.rs (1)
  • default (461-487)
🪛 GitHub Actions: Code Coverage
src/tests/resolve.rs

[error] 134-134: Test failed: assertion left == right failed: normal entry '/home/runner/work/unrs-resolver/unrs-resolver/fixtures/misc/nested-package-json' @root/package left: Err(NotFound('@root/package')) right: Ok('/home/runner/work/unrs-resolver/unrs-resolver/fixtures/misc/nested-package-json/package/output/index.js')

🪛 GitHub Actions: CI
src/tests/resolve.rs

[error] 134-134: Test failed: assertion left == right failed: normal entry "D:\a\unrs-resolver\unrs-resolver\fixtures\misc/nested-package-json" @root/package left: Err(NotFound("@root/package")) right: Ok("D:\a\unrs-resolver\unrs-resolver\fixtures\misc/nested-package-json\package/output/index.js")

🔇 Additional comments (8)
fixtures/pnp/package.json (1)

3-3: Yarn Version Bump Verification

The update changes the packageManager field to "yarn@4.8.0". This bump ensures consistency with the nested package setup. Please verify that all related documentation and tooling support Yarn 4.8.0.

pnpm-workspace.yaml (1)

6-7: New Ignored Built Dependency Entry

The addition of ignoredBuiltDependencies with - esbuild is clear and helps prevent unnecessary build processing of esbuild. Verify that excluding esbuild does not affect any dependent build flows.

fixtures/misc/nested-package-json/.yarnrc.yml (1)

1-3: Yarn Configuration Setup

This new .yarnrc.yml disables telemetry and sets nodeLinker to node-modules, which aligns with typical local development setups. These settings appear appropriate for a nested package environment.

fixtures/misc/nested-package-json/package/nested/package.json (1)

1-4: Nested Package Entry Point Declaration

The package.json in the nested directory correctly specifies the "main" and "types" fields with relative paths. Please confirm that these paths ("../output/nested.js" and "../output/nested.d.ts") resolve correctly in your build and consumption workflows.

fixtures/misc/nested-package-json/.gitignore (1)

1-6: Refined .gitignore for Yarn Artifacts

The new .gitignore file properly excludes the general .yarn directory while whitelisting essential subdirectories (patches, plugins, releases, sdks, and versions). This configuration effectively balances between ignoring non-essential data and retaining necessary files.

fixtures/misc/nested-package-json/package.json (1)

1-7: LGTM: Basic package.json structure is correct

This package.json correctly defines the package name, package manager version, and has a dependency on a local package using the link protocol.

fixtures/misc/nested-package-json/package/package.json (1)

1-6: LGTM: Package configuration looks correct

This package.json correctly defines a scoped package with main entry point and TypeScript definition file paths.

justfile (1)

18-18: LGTM: Command added correctly

The command to install Yarn dependencies in the nested package json directory is correctly added to the install process.

Copy link

codecov bot commented Mar 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.38%. Comparing base (96e08b4) to head (4cca871).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #40   +/-   ##
=======================================
  Coverage   93.38%   93.38%           
=======================================
  Files          13       13           
  Lines        2827     2827           
=======================================
  Hits         2640     2640           
  Misses        187      187           

☔ 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.

@JounQin JounQin merged commit c0c056a into main Mar 29, 2025
15 checks passed
@JounQin JounQin deleted the fix/nested_pkg branch March 29, 2025 04:16
This was referenced Mar 29, 2025
JounQin pushed a commit that referenced this pull request Jun 10, 2025
## 🤖 New release

* `oxc_resolver`: 8.0.0 -> 9.0.0 (⚠ API breaking changes)
* `oxc_napi_resolver`: 8.0.0

### ⚠ `oxc_resolver` breaking changes

```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field ResolveOptions.modules in /tmp/.tmpTBvVad/oxc-resolver/src/options.rs:114

--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_added.ron

Failed in:
  trait method oxc_resolver::CachedPath::module_directory in file /tmp/.tmpTBvVad/oxc-resolver/src/cache.rs:69
  trait method oxc_resolver::CachedPath::cached_node_modules in file /tmp/.tmpTBvVad/oxc-resolver/src/cache.rs:76
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `oxc_resolver`

<blockquote>

##
[9.0.0](oxc-project/oxc-resolver@oxc_resolver-v8.0.0...oxc_resolver-v9.0.0)
- 2025-05-09

### <!-- 1 -->Bug Fixes

- hash import does not need to load from node_modules
([#501](oxc-project/oxc-resolver#501))

### <!-- 7 -->Chore

- add `--tsconfig` to example
([#505](oxc-project/oxc-resolver#505))
- publish `oxc_napi_resolver`
([#496](oxc-project/oxc-resolver#496))
</blockquote>

## `oxc_napi_resolver`

<blockquote>

##
[8.0.0](https://github.com/oxc-project/oxc-resolver/releases/tag/oxc_napi_resolver-v8.0.0)
- 2025-05-09

### <!-- 0 -->Features

- *(napi)* add mimalloc
([#423](oxc-project/oxc-resolver#423))
- [**breaking**] Rust Edition 2024
([#402](oxc-project/oxc-resolver#402))
- expose `package_json_path`
([#376](oxc-project/oxc-resolver#376))
- *(napi)* expose module type info in ResolveResult
([#223](oxc-project/oxc-resolver#223))
- *(napi)* add tracing via `OXC_LOG:DEBUG`
([#202](oxc-project/oxc-resolver#202))
- *(napi)* add async API
([#191](oxc-project/oxc-resolver#191))
- add `imports_fields` option
([#138](oxc-project/oxc-resolver#138))
- add more builder functions for options
([#110](oxc-project/oxc-resolver#110))
- *(napi)* support wasi target
([#31](oxc-project/oxc-resolver#31))
- add file_dependencies and missing_dependencies API
([#50](oxc-project/oxc-resolver#50))
- *(napi)* expose cloneWithOptions and clearCache methods
([#40](oxc-project/oxc-resolver#40))
- *(napi)* update the doc and type for tsconfig references
([#24](oxc-project/oxc-resolver#24))
- *(napi)* add options
([#19](oxc-project/oxc-resolver#19))
- *(resolver)* add tracing-subscriber feature
([#904](https://github.com/oxc-project/oxc-resolver/pull/904))
- *(resolver)* tsconfig project references
([#862](https://github.com/oxc-project/oxc-resolver/pull/862))
- *(resolver)* add thiserror
([#847](https://github.com/oxc-project/oxc-resolver/pull/847))
- *(resolver)* implement nested alias field
([#795](https://github.com/oxc-project/oxc-resolver/pull/795))
- *(resolver)* implement tsconfig-paths
([#750](https://github.com/oxc-project/oxc-resolver/pull/750))
- *(resolver)* implement configurable `exports_fields` option
([#733](https://github.com/oxc-project/oxc-resolver/pull/733))
- *(resolver)* implement `main_fields`
- *(resolver)* implement resolveToContext
([#694](https://github.com/oxc-project/oxc-resolver/pull/694))
- *(resolver)* implement restrictions (path only)
([#693](https://github.com/oxc-project/oxc-resolver/pull/693))
- *(resolver)* implement fully specified
([#687](https://github.com/oxc-project/oxc-resolver/pull/687))
- *(resolver)* imports field
([#681](https://github.com/oxc-project/oxc-resolver/pull/681))
- *(resolver)* finish most of exports field
([#674](https://github.com/oxc-project/oxc-resolver/pull/674))
- *(resolver)* port the rest of the exports field tests
([#659](https://github.com/oxc-project/oxc-resolver/pull/659))
- *(resolver)* implement symlinks
([#582](oxc-project/oxc-resolver#582))
- *(resolver)* complete query and fragment parsing
([#579](oxc-project/oxc-resolver#579))
- *(resolver)* add preferRelative and preferAbsolute
([#577](oxc-project/oxc-resolver#577))
- *(resolver)* implement roots
([#576](oxc-project/oxc-resolver#576))
- *(resolver)* implement fallback
([#572](oxc-project/oxc-resolver#572))
- *(resolver)* implement enforceExtension
([#566](oxc-project/oxc-resolver#566))
- *(resolver)* implement descriptionFiles option
([#565](oxc-project/oxc-resolver#565))
- *(resolver)* implement the basics of path alias
([#564](oxc-project/oxc-resolver#564))
- *(resolver)* accept different file system implementations
([#562](oxc-project/oxc-resolver#562))
- *(resolver)* implement browser field
([#561](oxc-project/oxc-resolver#561))
- *(resolver)* implement scoped packages
([#558](oxc-project/oxc-resolver#558))
- *(resolver)* port incorrect description file test
([#557](oxc-project/oxc-resolver#557))
- *(resolver)* implement extension_alias
([#556](oxc-project/oxc-resolver#556))
- *(resolver)* port resolve tests
([#555](oxc-project/oxc-resolver#555))
- *(resolver)* resolve extensions
([#549](oxc-project/oxc-resolver#549))
- *(resolver)* add resolver test fixtures
([#542](oxc-project/oxc-resolver#542))

### <!-- 1 -->Bug Fixes

- hash import does not need to load from node_modules
([#501](oxc-project/oxc-resolver#501))
- *(napi)* `new ResolverFactory()` options should be optional
([#256](oxc-project/oxc-resolver#256))
- *(napi)* update buggy NAPI-RS versions
([#225](oxc-project/oxc-resolver#225))
- canonicalize is not supported on wasi target
([#124](oxc-project/oxc-resolver#124))
- resolve "browser" field when "exports" is present
([#59](oxc-project/oxc-resolver#59))

### <!-- 4 -->Refactor

- [**breaking**] remove `description_files` option
([#488](oxc-project/oxc-resolver#488))
- [**breaking**] remove `modules` options
([#484](oxc-project/oxc-resolver#484))
- vitest ([#380](oxc-project/oxc-resolver#380))
- apply latest `cargo +nightly fmt`
([#281](oxc-project/oxc-resolver#281))
- selectively parse package_json fields instead of parsing everything
([#103](oxc-project/oxc-resolver#103))
- *(resolver)* clean up some code and tests
- *(resolver)* change internal funcs to non-pub by moving to unit tests
([#682](https://github.com/oxc-project/oxc-resolver/pull/682))

### <!-- 7 -->Chore

- publish `oxc_napi_resolver`
([#496](oxc-project/oxc-resolver#496))
- *(napi)* make mimalloc optional to build
([#495](oxc-project/oxc-resolver#495))
- *(README)* add wasm usage example
- *(README)* crates.io badge use recent downloads
- *(napi)* auto download wasm binding on webcontainer
([#471](oxc-project/oxc-resolver#471))
- use root package.json for napi build
([#469](oxc-project/oxc-resolver#469))
- *(deps)* update github-actions
([#444](oxc-project/oxc-resolver#444))
- *(deps)* lock file maintenance npm packages
([#436](oxc-project/oxc-resolver#436))
- bump napi
([#404](oxc-project/oxc-resolver#404))
- *(deps)* lock file maintenance npm packages
([#391](oxc-project/oxc-resolver#391))
- *(deps)* lock file maintenance rust crates
([#390](oxc-project/oxc-resolver#390))
- *(README)* clarify Rust and node.js usages
- add dprint
([#326](oxc-project/oxc-resolver#326))
- *(deps)* update napi-rs to 3.0.0-alpha
- `cargo upgrade` && `pnpm upgrade`
- *(deps)* update napi-rs to 3.0.0-alpha
- update napi changes
- *(deps)* update rust crate napi-derive to 3.0.0-alpha
- *(deps)* update rust crate napi to 3.0.0-alpha
- *(deps)* update napi-rs to 2.16.8
- *(napi)* make napi binary smaller with minimal tracing features
([#213](oxc-project/oxc-resolver#213))
- *(napi)* remove tokio
([#212](oxc-project/oxc-resolver#212))
- document directory is an absolute path for `resolve(directory,
specifier)`
([#206](oxc-project/oxc-resolver#206))
- re-enable the wasi build
([#193](oxc-project/oxc-resolver#193))
- use pnpm workspace
([#182](oxc-project/oxc-resolver#182))
- *(deps)* update rust crates
([#176](oxc-project/oxc-resolver#176))
- *(napi)* update NAPI-RS cli version and binding template
([#111](oxc-project/oxc-resolver#111))
- update project github url
- *(deps)* update pnpm to v8.14.1
([#52](oxc-project/oxc-resolver#52))
- *(deps)* update pnpm to v8.14.0
([#48](oxc-project/oxc-resolver#48))
- *(deps)* update pnpm to v8.13.1
([#42](oxc-project/oxc-resolver#42))
- remove FIXME comments
- *(napi)* align `*Fields` user options with enhanced-resolve
([#35](oxc-project/oxc-resolver#35))
- *(deps)* update pnpm to v8.12.1
([#21](oxc-project/oxc-resolver#21))
- add some doc for napi TsconfigOptions
([#20](oxc-project/oxc-resolver#20))
- *(deps)* update pnpm to v8.12.0
([#18](oxc-project/oxc-resolver#18))
- *(README)* adding debugging command from Rspack
- *(deps)* update pnpm to v8.11.0
([#9](oxc-project/oxc-resolver#9))
- *(resolver)* remove tracing_subscriber
([#1362](https://github.com/oxc-project/oxc-resolver/pull/1362))
- *(resolver)* improve documentation
([#591](oxc-project/oxc-resolver#591))

### <!-- 8 -->CI

- check for napi .d.index changes
([#491](oxc-project/oxc-resolver#491))
- *(release-napi)* support `riscv64gc-unknown-linux-gnu` and
`s390x-unknown-linux-gnu`
([#451](oxc-project/oxc-resolver#451))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy