@@ -179,8 +179,13 @@ module.exports = async function () {
179179
180180 await writeWebpackFederationEntryPoint ( mainFilePath ) ;
181181
182- let { remotes , shared } = getMergedConfig ( 'npmscripts' , 'federation ') ;
182+ const config = getMergedConfig ( 'npmscripts' ) ;
183183
184+ const { build, federation} = config ;
185+
186+ let { exposes, remotes, shared} = federation ;
187+
188+ exposes = exposes || [ ] ;
184189 remotes = remotes || [ ] ;
185190 shared = shared || [ ] ;
186191
@@ -220,6 +225,7 @@ module.exports = async function () {
220225 plugins : [
221226 new ModuleFederationPlugin ( {
222227 exposes : {
228+ ...transformExposes ( exposes , build . input ) ,
223229 '.' : mainFilePath ,
224230 } ,
225231 filename : 'container.js' ,
@@ -256,3 +262,21 @@ module.exports = async function () {
256262 } ,
257263 } ;
258264} ;
265+
266+ function transformExposes ( exposes , inputDir ) {
267+ return exposes . reduce ( ( exposes , filePath ) => {
268+ if ( ! filePath . startsWith ( '<inputDir>/' ) ) {
269+ throw new Error (
270+ "Only paths relative to '<inputDir>/' are accepted as 'exposes'"
271+ ) ;
272+ }
273+
274+ filePath = filePath . replace ( / ^ < i n p u t D i r > \/ / , '' ) ;
275+
276+ const exposeName = filePath . replace ( / \. j s $ / i, '' ) ;
277+
278+ exposes [ exposeName ] = `./${ inputDir } /${ filePath } ` ;
279+
280+ return exposes ;
281+ } , { } ) ;
282+ }
0 commit comments