Conversation
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>
|
Cursor Agent can help with this pull request. Just |
|
|
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
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_blocksin 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.
|
|
||
| const blocks = compilation.chunkGraph.getChunkGroupBlocks(chunkGroup); | ||
| expect(blocks.length).toBe(1); | ||
| expect(blocks[0]).toBe(block); |
There was a problem hiding this comment.
@cursoragent should check dependencies in AsyncDependenciesBlock
There was a problem hiding this comment.
@cursoragent should check dependencies in AsyncDependenciesBlock
There was a problem hiding this comment.
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.
Learn more about Cursor Agents
There was a problem hiding this comment.
@cursoragent please include the dependency assertion in your tests
There was a problem hiding this comment.
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.
Learn more about Cursor Agents
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 1.88KB from 48.21MB to 48.21MB (⬆️0.00%) |
CodSpeed Performance ReportMerging #12418 will not alter performanceComparing Summary
|
Co-authored-by: yangjianzju <yangjianzju@gmail.com>
Summary
Adds
ChunkGraph.getChunkGroupBlocksto allow retrieving allAsyncDependenciesBlockinstances associated with a givenChunkGroup. This addresses the need to collect async blocks for a chunk group, as described in #12416.Related links
Checklist