Skip to content

Commit

Permalink
feat(core): add yarn pnp support (#7639)
Browse files Browse the repository at this point in the history
* feat: support yarn pnp

* chore: add snapshot back

* chore: fix test error

* chore: fix unused deps

* fix: fix type

* chore: fix snapshot

* chore: skip default test for enablePnp

* chore: fix test

* chore: update ae

* Update crates/rspack_core/src/options/resolve/mod.rs

Co-authored-by: Maël Nison <[email protected]>

* chore: add doc

* chore: change enablePnp to pnp

* Update website/docs/zh/config/resolve.mdx

Co-authored-by: neverland <[email protected]>

* Update website/docs/en/config/resolve.mdx

Co-authored-by: neverland <[email protected]>

* Update resolve.mdx

* chore: update lock

* chore: update format

* chore: update snapshot

---------

Co-authored-by: Maël Nison <[email protected]>
Co-authored-by: neverland <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2025
1 parent 203b7e9 commit 5b73853
Show file tree
Hide file tree
Showing 49 changed files with 21,944 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"**/CVS": true,
"**/.DS_Store": true,
"**/*.bk": true,
"/target": true,
"**/.yarn": true
"/target": true
},
"[typescript]": {
"editor.formatOnSave": true
Expand Down
160 changes: 156 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ quote = { version = "1.0.38" }
rayon = { version = "1.10.0" }
regex = { version = "1.11.1" }
ropey = "1.6.1"
rspack_resolver = { version = "0.3.6", features = ["package_json_raw_json_api"] }
rspack_resolver = { features = ["package_json_raw_json_api"], version = "0.4.1" }
rspack_sources = { version = "0.4.1" }
rustc-hash = { version = "2.1.0" }
serde = { version = "1.0.217" }
Expand Down Expand Up @@ -102,6 +102,7 @@ swc_html = { version = "=7.0.0" }
swc_html_minifier = { version = "=7.0.0", default-features = false }
swc_node_comments = { version = "=5.0.0" }

pnp = { version = "0.9.0" }

rspack_dojang = { version = "0.1.9" }

Expand Down
4 changes: 3 additions & 1 deletion crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export declare class JsResolver {
}

export declare class JsResolverFactory {
constructor()
constructor(pnp: boolean)
get(type: string, options?: RawResolveOptionsWithDependencyType): JsResolver
}

Expand Down Expand Up @@ -1887,6 +1887,7 @@ export interface RawResolveOptions {
aliasFields?: Array<string>
restrictions?: Array<string>
roots?: Array<string>
pnp?: boolean
}

export interface RawResolveOptionsWithDependencyType {
Expand All @@ -1913,6 +1914,7 @@ export interface RawResolveOptionsWithDependencyType {
roots?: Array<string>
dependencyCategory?: string
resolveToContext?: boolean
pnp?: boolean
}

export interface RawResolveTsconfigOptions {
Expand Down
4 changes: 2 additions & 2 deletions crates/node_binding/src/resolver_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub struct JsResolverFactory {
#[napi]
impl JsResolverFactory {
#[napi(constructor)]
pub fn new() -> napi::Result<Self> {
let input_filesystem = Arc::new(NativeFileSystem {});
pub fn new(pnp: bool) -> napi::Result<Self> {
let input_filesystem = Arc::new(NativeFileSystem::new(pnp));
Ok(Self {
resolver_factory: None,
loader_resolver_factory: None,
Expand Down
Loading

2 comments on commit 5b73853

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 5b73853 Jan 9, 2025

Choose a reason for hiding this comment

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

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
rspress ✅ success
rslib ✅ success
rsbuild ✅ success
rsdoctor ✅ success
examples ✅ success
devserver ✅ success
nuxt ✅ success

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 5b73853 Jan 9, 2025

Choose a reason for hiding this comment

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

📝 Benchmark detail: Open

Name Base (2025-01-09 203b7e9) Current Change
10000_big_production-mode_disable-minimize + exec 37.4 s ± 521 ms 38.1 s ± 496 ms +1.88 %
10000_development-mode + exec 1.89 s ± 27 ms 1.88 s ± 39 ms -0.25 %
10000_development-mode_hmr + exec 680 ms ± 5 ms 689 ms ± 36 ms +1.36 %
10000_production-mode + exec 2.46 s ± 73 ms 2.42 s ± 34 ms -1.58 %
arco-pro_development-mode + exec 1.74 s ± 59 ms 1.76 s ± 72 ms +0.65 %
arco-pro_development-mode_hmr + exec 378 ms ± 0.84 ms 378 ms ± 1.6 ms +0.12 %
arco-pro_production-mode + exec 3.74 s ± 54 ms 3.68 s ± 123 ms -1.58 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.74 s ± 137 ms 3.7 s ± 112 ms -0.94 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.77 s ± 125 ms 3.72 s ± 148 ms -1.48 %
large-dyn-imports_development-mode + exec 2.13 s ± 30 ms 2.15 s ± 33 ms +0.82 %
large-dyn-imports_production-mode + exec 2.19 s ± 33 ms 2.22 s ± 42 ms +1.13 %
threejs_development-mode_10x + exec 1.54 s ± 55 ms 1.5 s ± 29 ms -2.45 %
threejs_development-mode_10x_hmr + exec 792 ms ± 20 ms 764 ms ± 31 ms -3.48 %
threejs_production-mode_10x + exec 5.36 s ± 92 ms 5.36 s ± 116 ms -0.04 %
10000_big_production-mode_disable-minimize + rss memory 9538 MiB ± 224 MiB 9574 MiB ± 41.6 MiB +0.37 %
10000_development-mode + rss memory 649 MiB ± 13.7 MiB 648 MiB ± 11.4 MiB -0.19 %
10000_development-mode_hmr + rss memory 1435 MiB ± 327 MiB 1410 MiB ± 179 MiB -1.77 %
10000_production-mode + rss memory 643 MiB ± 26.3 MiB 635 MiB ± 37.3 MiB -1.30 %
arco-pro_development-mode + rss memory 550 MiB ± 28.7 MiB 552 MiB ± 27.3 MiB +0.41 %
arco-pro_development-mode_hmr + rss memory 619 MiB ± 52 MiB 587 MiB ± 81.5 MiB -5.07 %
arco-pro_production-mode + rss memory 720 MiB ± 76 MiB 731 MiB ± 32.4 MiB +1.51 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 725 MiB ± 72.1 MiB 723 MiB ± 46.6 MiB -0.21 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 741 MiB ± 51 MiB 720 MiB ± 36.4 MiB -2.80 %
large-dyn-imports_development-mode + rss memory 632 MiB ± 2.97 MiB 624 MiB ± 5.38 MiB -1.24 %
large-dyn-imports_production-mode + rss memory 525 MiB ± 3.14 MiB 519 MiB ± 3.16 MiB -1.23 %
threejs_development-mode_10x + rss memory 579 MiB ± 11.7 MiB 565 MiB ± 16.6 MiB -2.53 %
threejs_development-mode_10x_hmr + rss memory 1131 MiB ± 121 MiB 1182 MiB ± 99.1 MiB +4.56 %
threejs_production-mode_10x + rss memory 880 MiB ± 51.8 MiB 880 MiB ± 45.9 MiB +0.06 %

Please sign in to comment.