Skip to content

Conversation

@hardfist
Copy link
Contributor

Summary

Adds ChunkGraph.getChunkGroupBlocks to allow retrieving all AsyncDependenciesBlock instances associated with a given ChunkGroup. This addresses the need to collect async blocks for a chunk group, as described in #12416.

Related links

Checklist

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

Open in Cursor Open in Web

This commit adds a new method to the ChunkGraph API that allows retrieving all async dependency blocks associated with a given chunk group. This enhances the ability to inspect and manipulate the chunk graph.

Co-authored-by: yangjianzju <yangjianzju@gmail.com>
Copilot AI review requested due to automatic review settings December 11, 2025 03:43
@cursor
Copy link

cursor bot commented Dec 11, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@netlify
Copy link

netlify bot commented Dec 11, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit ea281ac
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/693a658f9c85830008434886

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Dec 11, 2025
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 adds a new ChunkGraph.getChunkGroupBlocks method to retrieve all AsyncDependenciesBlock instances associated with a given ChunkGroup. This is the inverse operation of the existing getBlockChunkGroup method, allowing bidirectional traversal of the block-to-chunk-group relationship graph.

Key Changes:

  • Implements get_chunk_group_blocks in the Rust core ChunkGraph to filter blocks by chunk group
  • Exposes the method through the NAPI binding layer with proper wrapper types
  • Adds comprehensive test coverage using a custom webpack plugin

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/rspack_core/src/chunk_graph/mod.rs Implements core logic to find all blocks belonging to a chunk group by filtering the block-to-chunk-group map
crates/rspack_binding_api/src/chunk_graph.rs Adds NAPI binding for the new method, converting block identifiers to wrapper types
crates/rspack_binding_api/src/chunk_group.rs Changes visibility of chunk_group_ukey from private to pub(crate) to enable access from chunk_graph module
crates/node_binding/napi-binding.d.ts Adds TypeScript type definition for the new method
tests/rspack-test/configCases/chunk-graph/get-chunk-group-blocks/rspack.config.js Test plugin that verifies round-trip relationship: block → chunk group → blocks
tests/rspack-test/configCases/chunk-graph/get-chunk-group-blocks/index.js Test fixture with dynamic import to create an async block
tests/rspack-test/configCases/chunk-graph/get-chunk-group-blocks/foo.js Test module referenced by dynamic import

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

@hardfist hardfist changed the title Fix rspack issue 12416 feat: expose chunkgraph.getChunkGroupBlocks Dec 11, 2025
@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Dec 11, 2025
SyMind
SyMind previously approved these changes Dec 11, 2025
@hardfist hardfist changed the title feat: expose chunkgraph.getChunkGroupBlocks feat: expose ChunkGraph.getChunkGroupBlocks Dec 11, 2025

const blocks = compilation.chunkGraph.getChunkGroupBlocks(chunkGroup);
expect(blocks.length).toBe(1);
expect(blocks[0]).toBe(block);
Copy link
Member

@SyMind SyMind Dec 11, 2025

Choose a reason for hiding this comment

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

@cursoragent should check dependencies in AsyncDependenciesBlock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cursoragent should check dependencies in AsyncDependenciesBlock

Copy link

@cursor cursor bot Dec 11, 2025

Choose a reason for hiding this comment

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

ChunkGraph.getChunkGroupBlocks now returns AsyncDependenciesBlockWrapper instances, so consumers can immediately inspect each block’s dependencies (or nested blocks) via the existing getters on AsyncDependenciesBlock. The new config-case test exercises this by retrieving the block from the chunk group and confirming it matches the block captured from the entry module; from there you can call block.dependencies exactly as before. If there’s a specific dependency-related assertion you’d like covered, happy to extend the test accordingly.


Open in Cursor Open in Web

Learn more about Cursor Agents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cursoragent please include the dependency assertion in your tests

Copy link

@cursor cursor bot Dec 11, 2025

Choose a reason for hiding this comment

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

Good call — I’ll extend tests/rspack-test/configCases/chunk-graph/get-chunk-group-blocks/rspack.config.js to inspect the first block returned by getChunkGroupBlocks, grab its dependencies, and assert that it matches the dependency collected from the entry module (same count and same request/module). That will prove the API round-trip preserves the full block information, not just identity. I’ll push the update shortly.


Open in Cursor Open in Web

Learn more about Cursor Agents

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: 9b810aabde | PR: #12410

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB 0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: 9b810aabde | PR: #12410

Metric Current Baseline Change
📊 Total Size 823.6 KB 823.6 KB 0 B (0.0%)
📄 JavaScript 823.6 KB 823.6 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: 9b810aabde | PR: #12410

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB 0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-5k Bundle Diff

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: 9b810aabde | PR: #12410

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.3 KB 0 B (0.0%)
📄 JavaScript 984.3 KB 984.3 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: rome Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: 9b810aabde | PR: #12410

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB 0 B (0.0%)
📄 JavaScript 2.0 MB 2.0 MB 0 B (0.0%)
🎨 CSS 83.0 KB 83.0 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

📦 Binary Size-limit

Comparing ea281ac to fix: make splitChunks more stable (#12410) by Fy

❌ Size increased by 1.88KB from 48.21MB to 48.21MB (⬆️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 11, 2025

CodSpeed Performance Report

Merging #12418 will not alter performance

Comparing cursor/fix-rspack-issue-12416-2839 (ea281ac) with main (9b810aa)

Summary

✅ 17 untouched

Co-authored-by: yangjianzju <yangjianzju@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants