@@ -35,6 +35,8 @@ const EXPECTED_REMOTE_EXPOSE_PATHS = [
3535 './actionBundle' ,
3636 './infoBundle' ,
3737] . sort ( ) ;
38+ const REMOTE_EXPOSE_ENTRY_PATTERN =
39+ / ' ( \. \/ [ ^ ' ] + ) ' : \s * ' ( \. \/ s r c \/ c o m p o n e n t s \/ [ ^ ' ] + ) ' / g;
3840
3941type Mode = 'dev' | 'build' ;
4042
@@ -93,6 +95,15 @@ function createHostEnv(remotePort: number) {
9395 } ;
9496}
9597
98+ function getRemoteExposeEntries ( configSource : string ) {
99+ return Array . from ( configSource . matchAll ( REMOTE_EXPOSE_ENTRY_PATTERN ) ) . map (
100+ ( [ , exposeKey , importPath ] ) => ( {
101+ exposeKey,
102+ importPath,
103+ } ) ,
104+ ) ;
105+ }
106+
96107async function renderRemoteRscIntoHost ( { hostPort, page } : TestContext ) {
97108 const response = await fetch ( `http://127.0.0.1:${ hostPort } ${ HOST_RSC_URL } ` ) ;
98109 const html = await response . text ( ) ;
@@ -497,6 +508,12 @@ function runTests({ mode }: TestConfig) {
497508 path . join ( remoteDir , 'module-federation.config.ts' ) ,
498509 'utf-8' ,
499510 ) ;
511+ const remoteExposeEntries = getRemoteExposeEntries (
512+ moduleFederationConfigSource ,
513+ ) ;
514+ const remoteExposeKeys = remoteExposeEntries
515+ . map ( ( { exposeKey } ) => exposeKey )
516+ . sort ( ) ;
500517
501518 expect (
502519 componentSources . every (
@@ -535,6 +552,12 @@ function runTests({ mode }: TestConfig) {
535552 expect ( moduleFederationConfigSource ) . toContain (
536553 'nonComponentExposeEntries' ,
537554 ) ;
555+ expect ( remoteExposeKeys ) . toEqual ( EXPECTED_REMOTE_EXPOSE_PATHS ) ;
556+ expect (
557+ remoteExposeEntries . every ( ( { importPath } ) =>
558+ importPath . startsWith ( './src/components/' ) ,
559+ ) ,
560+ ) . toBe ( true ) ;
538561 } ) ;
539562
540563 it ( 'should not load callback helper expose chunk' , ( ) => {
0 commit comments