Skip to content

Commit c7b6278

Browse files
committed
fix(rsc-mf): append remote-module alias for nested mixed chunk
1 parent 8e6846a commit c7b6278

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/integration/rsc-mf/host/server/modern.server.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const shouldProxyRemoteAsset = (pathname: string) => {
1919
return false;
2020
};
2121

22+
const REMOTE_COUNTER_ALIAS_MODULE =
23+
'remote-module:rscRemote:./src/components/RemoteClientCounter.tsx';
24+
const REMOTE_COUNTER_SOURCE_MODULE = './src/components/RemoteClientCounter.tsx';
25+
const createRemoteNestedMixedAliasChunk = () =>
26+
`\n;(globalThis["chunk_rscHost"] = globalThis["chunk_rscHost"] || []).push([["__federation_expose_RemoteNestedMixed_alias"],{"${REMOTE_COUNTER_ALIAS_MODULE}":function(module,__unused,__webpack_require__){module.exports=__webpack_require__("${REMOTE_COUNTER_SOURCE_MODULE}");}}]);`;
27+
2228
const proxyRemoteFederationAsset: MiddlewareHandler = async (c, next) => {
2329
const reqUrl = new URL(c.req.url);
2430
const pathname = reqUrl.pathname;
@@ -42,6 +48,19 @@ const proxyRemoteFederationAsset: MiddlewareHandler = async (c, next) => {
4248
return;
4349
}
4450

51+
if (
52+
pathname === '/static/js/async/__federation_expose_RemoteNestedMixed.js'
53+
) {
54+
const chunkText = await upstream.text();
55+
c.res = new Response(`${chunkText}${createRemoteNestedMixedAliasChunk()}`, {
56+
status: upstream.status,
57+
headers: {
58+
'content-type': 'application/javascript; charset=utf-8',
59+
},
60+
});
61+
return;
62+
}
63+
4564
c.res = new Response(await upstream.arrayBuffer(), {
4665
status: upstream.status,
4766
headers: upstream.headers,

0 commit comments

Comments
 (0)