File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -579,6 +579,24 @@ class Chunk {
579579 } ;
580580 }
581581
582+ hasModuleInGraph ( filterFn ) {
583+ const chunksProcessed = new Set ( ) ;
584+ const queue = [ this ] ;
585+
586+ while ( queue . length > 0 ) {
587+ const chunk = queue . pop ( ) ;
588+ if ( chunk . getModules ( ) . some ( filterFn ) )
589+ return true ;
590+ for ( const next of chunk . chunksIterable ) {
591+ if ( ! chunksProcessed . has ( next ) ) {
592+ chunksProcessed . add ( next ) ;
593+ queue . push ( next ) ;
594+ }
595+ }
596+ }
597+ return false ;
598+ }
599+
582600 sortModules ( sortByFn ) {
583601 this . _modules . sortWith ( sortByFn || sortById ) ;
584602 }
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ class FetchCompileWasmMainTemplatePlugin {
88
99 apply ( mainTemplate ) {
1010 mainTemplate . plugin ( "local-vars" , ( source , chunk ) => {
11+ if ( ! chunk . hasModuleInGraph ( m => m . type . startsWith ( "webassembly" ) ) )
12+ return source ;
1113 return mainTemplate . asString ( [
1214 source ,
1315 "" ,
@@ -69,6 +71,8 @@ class FetchCompileWasmMainTemplatePlugin {
6971 ] ) ;
7072 } ) ;
7173 mainTemplate . plugin ( "require-extensions" , ( source , chunk ) => {
74+ if ( ! chunk . hasModuleInGraph ( m => m . type . startsWith ( "webassembly" ) ) )
75+ return source ;
7276 return mainTemplate . asString ( [
7377 source ,
7478 "" ,
You can’t perform that action at this time.
0 commit comments