File tree Expand file tree Collapse file tree 7 files changed +38
-1
lines changed
crates/rspack_core/src/build_chunk_graph
packages/rspack-test-tools/tests/configCases/chunk-graph/disconnect-unneeded-chunks Expand file tree Collapse file tree 7 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,11 @@ pub fn remove_available_modules(
220220 continue ;
221221 }
222222
223+ let outgoings = chunk. outgoings_mut ( ) ;
224+ for remove_id in & removed {
225+ outgoings. swap_remove ( remove_id) ;
226+ }
227+
223228 let chunk = & chunks[ chunk_index] . 1 . chunk_desc ;
224229 let outgoings = chunk. outgoings ( ) ;
225230
@@ -229,7 +234,7 @@ pub fn remove_available_modules(
229234 // if all incomings from current chunk are removed, we can remove this child
230235 if child_chunk. incomings ( ) . iter ( ) . all ( |incoming| {
231236 // if all incomings are not from current chunk, we disconnect them
232- !removed . contains ( incoming) && ! outgoings. contains ( incoming)
237+ !outgoings. contains ( incoming)
233238 } ) {
234239 disconnect_children. insert ( * child) ;
235240 }
Original file line number Diff line number Diff line change @@ -97,6 +97,15 @@ impl ChunkDesc {
9797 }
9898 }
9999
100+ pub ( crate ) fn outgoings_mut (
101+ & mut self ,
102+ ) -> & mut IndexSet < AsyncDependenciesBlockIdentifier , BuildHasherDefault < IdentifierHasher > > {
103+ match self {
104+ ChunkDesc :: Entry ( entry) => & mut entry. outgoing_blocks ,
105+ ChunkDesc :: Chunk ( chunk) => & mut chunk. outgoing_blocks ,
106+ }
107+ }
108+
100109 pub ( crate ) fn incomings ( & self ) -> & HashSet < AsyncDependenciesBlockIdentifier > {
101110 match self {
102111 ChunkDesc :: Entry ( entry) => & entry. incoming_blocks ,
Original file line number Diff line number Diff line change 1+ export const value = 1
Original file line number Diff line number Diff line change 1+ import './routes.js'
2+
3+ it ( 'should load routes' , async ( ) => {
4+ const { value} = await import ( /*webpackChunkName: "routes"*/ './module.js' )
5+
6+ expect ( await value ) . toBe ( 1 )
7+
8+ // foo should contain no children at all
9+ const chunkId = __STATS__ . namedChunkGroups . routes . chunks [ 0 ] ;
10+ const chunk = __STATS__ . chunks . find ( c => c . id === chunkId ) ;
11+ expect ( chunk . children . length ) . toBe ( 0 ) ;
12+ } )
Original file line number Diff line number Diff line change 1+ export * from './routes'
Original file line number Diff line number Diff line change 1+ export const value = import ( /*webpackChunkName: "foo"*/ './foo.js' ) . then ( ( { value } ) => value )
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ output : {
3+ chunkFilename : "[name].js"
4+ } ,
5+ stats : {
6+ chunkGroups : true
7+ }
8+ } ;
You can’t perform that action at this time.
0 commit comments