Skip to content

Commit

Permalink
fix(incremental): activate inactive module not codegen (#8871)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk authored Dec 27, 2024
1 parent b5d22d6 commit 5431a0b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 16 deletions.
39 changes: 23 additions & 16 deletions crates/rspack_ids/src/named_module_ids_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn module_ids(&self, compilation: &mut rspack_core::Compilation) -> Result<()> {
.map(|(&module, id)| (id.clone(), module))
.collect();
let module_graph = compilation.get_module_graph();
let mut modules: IdentifierSet = if let Some(mutations) = compilation
if let Some(mutations) = compilation
.incremental
.mutations_read(IncrementalPasses::MODULE_IDS)
&& !module_ids.is_empty()
Expand All @@ -154,21 +154,28 @@ fn module_ids(&self, compilation: &mut rspack_core::Compilation) -> Result<()> {
_ => {}
};
acc
})
} else {
module_graph.modules().keys().copied().collect()
};

modules.retain(|m| {
let m = module_graph
.module_by_identifier(m)
.expect("should have module");
m.need_id()
&& compilation
.chunk_graph
.get_number_of_module_chunks(m.identifier())
!= 0
});
});
}

let modules: IdentifierSet = module_graph
.modules()
.iter()
.filter(|&(module_identifier, module)| {
let not_used =
if let Some(module_id) = ChunkGraph::get_module_id(&module_ids, *module_identifier) {
!used_ids.contains_key(module_id.as_str())
} else {
true
};
not_used
&& module.need_id()
&& compilation
.chunk_graph
.get_number_of_module_chunks(*module_identifier)
!= 0
})
.map(|(m, _)| *m)
.collect();
let modules_len = modules.len();

let context: &str = compilation.options.context.as_ref();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const value = 42;
globalThis["activate-inactive-module"] = value;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "./a";

it("should not change the module id for the updated module", async () => {
expect(globalThis["activate-inactive-module"]).toBe(undefined);
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { value } from "./a";

it("should not change the module id for the updated module", async () => {
expect(globalThis["activate-inactive-module"]).toBe(42);
expect(value).toBe(42);
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "./a";

it("should not change the module id for the updated module", async () => {
expect(globalThis["activate-inactive-module"]).toBe(undefined);
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('@rspack/core').Configuration} */
module.exports = {
module: {
rules: [
{
test: /a\.js/,
sideEffects: false,
}
]
}
};

1 comment on commit 5431a0b

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 5431a0b Dec 27, 2024

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 (2024-12-27 170b877) Current Change
10000_big_production-mode_disable-minimize + exec 37.9 s ± 592 ms 38.3 s ± 584 ms +1.11 %
10000_development-mode + exec 1.86 s ± 25 ms 1.83 s ± 37 ms -1.67 %
10000_development-mode_hmr + exec 682 ms ± 12 ms 679 ms ± 31 ms -0.47 %
10000_production-mode + exec 2.5 s ± 32 ms 2.45 s ± 56 ms -2.27 %
arco-pro_development-mode + exec 1.76 s ± 46 ms 1.77 s ± 111 ms +0.74 %
arco-pro_development-mode_hmr + exec 377 ms ± 0.82 ms 377 ms ± 2.1 ms -0.01 %
arco-pro_production-mode + exec 3.62 s ± 91 ms 3.63 s ± 54 ms +0.53 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.67 s ± 53 ms 3.71 s ± 116 ms +0.99 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.62 s ± 114 ms 3.7 s ± 97 ms +2.08 %
threejs_development-mode_10x + exec 1.51 s ± 11 ms 1.51 s ± 22 ms -0.39 %
threejs_development-mode_10x_hmr + exec 790 ms ± 33 ms 767 ms ± 3.2 ms -2.97 %
threejs_production-mode_10x + exec 5.4 s ± 129 ms 5.4 s ± 139 ms +0.02 %
10000_big_production-mode_disable-minimize + rss memory 9505 MiB ± 278 MiB 9570 MiB ± 141 MiB +0.68 %
10000_development-mode + rss memory 653 MiB ± 10.9 MiB 702 MiB ± 28.5 MiB +7.56 %
10000_development-mode_hmr + rss memory 1451 MiB ± 170 MiB 1549 MiB ± 257 MiB +6.77 %
10000_production-mode + rss memory 628 MiB ± 25.7 MiB 672 MiB ± 37.7 MiB +6.88 %
arco-pro_development-mode + rss memory 578 MiB ± 26.7 MiB 608 MiB ± 38.5 MiB +5.29 %
arco-pro_development-mode_hmr + rss memory 610 MiB ± 104 MiB 671 MiB ± 74 MiB +9.97 %
arco-pro_production-mode + rss memory 731 MiB ± 44.6 MiB 775 MiB ± 83.7 MiB +6.04 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 745 MiB ± 71.9 MiB 766 MiB ± 45.6 MiB +2.81 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 759 MiB ± 30.2 MiB 739 MiB ± 49.9 MiB -2.59 %
threejs_development-mode_10x + rss memory 594 MiB ± 12.2 MiB 639 MiB ± 32.1 MiB +7.49 %
threejs_development-mode_10x_hmr + rss memory 1171 MiB ± 171 MiB 1207 MiB ± 91.5 MiB +3.10 %
threejs_production-mode_10x + rss memory 873 MiB ± 52.4 MiB 933 MiB ± 65.7 MiB +6.90 %

Please sign in to comment.