Skip to content
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: incorrect resolution when using shared resolvers with different main_fields #134

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

Boshen
Copy link
Member

@Boshen Boshen commented Apr 22, 2024

The modified test case

fn test() {
    let f = super::fixture().join("restrictions");

    let resolver1 = Resolver::new(ResolveOptions {
        main_fields: vec!["style".into()],
        ..ResolveOptions::default()
    });

    let resolution = resolver1.resolve(&f, "pck2").map(|r| r.full_path());
    assert_eq!(resolution, Ok(f.join("node_modules/pck2/index.css")));

    let resolver2 = resolver1.clone_with_options(ResolveOptions {
        main_fields: vec!["module".into(), "main".into()],
        ..ResolveOptions::default()
    });

    let resolution = resolver2.resolve(&f, "pck2").map(|r| r.full_path());
    assert_eq!(resolution, Ok(f.join("node_modules/pck2/module.js")));
}

failed to revolve due to package.json caching the value of main_fields: vec!["style".into()], the second resolution main_fields: vec!["module".into(), "main".into()] would yield nothing because package.json#mainFields still holds the value of "style".

This PR changes caching the options to retrieving the values dynamically. I need to continue the work on all the other fields in #135

But I need to hotfix the main_fields change first for Rspack.

Copy link

codecov bot commented Apr 22, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.94%. Comparing base (ee22b66) to head (0224a85).
Report is 2 commits behind head on main.

Files Patch % Lines
src/lib.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #134   +/-   ##
=======================================
  Coverage   94.93%   94.94%           
=======================================
  Files          11       11           
  Lines        2212     2216    +4     
=======================================
+ Hits         2100     2104    +4     
  Misses        112      112           

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

Copy link

codspeed-hq bot commented Apr 22, 2024

CodSpeed Performance Report

Merging #134 will not alter performance

Comparing dont-cache-optins (0224a85) with main (db051d5)

Summary

✅ 2 untouched benchmarks

@Boshen Boshen merged commit a8118bc into main Apr 22, 2024
21 checks passed
@Boshen Boshen deleted the dont-cache-optins branch April 22, 2024 18:07
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