@@ -47,12 +47,6 @@ const BundlerRuntimePath = require.resolve(
47
47
const RuntimePath = require . resolve ( '@module-federation/runtime' , {
48
48
paths : [ RuntimeToolsPath ] ,
49
49
} ) ;
50
- const EmbeddedRuntimePath = require . resolve (
51
- '@module-federation/runtime/embedded' ,
52
- {
53
- paths : [ RuntimeToolsPath ] ,
54
- } ,
55
- ) ;
56
50
57
51
const federationGlobal = getFederationGlobalScope ( RuntimeGlobals ) ;
58
52
@@ -330,17 +324,28 @@ class FederationRuntimePlugin {
330
324
) ;
331
325
}
332
326
333
- setRuntimeAlias ( compiler : Compiler ) {
334
- const { experiments, implementation } = this . options || { } ;
335
- let runtimePath = EmbeddedRuntimePath ;
327
+ getRuntimeAlias ( compiler : Compiler ) {
328
+ const { implementation } = this . options || { } ;
329
+ let runtimePath = RuntimePath ;
330
+ const alias : any = compiler . options . resolve . alias || { } ;
336
331
337
- if ( implementation ) {
338
- runtimePath = require . resolve ( `@module-federation/runtime/embedded` , {
339
- paths : [ implementation ] ,
340
- } ) ;
332
+ if ( alias [ '@module-federation/runtime$' ] ) {
333
+ runtimePath = alias [ '@module-federation/runtime$' ] ;
334
+ } else {
335
+ if ( implementation ) {
336
+ runtimePath = require . resolve ( `@module-federation/runtime` , {
337
+ paths : [ implementation ] ,
338
+ } ) ;
339
+ }
341
340
}
342
341
342
+ return runtimePath ;
343
+ }
344
+
345
+ setRuntimeAlias ( compiler : Compiler ) {
346
+ const { implementation } = this . options || { } ;
343
347
const alias : any = compiler . options . resolve . alias || { } ;
348
+ const runtimePath = this . getRuntimeAlias ( compiler ) ;
344
349
alias [ '@module-federation/runtime$' ] =
345
350
alias [ '@module-federation/runtime$' ] || runtimePath ;
346
351
alias [ '@module-federation/runtime-tools$' ] =
@@ -408,11 +413,12 @@ class FederationRuntimePlugin {
408
413
409
414
new HoistContainerReferences ( ) . apply ( compiler ) ;
410
415
416
+ const runtimePath = this . getRuntimeAlias ( compiler ) ;
411
417
new compiler . webpack . NormalModuleReplacementPlugin (
412
418
/ @ m o d u l e - f e d e r a t i o n \/ r u n t i m e / ,
413
419
( resolveData ) => {
414
420
if ( / w e b p a c k - b u n d l e r - r u n t i m e / . test ( resolveData . contextInfo . issuer ) ) {
415
- resolveData . request = RuntimePath ;
421
+ resolveData . request = runtimePath ;
416
422
417
423
if ( resolveData . createData ) {
418
424
resolveData . createData . request = resolveData . request ;
0 commit comments