Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incremental rebuild are compatible with empty artifact #8758

Merged
merged 1 commit into from
Dec 18, 2024
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
4 changes: 4 additions & 0 deletions crates/rspack_core/src/cgm_hash_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pub struct CgmHashResults {
}

impl CgmHashResults {
pub fn is_empty(&self) -> bool {
self.module_to_hashes.is_empty()
}

pub fn get(&self, module: &ModuleIdentifier, runtime: &RuntimeSpec) -> Option<&RspackHashDigest> {
let hashes = self.module_to_hashes.get(module)?;
hashes.get(runtime)
Expand Down
4 changes: 4 additions & 0 deletions crates/rspack_core/src/cgm_runtime_requirement_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ pub struct CgmRuntimeRequirementsResults {
}

impl CgmRuntimeRequirementsResults {
pub fn is_empty(&self) -> bool {
self.module_to_runtime_requirements.is_empty()
}

pub fn get(&self, module: &ModuleIdentifier, runtime: &RuntimeSpec) -> Option<&RuntimeGlobals> {
let requirements = self.module_to_runtime_requirements.get(module)?;
requirements.get(runtime)
Expand Down
4 changes: 4 additions & 0 deletions crates/rspack_core/src/code_generation_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ pub struct CodeGenerationResults {
}

impl CodeGenerationResults {
pub fn is_empty(&self) -> bool {
self.module_generation_result_map.is_empty() && self.map.is_empty()
}

pub fn get_one(&self, module_identifier: &ModuleIdentifier) -> Option<&CodeGenerationResult> {
self
.map
Expand Down
14 changes: 12 additions & 2 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,9 @@ impl Compilation {
let mutations = self
.incremental
.mutations_read(IncrementalPasses::CHUNKS_RENDER);
let chunks = if let Some(mutations) = mutations {
let chunks = if let Some(mutations) = mutations
&& !self.chunk_render_results.is_empty()
{
let removed_chunks = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ChunkRemove { chunk } => Some(*chunk),
_ => None,
Expand Down Expand Up @@ -1222,7 +1224,10 @@ impl Compilation {
let mutations = self
.incremental
.mutations_read(IncrementalPasses::DEPENDENCIES_DIAGNOSTICS);
let modules = if let Some(mutations) = mutations {
// TODO move diagnostic collect to make
let modules = if let Some(mutations) = mutations
&& !self.dependencies_diagnostics.is_empty()
{
let revoked_modules = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ModuleRemove { module } => Some(*module),
_ => None,
Expand Down Expand Up @@ -1349,6 +1354,7 @@ impl Compilation {
let create_module_hashes_modules = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::MODULES_HASHES)
&& !self.cgm_hash_results.is_empty()
{
let revoked_modules = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ModuleRemove { module } => Some(*module),
Expand Down Expand Up @@ -1381,6 +1387,7 @@ impl Compilation {
let code_generation_modules = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::MODULES_CODEGEN)
&& !self.code_generation_results.is_empty()
{
let revoked_modules = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ModuleRemove { module } => Some(*module),
Expand All @@ -1407,6 +1414,7 @@ impl Compilation {
let process_runtime_requirements_modules = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::MODULES_RUNTIME_REQUIREMENTS)
&& !self.cgm_runtime_requirements_results.is_empty()
{
let revoked_modules = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ModuleRemove { module } => Some(*module),
Expand Down Expand Up @@ -1438,6 +1446,7 @@ impl Compilation {
let process_runtime_requirements_chunks = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::CHUNKS_RUNTIME_REQUIREMENTS)
&& !self.cgc_runtime_requirements_results.is_empty()
{
let removed_chunks = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ChunkRemove { chunk } => Some(chunk),
Expand Down Expand Up @@ -1479,6 +1488,7 @@ impl Compilation {
let create_hash_chunks = if let Some(mutations) = self
.incremental
.mutations_read(IncrementalPasses::CHUNKS_HASHES)
&& !self.chunk_hashes_results.is_empty()
{
let removed_chunks = mutations.iter().filter_map(|mutation| match mutation {
Mutation::ChunkRemove { chunk } => Some(*chunk),
Expand Down
1 change: 1 addition & 0 deletions crates/rspack_ids/src/named_module_ids_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ fn module_ids(&self, compilation: &mut rspack_core::Compilation) -> Result<()> {
let mut modules: IdentifierSet = if let Some(mutations) = compilation
.incremental
.mutations_read(IncrementalPasses::MODULE_IDS)
&& !module_ids.is_empty()
{
mutations
.iter()
Expand Down
Loading