Skip to content

Commit c402af6

Browse files
committed
fix(rsc-mf): alias multiple remote counter module request keys
1 parent ec9e952 commit c402af6

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ const serverOnlyEmptyPath = path.join(
88
'empty.js',
99
);
1010
const remoteDistStaticDir = path.resolve(__dirname, '../remote/dist/static');
11-
const REMOTE_COUNTER_ALIAS_MODULE =
12-
'remote-module:rscRemote:./src/components/RemoteClientCounter.tsx';
11+
const REMOTE_COUNTER_ALIAS_MODULES = [
12+
'remote-module:rscRemote:./src/components/RemoteClientCounter.tsx',
13+
'remote-module:rscRemote:./RemoteClientCounter',
14+
'remote-module:rscRemote:./RemoteClientCounter.tsx',
15+
];
1316
const createRemoteNestedMixedAliasChunk = (remoteCounterModuleId: string) =>
14-
`\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__(${JSON.stringify(remoteCounterModuleId)});}}]);`;
17+
`\n;(globalThis["chunk_rscHost"] = globalThis["chunk_rscHost"] || []).push([["__federation_expose_RemoteNestedMixed_alias"],{${REMOTE_COUNTER_ALIAS_MODULES.map(
18+
aliasModule =>
19+
`"${aliasModule}":function(module,__unused,__webpack_require__){module.exports=__webpack_require__(${JSON.stringify(
20+
remoteCounterModuleId,
21+
)});}`,
22+
).join(',')}}]);`;
1523

1624
const resolveRemoteCounterModuleId = (chunkText: string) => {
1725
const marker = 'remote-client-server-count';

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

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

22-
const REMOTE_COUNTER_ALIAS_MODULE =
23-
'remote-module:rscRemote:./src/components/RemoteClientCounter.tsx';
22+
const REMOTE_COUNTER_ALIAS_MODULES = [
23+
'remote-module:rscRemote:./src/components/RemoteClientCounter.tsx',
24+
'remote-module:rscRemote:./RemoteClientCounter',
25+
'remote-module:rscRemote:./RemoteClientCounter.tsx',
26+
];
2427
const REMOTE_COUNTER_SOURCE_MODULE = './src/components/RemoteClientCounter.tsx';
2528
const REMOTE_ACTION_ID_TO_PROXY_ACTION_ID = {
2629
'606c30f35d74d843171a8a71358eda595991e4ee16270e9f052af3faef57a19999':
@@ -34,7 +37,10 @@ const REMOTE_ACTION_ID_TO_PROXY_ACTION_ID = {
3437
} as const;
3538
const PROXY_REQUEST_HEADER = 'x-rsc-mf-proxy-action';
3639
const createRemoteNestedMixedAliasChunk = () =>
37-
`\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}");}}]);`;
40+
`\n;(globalThis["chunk_rscHost"] = globalThis["chunk_rscHost"] || []).push([["__federation_expose_RemoteNestedMixed_alias"],{${REMOTE_COUNTER_ALIAS_MODULES.map(
41+
aliasModule =>
42+
`"${aliasModule}":function(module,__unused,__webpack_require__){module.exports=__webpack_require__("${REMOTE_COUNTER_SOURCE_MODULE}");}`,
43+
).join(',')}}]);`;
3844

3945
const proxyRemoteRscAction: MiddlewareHandler = async (c, next) => {
4046
const request = c.req.raw;

0 commit comments

Comments
 (0)