@@ -5,7 +5,7 @@ import type {
55 ManifestModuleInfos ,
66 moduleFederationPlugin ,
77} from '@module-federation/sdk' ;
8- import { getBuildVersion , parseOptions } from './utils' ;
8+ import { parseOptions } from './utils' ;
99import type { EntryObject } from 'webpack' ;
1010import { BasicPluginOptionsManager } from './BasicPluginOptionsManager' ;
1111
@@ -65,7 +65,7 @@ class ContainerManager extends BasicPluginOptionsManager<moduleFederationPlugin.
6565 const [ exposeKey , exposeObj ] = item ;
6666 sum [ exposeKey ] = exposeObj ;
6767 return sum ;
68- } , { } ) ;
68+ } , { } as moduleFederationPlugin . ExposesObject ) ;
6969 }
7070 // { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
7171 get exposeFileNameImportMap ( ) : Record < string , string [ ] > {
@@ -81,30 +81,36 @@ class ContainerManager extends BasicPluginOptionsManager<moduleFederationPlugin.
8181 name : item . name || generateExposeFilename ( key , false ) ,
8282 } ) ,
8383 ) ;
84- return parsedOptions . reduce ( ( sum , item ) => {
85- const [ _exposeKey , exposeObj ] = item ;
86- const { name, import : importPath } = exposeObj ;
87- sum [ name ] = importPath ;
88- return sum ;
89- } , { } ) ;
84+ return parsedOptions . reduce (
85+ ( sum , item ) => {
86+ const [ _exposeKey , exposeObj ] = item ;
87+ const { name, import : importPath } = exposeObj ;
88+ sum [ name ] = importPath ;
89+ return sum ;
90+ } ,
91+ { } as Record < string , string [ ] > ,
92+ ) ;
9093 }
9194
9295 // { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
93- get exposeObject ( ) : Record < string , string > {
96+ get exposeObject ( ) : Record < string , string [ ] > {
9497 const parsedOptions = this . _parseOptions ( ) ;
9598
96- return parsedOptions . reduce ( ( sum , item ) => {
97- const [ exposeKey , exposeObject ] = item ;
98- sum [ exposeKey ] = [ ] ;
99- exposeObject . import . forEach ( ( item ) => {
100- const relativePath = path . relative (
101- '.' ,
102- item . replace ( path . extname ( item ) , '' ) ,
103- ) ;
104- sum [ exposeKey ] . push ( relativePath ) ;
105- } ) ;
106- return sum ;
107- } , { } ) ;
99+ return parsedOptions . reduce (
100+ ( sum , item ) => {
101+ const [ exposeKey , exposeObject ] = item ;
102+ sum [ exposeKey ] = [ ] ;
103+ exposeObject . import . forEach ( ( item ) => {
104+ const relativePath = path . relative (
105+ '.' ,
106+ item . replace ( path . extname ( item ) , '' ) ,
107+ ) ;
108+ sum [ exposeKey ] . push ( relativePath ) ;
109+ } ) ;
110+ return sum ;
111+ } ,
112+ { } as Record < string , string [ ] > ,
113+ ) ;
108114 }
109115
110116 // { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
0 commit comments