Skip to content

Commit 5b73853

Browse files
hardfistarcanischenjiahan
authored
feat(core): add yarn pnp support (#7639)
* 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 <nison.mael@gmail.com> * chore: add doc * chore: change enablePnp to pnp * Update website/docs/zh/config/resolve.mdx Co-authored-by: neverland <chenjiahan.jait@bytedance.com> * Update website/docs/en/config/resolve.mdx Co-authored-by: neverland <chenjiahan.jait@bytedance.com> * Update resolve.mdx * chore: update lock * chore: update format * chore: update snapshot --------- Co-authored-by: Maël Nison <nison.mael@gmail.com> Co-authored-by: neverland <chenjiahan.jait@bytedance.com>
1 parent 203b7e9 commit 5b73853

File tree

49 files changed

+21944
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+21944
-38
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"**/CVS": true,
77
"**/.DS_Store": true,
88
"**/*.bk": true,
9-
"/target": true,
10-
"**/.yarn": true
9+
"/target": true
1110
},
1211
"[typescript]": {
1312
"editor.formatOnSave": true

Cargo.lock

Lines changed: 156 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ quote = { version = "1.0.38" }
6464
rayon = { version = "1.10.0" }
6565
regex = { version = "1.11.1" }
6666
ropey = "1.6.1"
67-
rspack_resolver = { version = "0.3.6", features = ["package_json_raw_json_api"] }
67+
rspack_resolver = { features = ["package_json_raw_json_api"], version = "0.4.1" }
6868
rspack_sources = { version = "0.4.1" }
6969
rustc-hash = { version = "2.1.0" }
7070
serde = { version = "1.0.217" }
@@ -102,6 +102,7 @@ swc_html = { version = "=7.0.0" }
102102
swc_html_minifier = { version = "=7.0.0", default-features = false }
103103
swc_node_comments = { version = "=5.0.0" }
104104

105+
pnp = { version = "0.9.0" }
105106

106107
rspack_dojang = { version = "0.1.9" }
107108

crates/node_binding/binding.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export declare class JsResolver {
258258
}
259259

260260
export declare class JsResolverFactory {
261-
constructor()
261+
constructor(pnp: boolean)
262262
get(type: string, options?: RawResolveOptionsWithDependencyType): JsResolver
263263
}
264264

@@ -1887,6 +1887,7 @@ export interface RawResolveOptions {
18871887
aliasFields?: Array<string>
18881888
restrictions?: Array<string>
18891889
roots?: Array<string>
1890+
pnp?: boolean
18901891
}
18911892

18921893
export interface RawResolveOptionsWithDependencyType {
@@ -1913,6 +1914,7 @@ export interface RawResolveOptionsWithDependencyType {
19131914
roots?: Array<string>
19141915
dependencyCategory?: string
19151916
resolveToContext?: boolean
1917+
pnp?: boolean
19161918
}
19171919

19181920
export interface RawResolveTsconfigOptions {

crates/node_binding/src/resolver_factory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub struct JsResolverFactory {
2121
#[napi]
2222
impl JsResolverFactory {
2323
#[napi(constructor)]
24-
pub fn new() -> napi::Result<Self> {
25-
let input_filesystem = Arc::new(NativeFileSystem {});
24+
pub fn new(pnp: bool) -> napi::Result<Self> {
25+
let input_filesystem = Arc::new(NativeFileSystem::new(pnp));
2626
Ok(Self {
2727
resolver_factory: None,
2828
loader_resolver_factory: None,

0 commit comments

Comments
 (0)