Skip to content

Conversation

@hardfist
Copy link
Contributor

@hardfist hardfist commented Jan 21, 2026

Summary

Refactor artifact recovery in rebuild.rs to use the unified ArtifactExt trait and recover_artifact function for
all artifact types, including wrapped types.

Changes

  • Extended ArtifactExt trait with should_recover and recover methods for unified artifact recovery logic
  • Added documentation in agents/ARTIFACTS.md explaining the artifact design and usage
  • Before
 if new_compilation
      .incremental
      .mutations_readable(IncrementalPasses::INFER_ASYNC_MODULES)
    {
      new_compilation.async_modules_artifact =
        std::mem::take(&mut self.compilation.async_modules_artifact);
    }
  • After
 recover_artifact(                                                                                                 
   incremental,                                                                                                    
   &mut new_compilation.async_modules_artifact,                                                                    
   &mut self.compilation.async_modules_artifact,                                                                   
 );      

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Jan 21, 2026

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 5484541
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69708a2b146b800008e2831d

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: refactor labels Jan 21, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
react-5k 2.7 MB 0
ui-components 2.1 MB 0
rome 984.2 KB 0

Generated by Rsdoctor GitHub Action

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 21, 2026

Deploying rspack-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5484541
Status: ✅  Deploy successful!
Preview URL: https://89240449.rspack-v2.pages.dev
Branch Preview URL: https://yj-artifact-trait.rspack-v2.pages.dev

View logs

@github-actions
Copy link
Contributor

github-actions bot commented Jan 21, 2026

📦 Binary Size-limit

Comparing 5484541 to chore: disable generation of wasm binding (#12802) by CPunisher

🎉 Size decreased by 1.50KB from 48.01MB to 48.01MB (⬇️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 21, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing yj/artifact-trait (5484541) with main (b7bb53d)

Summary

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@hardfist hardfist force-pushed the yj/artifact-trait branch 3 times, most recently from 8bcb1b7 to c550637 Compare January 21, 2026 08:08
@hardfist hardfist marked this pull request as ready for review January 21, 2026 08:21
Copilot AI review requested due to automatic review settings January 21, 2026 08:21
@hardfist hardfist enabled auto-merge (squash) January 21, 2026 08:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a unified ArtifactExt trait to streamline artifact recovery during incremental compilation rebuilds. The refactoring replaces repetitive conditional recovery logic with a trait-based approach that associates each artifact with its corresponding incremental pass.

Changes:

  • Introduced ArtifactExt trait with PASS constant, should_recover, and recover methods to unify artifact recovery logic
  • Implemented ArtifactExt for all artifact types (14 artifacts total) and wrapper types (DerefOption, Arc<AtomicRefCell>, BindingCell, Box)
  • Refactored rebuild.rs to use the new recover_artifact helper function, replacing ~90 lines of repetitive conditional logic with ~80 lines of clean, uniform recovery calls
  • Added comprehensive documentation in agents/ARTIFACTS.md explaining the artifact system design and usage

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
crates/rspack_core/src/artifacts/mod.rs Defines ArtifactExt trait and wrapper implementations for unified artifact recovery
crates/rspack_core/src/utils/deref_option.rs Implements ArtifactExt for DerefOption<T> wrapper
crates/rspack_core/src/compiler/rebuild.rs Refactored to use recover_artifact function instead of manual conditional logic
crates/rspack_core/src/artifacts/async_modules_artifact.rs Added ArtifactExt implementation with INFER_ASYNC_MODULES pass
crates/rspack_core/src/artifacts/dependencies_diagnostics_artifact.rs Added ArtifactExt implementation with DEPENDENCIES_DIAGNOSTICS pass
crates/rspack_core/src/artifacts/side_effects_do_optimize_artifact.rs Changed from type alias to newtype struct with ArtifactExt implementation
crates/rspack_core/src/artifacts/code_generation_results.rs Added ArtifactExt implementation with MODULES_CODEGEN pass
crates/rspack_core/src/artifacts/module_ids_artifact.rs Added ArtifactExt implementation with MODULE_IDS pass
crates/rspack_core/src/artifacts/chunk_ids_artifact.rs Added ArtifactExt implementation with CHUNK_IDS pass
crates/rspack_core/src/artifacts/cgm_hash_artifact.rs Added ArtifactExt implementation with MODULES_HASHES pass
crates/rspack_core/src/artifacts/cgm_runtime_requirement_artifact.rs Added ArtifactExt implementation with MODULES_RUNTIME_REQUIREMENTS pass
crates/rspack_core/src/artifacts/cgc_runtime_requirements_artifact.rs Added ArtifactExt implementation with CHUNKS_RUNTIME_REQUIREMENTS pass
crates/rspack_core/src/artifacts/chunk_hashes_artifact.rs Added ArtifactExt implementation with CHUNKS_HASHES pass
crates/rspack_core/src/artifacts/chunk_render_artifact.rs Added ArtifactExt implementation with CHUNKS_RENDER pass
crates/rspack_core/src/artifacts/chunk_render_cache_artifact.rs Added ArtifactExt with custom recover that calls start_next_generation
crates/rspack_core/src/artifacts/code_generate_cache_artifact.rs Added ArtifactExt with custom recover that calls start_next_generation
crates/rspack_core/src/artifacts/process_runtime_requirements_cache_artifact.rs Added ArtifactExt with custom recover that calls start_next_generation
crates/rspack_core/src/artifacts/imported_by_defer_modules_artifact.rs Added ArtifactExt implementation with empty pass (has FIXME comment)
crates/rspack_core/src/artifacts/build_module_graph_artifact.rs Added ArtifactExt implementation with MAKE pass
crates/rspack_core/src/artifacts/build_chunk_graph_artifact.rs Added ArtifactExt implementation with BUILD_CHUNK_GRAPH pass
agents/ARTIFACTS.md New documentation file explaining artifact system design and usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hardfist hardfist merged commit 53993c1 into main Jan 21, 2026
84 of 86 checks passed
@hardfist hardfist deleted the yj/artifact-trait branch January 21, 2026 08:56
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
2 tasks
LingyuCoder pushed a commit that referenced this pull request Jan 22, 2026
* refactor: introduce ArtifactExt trait

* refactor: fix wrapper
LingyuCoder pushed a commit that referenced this pull request Jan 22, 2026
* refactor: introduce ArtifactExt trait

* refactor: fix wrapper
hardfist added a commit that referenced this pull request Jan 22, 2026
* refactor: introduce ArtifactExt trait

* refactor: fix wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants