Skip to content

Commit aca2ac5

Browse files
authored
Merge branch 'main' into duplicate-link
2 parents 68a8882 + 4db1b0e commit aca2ac5

File tree

6 files changed

+193
-142
lines changed

6 files changed

+193
-142
lines changed

.changeset/green-crews-melt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/node': patch
3+
---
4+
5+
fix: remove chunks from installedChunks on fail to enable retries

.changeset/plenty-birds-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/bridge-react': patch
3+
---
4+
5+
feat: add error detection for react v19 under the default export createBaseBridgeComponent

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"@storybook/node-logger": "8.1.11",
143143
"@storybook/react": "8.3.5",
144144
"@svgr/webpack": "8.1.0",
145-
"@swc-node/register": "1.10.9",
145+
"@swc-node/register": "1.10.10",
146146
"@swc/cli": "0.5.0",
147147
"@swc/core": "1.7.26",
148148
"@swc/helpers": "0.5.13",

packages/bridge/bridge-react/src/provider/create.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ function defaultCreateRoot(
3030
} {
3131
const reactVersion = ReactDOM.version || '';
3232
const isReact18 = reactVersion.startsWith('18');
33+
const isReact19 = reactVersion.startsWith('19');
34+
35+
// For React 19, throw error and suggest using version-specific import
36+
if (isReact19) {
37+
throw new Error(
38+
`React 19 detected. The default export is not compatible with React 19. ` +
39+
`Please use the version-specific import instead: ` +
40+
`import { createBridgeComponent } from '@module-federation/bridge-react/v19'`,
41+
);
42+
}
3343

3444
// For React 18, use createRoot API
3545
if (isReact18) {

packages/node/src/runtimePlugin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ export const installChunk = (
235235
}
236236
};
237237

238+
// Hoisted utility function to remove a chunk on fail
239+
export const deleteChunk = (
240+
chunkId: string,
241+
installedChunks: { [key: string]: any },
242+
): boolean => {
243+
delete installedChunks[chunkId];
244+
return true;
245+
};
246+
238247
// Hoisted function to set up webpack script loader
239248
export const setupScriptLoader = (): void => {
240249
__webpack_require__.l = (
@@ -297,7 +306,8 @@ export const setupChunkHandler = (
297306
chunkId,
298307
__webpack_require__.federation.rootOutputDir || '',
299308
(err, chunk) => {
300-
if (err) return reject(err);
309+
if (err)
310+
return deleteChunk(chunkId, installedChunks) && reject(err);
301311
if (chunk) installChunk(chunk, installedChunks);
302312
resolve(chunk);
303313
},
@@ -312,7 +322,8 @@ export const setupChunkHandler = (
312322
chunkName,
313323
__webpack_require__.federation.initOptions.name,
314324
(err, chunk) => {
315-
if (err) return reject(err);
325+
if (err)
326+
return deleteChunk(chunkId, installedChunks) && reject(err);
316327
if (chunk) installChunk(chunk, installedChunks);
317328
resolve(chunk);
318329
},

0 commit comments

Comments
 (0)