@@ -47,12 +47,6 @@ const BundlerRuntimePath = require.resolve(
4747const RuntimePath = require . resolve ( '@module-federation/runtime' , {
4848 paths : [ RuntimeToolsPath ] ,
4949} ) ;
50- const EmbeddedRuntimePath = require . resolve (
51- '@module-federation/runtime/embedded' ,
52- {
53- paths : [ RuntimeToolsPath ] ,
54- } ,
55- ) ;
5650
5751const federationGlobal = getFederationGlobalScope ( RuntimeGlobals ) ;
5852
@@ -330,17 +324,28 @@ class FederationRuntimePlugin {
330324 ) ;
331325 }
332326
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 || { } ;
336331
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+ }
341340 }
342341
342+ return runtimePath ;
343+ }
344+
345+ setRuntimeAlias ( compiler : Compiler ) {
346+ const { implementation } = this . options || { } ;
343347 const alias : any = compiler . options . resolve . alias || { } ;
348+ const runtimePath = this . getRuntimeAlias ( compiler ) ;
344349 alias [ '@module-federation/runtime$' ] =
345350 alias [ '@module-federation/runtime$' ] || runtimePath ;
346351 alias [ '@module-federation/runtime-tools$' ] =
@@ -408,11 +413,12 @@ class FederationRuntimePlugin {
408413
409414 new HoistContainerReferences ( ) . apply ( compiler ) ;
410415
416+ const runtimePath = this . getRuntimeAlias ( compiler ) ;
411417 new compiler . webpack . NormalModuleReplacementPlugin (
412418 / @ m o d u l e - f e d e r a t i o n \/ r u n t i m e / ,
413419 ( resolveData ) => {
414420 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 ;
416422
417423 if ( resolveData . createData ) {
418424 resolveData . createData . request = resolveData . request ;
0 commit comments