File tree Expand file tree Collapse file tree 2 files changed +23
-43
lines changed
Expand file tree Collapse file tree 2 files changed +23
-43
lines changed Original file line number Diff line number Diff line change @@ -165,9 +165,30 @@ class ConsumeSharedModule extends Module {
165165 * "default-with-named": Provide a namespace object with named and default export. namespace = { ...exports, default: exports }
166166 */
167167 getExportsType ( moduleGraph , strict ) {
168- if ( this . buildMeta && this . buildMeta . exportsType === "namespace" ) {
169- return "namespace" ;
168+ if ( this . options . import ) {
169+ let fallbackModule = null ;
170+
171+ if ( this . options . eager ) {
172+ const dep = this . dependencies [ 0 ] ;
173+ if ( dep ) {
174+ fallbackModule = moduleGraph . getModule ( dep ) ;
175+ }
176+ } else {
177+ const block = this . blocks [ 0 ] ;
178+ if ( block && block . dependencies . length > 0 ) {
179+ fallbackModule = moduleGraph . getModule ( block . dependencies [ 0 ] ) ;
180+ }
181+ }
182+
183+ if (
184+ fallbackModule &&
185+ fallbackModule . buildMeta &&
186+ fallbackModule . buildMeta . exportsType === "namespace"
187+ ) {
188+ return "namespace" ;
189+ }
170190 }
191+
171192 return "dynamic" ;
172193 }
173194
Original file line number Diff line number Diff line change @@ -371,47 +371,6 @@ class ConsumeSharedPlugin {
371371 ) ;
372372 }
373373 ) ;
374-
375- compilation . hooks . finishModules . tapAsync (
376- { name : PLUGIN_NAME , stage : 10 } ,
377- ( modules , callback ) => {
378- for ( const module of modules ) {
379- if (
380- ! ( module instanceof ConsumeSharedModule ) ||
381- ! module . options . import
382- ) {
383- continue ;
384- }
385-
386- let dependency ;
387- if ( module . options . eager ) {
388- dependency = module . dependencies [ 0 ] ;
389- } else {
390- const block = module . blocks [ 0 ] ;
391- if ( block ) {
392- dependency = block . dependencies [ 0 ] ;
393- }
394- }
395-
396- if ( dependency ) {
397- const fallbackModule =
398- compilation . moduleGraph . getModule ( dependency ) ;
399- if (
400- fallbackModule &&
401- fallbackModule . buildMeta &&
402- fallbackModule . buildInfo
403- ) {
404- module . buildMeta = { ...fallbackModule . buildMeta } ;
405- module . buildInfo = { ...fallbackModule . buildInfo } ;
406- compilation . moduleGraph
407- . getExportsInfo ( module )
408- . setUnknownExportsProvided ( ) ;
409- }
410- }
411- }
412- callback ( ) ;
413- }
414- ) ;
415374 }
416375 ) ;
417376 }
You can’t perform that action at this time.
0 commit comments