Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ impl CodeSplitter {
)
{
incremental_diagnostic = diagnostic;
compilation.chunk_render_artifact.clear();
}
}

Expand Down
60 changes: 50 additions & 10 deletions crates/rspack_core/src/compilation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,10 +1254,16 @@ impl Compilation {
"Chunk filename that dependent on full hash",
"chunk filename that dependent on full hash is not supported in incremental compilation",
)
&& let Some(diagnostic) = diagnostic
{
self.push_diagnostic(diagnostic);
}

// Check if CHUNKS_RENDER pass is disabled, and clear artifact if needed
if !self
.incremental
.passes_enabled(IncrementalPasses::CHUNKS_RENDER)
{
if let Some(diagnostic) = diagnostic {
self.push_diagnostic(diagnostic);
}
self.chunk_render_artifact.clear();
}

Expand Down Expand Up @@ -1292,7 +1298,6 @@ impl Compilation {
));
chunks
} else {
self.chunk_render_artifact.clear();
self.chunk_by_ukey.keys().copied().collect()
};
let results = rspack_futures::scope::<_, Result<_>>(|token| {
Expand Down Expand Up @@ -1732,6 +1737,14 @@ impl Compilation {

let start = logger.time("module ids");

// Check if MODULE_IDS pass is disabled, and clear artifact if needed
if !self
.incremental
.passes_enabled(IncrementalPasses::MODULE_IDS)
{
self.module_ids_artifact.clear();
}

let mut diagnostics = vec![];
let mut module_ids_artifact = mem::take(&mut self.module_ids_artifact);
plugin_driver
Expand All @@ -1745,6 +1758,15 @@ impl Compilation {
logger.time_end(start);

let start = logger.time("chunk ids");

// Check if CHUNK_IDS pass is disabled, and clear artifact if needed
if !self
.incremental
.passes_enabled(IncrementalPasses::CHUNK_IDS)
{
self.named_chunk_ids_artifact.clear();
}

let mut diagnostics = vec![];
let mut chunk_by_ukey = mem::take(&mut self.chunk_by_ukey);
let mut named_chunk_ids_artifact = mem::take(&mut self.named_chunk_ids_artifact);
Expand Down Expand Up @@ -1775,6 +1797,14 @@ impl Compilation {
.map_err(|e| e.wrap_err("caused by plugins in Compilation.hooks.optimizeCodeGeneration"))?;
logger.time_end(start);

// Check if MODULES_HASHES pass is disabled, and clear artifact if needed
if !self
.incremental
.passes_enabled(IncrementalPasses::MODULES_HASHES)
{
self.cgm_hash_artifact.clear();
}

let create_module_hashes_modules = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::MODULES_HASHES)
Expand Down Expand Up @@ -1851,7 +1881,6 @@ impl Compilation {

modules
} else {
self.cgm_hash_artifact.clear();
self.get_module_graph().modules().keys().copied().collect()
};
self
Expand Down Expand Up @@ -1947,6 +1976,15 @@ impl Compilation {
)
.await?;
let runtime_chunks = self.get_chunk_graph_entries().collect();

// Check if CHUNKS_RUNTIME_REQUIREMENTS pass is disabled, and clear artifact if needed
if !self
.incremental
.passes_enabled(IncrementalPasses::CHUNKS_RUNTIME_REQUIREMENTS)
{
self.cgc_runtime_requirements_artifact.clear();
}

let process_runtime_requirements_chunks = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::CHUNKS_RUNTIME_REQUIREMENTS)
Expand Down Expand Up @@ -1979,7 +2017,6 @@ impl Compilation {
));
affected_chunks
} else {
self.cgc_runtime_requirements_artifact.clear();
self.chunk_by_ukey.keys().copied().collect()
};
self
Expand Down Expand Up @@ -2350,10 +2387,14 @@ impl Compilation {
"Chunk content that dependent on full hash",
"it requires calculating the hashes of all the chunks, which is a global effect",
)
&& let Some(diagnostic) = diagnostic
{
self.push_diagnostic(diagnostic);
}
if !self
.incremental
.passes_enabled(IncrementalPasses::CHUNKS_HASHES)
{
if let Some(diagnostic) = diagnostic {
self.push_diagnostic(diagnostic);
}
self.chunk_hashes_artifact.clear();
}

Expand Down Expand Up @@ -2382,7 +2423,6 @@ impl Compilation {
));
chunks
} else {
self.chunk_hashes_artifact.clear();
self.chunk_by_ukey.keys().copied().collect()
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ async fn optimize_dependencies(
"it requires calculating the used exports based on all modules, which is a global effect",
) {
diagnostics.extend(diagnostic);
// compilation.cgm_hash_artifact.clear();
}

let mut proxy =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ async fn optimize_dependencies(
"it requires calculating the export names of all the modules, which is a global effect",
) {
diagnostics.extend(diagnostic);
//compilation.cgm_hash_artifact.clear();
}

let mg = build_module_graph_artifact.get_module_graph_mut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ async fn optimize_code_generation(&self, compilation: &mut Compilation) -> Resul
IncrementalPasses::MODULES_HASHES,
"MangleExportsPlugin (optimization.mangleExports = true)",
"it requires calculating the export names of all the modules, which is a global effect",
) {
if let Some(diagnostic) = diagnostic {
compilation.push_diagnostic(diagnostic);
}
compilation.cgm_hash_artifact.clear();
) && let Some(diagnostic) = diagnostic
{
compilation.push_diagnostic(diagnostic);
}

let mg = compilation.get_module_graph_mut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1402,15 +1402,8 @@ async fn optimize_chunk_modules(&self, compilation: &mut Compilation) -> Result<
| IncrementalPasses::CHUNKS_HASHES,
"ModuleConcatenationPlugin (optimization.concatenateModules = true)",
"it requires calculating the modules that can be concatenated based on all the modules, which is a global effect",
) {
if let Some(diagnostic) = diagnostic {
) && let Some(diagnostic) = diagnostic {
compilation.push_diagnostic(diagnostic);
}
compilation.cgm_hash_artifact.clear();
compilation.module_ids_artifact.clear();
compilation.named_chunk_ids_artifact.clear();
compilation.cgc_runtime_requirements_artifact.clear();
compilation.chunk_hashes_artifact.clear();
}

self.optimize_chunk_modules_impl(compilation).await?;
Expand Down
Loading