Skip to content

Commit

Permalink
fix(make): isolated module clean incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykingxyz committed Sep 2, 2024
1 parent 01a460d commit d6c74be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ impl CleanIsolatedModule {
}

pub fn fix_artifact(self, artifact: &mut MakeArtifact) {
let module_graph = artifact.get_module_graph_mut();
let mut need_remove_modules = IdentifierSet::default();
let mut queue = VecDeque::from(
self
.need_check_isolated_module_ids
.into_iter()
.collect::<Vec<_>>(),
);
while let Some(module_identifier) = queue.pop_front() {
let module_graph = artifact.get_module_graph();
let Some(mgm) = module_graph.module_graph_module_by_identifier(&module_identifier) else {
tracing::trace!("Module is cleaned: {}", module_identifier);
continue;
Expand All @@ -53,9 +52,8 @@ impl CleanIsolatedModule {
// clean child module
queue.push_back(*connection.module_identifier());
}
artifact.revoke_module(&module_identifier);
tracing::trace!("Module is cleaned: {}", module_identifier);
need_remove_modules.insert(module_identifier);
}
artifact.revoke_modules(need_remove_modules);
}
}
4 changes: 3 additions & 1 deletion crates/rspack_core/src/compiler/make/cutout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ impl Cutout {
}

// do revoke module and collect deps
force_build_deps.extend(artifact.revoke_modules(force_build_modules));
for id in force_build_modules {
force_build_deps.extend(artifact.revoke_module(&id));
}

let mut module_graph = artifact.get_module_graph_mut();
for dep_id in remove_entry_deps {
Expand Down
41 changes: 19 additions & 22 deletions crates/rspack_core/src/compiler/make/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use rustc_hash::FxHashSet as HashSet;
use self::{cutout::Cutout, repair::repair};
use crate::{
utils::FileCounter, BuildDependency, Compilation, DependencyId, ModuleGraph, ModuleGraphPartial,
ModuleIdentifier,
};

#[derive(Debug, Default)]
Expand Down Expand Up @@ -55,30 +56,26 @@ impl MakeArtifact {
std::mem::take(&mut self.built_modules)
}

fn revoke_modules(&mut self, ids: IdentifierSet) -> Vec<BuildDependency> {
fn revoke_module(&mut self, module_identifier: &ModuleIdentifier) -> Vec<BuildDependency> {
let mut module_graph = ModuleGraph::new(vec![], Some(&mut self.module_graph_partial));
let mut res = vec![];
for module_identifier in &ids {
let module = module_graph
.module_by_identifier(module_identifier)
.expect("should have module");
if let Some(build_info) = module.build_info() {
self
.file_dependencies
.remove_batch_file(&build_info.file_dependencies);
self
.context_dependencies
.remove_batch_file(&build_info.context_dependencies);
self
.missing_dependencies
.remove_batch_file(&build_info.missing_dependencies);
self
.build_dependencies
.remove_batch_file(&build_info.build_dependencies);
}
res.extend(module_graph.revoke_module(module_identifier));
let module = module_graph
.module_by_identifier(module_identifier)
.expect("should have module");
if let Some(build_info) = module.build_info() {
self
.file_dependencies
.remove_batch_file(&build_info.file_dependencies);
self
.context_dependencies
.remove_batch_file(&build_info.context_dependencies);
self
.missing_dependencies
.remove_batch_file(&build_info.missing_dependencies);
self
.build_dependencies
.remove_batch_file(&build_info.build_dependencies);
}
res
module_graph.revoke_module(module_identifier)
}

pub fn reset_dependencies_incremental_info(&mut self) {
Expand Down

0 comments on commit d6c74be

Please sign in to comment.