File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
js-packages/webpack-config/src Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,13 @@ class RegisterAsyncChunksPlugin {
81
81
const chunkModules = ( c ) => Array . from ( compilation . chunkGraph . getChunkModulesIterable ( c ) ) ;
82
82
83
83
const relevantChunk = chunks . find ( ( chunk ) =>
84
- chunkModules ( chunk ) ?. find (
85
- ( module ) =>
86
- module . resource ?. split ( '.' ) [ 0 ] === importPathResolved || module . rootModule ?. resource ?. split ( '.' ) [ 0 ] === importPathResolved
87
- )
84
+ chunkModules ( chunk ) ?. find ( ( module ) => {
85
+ const resourceWithoutExt = module . resource ? module . resource . replace ( path . extname ( module . resource ) , '' ) : '' ;
86
+ const rootResourceWithoutExt = module . rootModule ?. resource
87
+ ? module . rootModule . resource . replace ( path . extname ( module . rootModule . resource ) , '' )
88
+ : '' ;
89
+ return resourceWithoutExt === importPathResolved || rootResourceWithoutExt === importPathResolved ;
90
+ } )
88
91
) ;
89
92
90
93
if ( ! relevantChunk ) {
@@ -94,7 +97,11 @@ class RegisterAsyncChunksPlugin {
94
97
95
98
const relevantChunkModules = chunkModules ( relevantChunk ) ;
96
99
const mainModule = relevantChunkModules . filter ( ( m ) => {
97
- return m . resource ?. split ( '.' ) [ 0 ] === importPathResolved || m . rootModule ?. resource ?. split ( '.' ) [ 0 ] === importPathResolved ;
100
+ const resourceWithoutExt = m . resource ? m . resource . replace ( path . extname ( m . resource ) , '' ) : '' ;
101
+ const rootResourceWithoutExt = m . rootModule ?. resource
102
+ ? m . rootModule . resource . replace ( path . extname ( m . rootModule . resource ) , '' )
103
+ : '' ;
104
+ return resourceWithoutExt === importPathResolved || rootResourceWithoutExt === importPathResolved ;
98
105
} ) [ 0 ] ;
99
106
const otherRelevantChunkModules = relevantChunkModules . filter ( ( m ) => m !== mainModule ) ;
100
107
You can’t perform that action at this time.
0 commit comments