Skip to content

Commit

Permalink
fix: resolve the inconsistent type issue in JsModule (#8939)
Browse files Browse the repository at this point in the history
* fix: resolve the inconsistent type issue in JsModule

* fix: cargo cliipy
  • Loading branch information
shulaoda authored Jan 22, 2025
1 parent 06807ac commit 9696d62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export declare class JsModule {
get nameForCondition(): string | undefined
get request(): string | undefined
get userRequest(): string | undefined
set userRequest(val: string)
set userRequest(val: string | undefined)
get rawRequest(): string | undefined
get factoryMeta(): JsFactoryMeta | undefined
get type(): string
Expand Down
14 changes: 9 additions & 5 deletions crates/rspack_binding_values/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,15 @@ impl JsModule {
}

#[napi(setter)]
pub fn set_user_request(&mut self, val: String) -> napi::Result<()> {
let module: &mut dyn Module = self.as_mut()?;

if let Ok(normal_module) = module.try_as_normal_module_mut() {
*normal_module.user_request_mut() = val;
pub fn set_user_request(&mut self, val: Either<String, ()>) -> napi::Result<()> {
match val {
Either::A(val) => {
let module: &mut dyn Module = self.as_mut()?;
if let Ok(normal_module) = module.try_as_normal_module_mut() {
*normal_module.user_request_mut() = val;
}
}
Either::B(_) => {}
}
Ok(())
}
Expand Down
6 changes: 4 additions & 2 deletions packages/rspack/src/Module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ export class Module {
get(): string | undefined {
return module.userRequest;
},
set(val: string) {
module.userRequest = val;
set(val: string | undefined) {
if (val) {
module.userRequest = val;
}
}
},
rawRequest: {
Expand Down

2 comments on commit 9696d62

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 9696d62 Jan 22, 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-21 c06787b) Current Change
10000_big_production-mode_disable-minimize + exec 36.7 s ± 515 ms 38.9 s ± 1.23 s +5.92 %
10000_development-mode + exec 1.86 s ± 52 ms 1.83 s ± 16 ms -1.95 %
10000_development-mode_hmr + exec 681 ms ± 9.8 ms 682 ms ± 6.3 ms +0.23 %
10000_production-mode + exec 2.45 s ± 138 ms 2.41 s ± 142 ms -1.31 %
10000_production-mode_persistent-cold + exec 2.61 s ± 155 ms 2.52 s ± 71 ms -3.47 %
10000_production-mode_persistent-hot + exec 1.77 s ± 116 ms 1.81 s ± 193 ms +2.13 %
arco-pro_development-mode + exec 1.76 s ± 98 ms 1.79 s ± 143 ms +1.79 %
arco-pro_development-mode_hmr + exec 388 ms ± 2.3 ms 388 ms ± 2.4 ms +0.14 %
arco-pro_production-mode + exec 3.64 s ± 257 ms 3.79 s ± 72 ms +4.32 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.75 s ± 314 ms 3.85 s ± 199 ms +2.62 %
arco-pro_production-mode_persistent-cold + exec 3.8 s ± 165 ms 3.91 s ± 33 ms +2.78 %
arco-pro_production-mode_persistent-hot + exec 2.34 s ± 79 ms 2.62 s ± 379 ms +12.27 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.67 s ± 99 ms 3.79 s ± 87 ms +3.36 %
large-dyn-imports_development-mode + exec 2.11 s ± 29 ms 2.09 s ± 54 ms -0.84 %
large-dyn-imports_production-mode + exec 2.16 s ± 40 ms 2.14 s ± 37 ms -0.81 %
threejs_development-mode_10x + exec 1.53 s ± 22 ms 1.52 s ± 19 ms -0.26 %
threejs_development-mode_10x_hmr + exec 788 ms ± 39 ms 788 ms ± 18 ms +0.01 %
threejs_production-mode_10x + exec 5.25 s ± 61 ms 5.49 s ± 391 ms +4.48 %
threejs_production-mode_10x_persistent-cold + exec 5.35 s ± 65 ms 5.55 s ± 387 ms +3.78 %
threejs_production-mode_10x_persistent-hot + exec 4.5 s ± 44 ms 4.79 s ± 375 ms +6.47 %
10000_big_production-mode_disable-minimize + rss memory 8680 MiB ± 34.2 MiB 8699 MiB ± 49.2 MiB +0.21 %
10000_development-mode + rss memory 656 MiB ± 19.6 MiB 676 MiB ± 20.5 MiB +3.14 %
10000_development-mode_hmr + rss memory 1264 MiB ± 163 MiB 1360 MiB ± 201 MiB +7.62 %
10000_production-mode + rss memory 639 MiB ± 31 MiB 678 MiB ± 21.1 MiB +6.08 %
10000_production-mode_persistent-cold + rss memory 744 MiB ± 15.6 MiB 777 MiB ± 22 MiB +4.36 %
10000_production-mode_persistent-hot + rss memory 723 MiB ± 37.7 MiB 759 MiB ± 17.9 MiB +4.98 %
arco-pro_development-mode + rss memory 553 MiB ± 38.1 MiB 600 MiB ± 35.7 MiB +8.59 %
arco-pro_development-mode_hmr + rss memory 631 MiB ± 36 MiB 668 MiB ± 53.5 MiB +5.89 %
arco-pro_production-mode + rss memory 738 MiB ± 66.3 MiB 737 MiB ± 22.3 MiB -0.19 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 730 MiB ± 23.1 MiB 754 MiB ± 34.6 MiB +3.31 %
arco-pro_production-mode_persistent-cold + rss memory 844 MiB ± 36.6 MiB 850 MiB ± 34.7 MiB +0.74 %
arco-pro_production-mode_persistent-hot + rss memory 695 MiB ± 19.9 MiB 730 MiB ± 26.1 MiB +5.09 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 727 MiB ± 32.5 MiB 729 MiB ± 33.1 MiB +0.33 %
large-dyn-imports_development-mode + rss memory 642 MiB ± 4.5 MiB 649 MiB ± 8.42 MiB +1.15 %
large-dyn-imports_production-mode + rss memory 523 MiB ± 4.79 MiB 533 MiB ± 4.84 MiB +1.94 %
threejs_development-mode_10x + rss memory 551 MiB ± 32.9 MiB 550 MiB ± 9.21 MiB -0.04 %
threejs_development-mode_10x_hmr + rss memory 1145 MiB ± 125 MiB 1091 MiB ± 177 MiB -4.67 %
threejs_production-mode_10x + rss memory 865 MiB ± 36.9 MiB 833 MiB ± 40.5 MiB -3.74 %
threejs_production-mode_10x_persistent-cold + rss memory 968 MiB ± 136 MiB 944 MiB ± 49.7 MiB -2.51 %
threejs_production-mode_10x_persistent-hot + rss memory 870 MiB ± 25.8 MiB 861 MiB ± 43.4 MiB -1.10 %

Threshold exceeded: ["10000_big_production-mode_disable-minimize + exec","arco-pro_production-mode_persistent-hot + exec","threejs_production-mode_10x_persistent-hot + exec"]

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 9696d62 Jan 22, 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

Please sign in to comment.