Skip to content

Commit eb437ca

Browse files
chore(federation): share react singletons
1 parent 0a41f60 commit eb437ca

6 files changed

Lines changed: 28 additions & 0 deletions

File tree

examples/federation/component-app/rspack.browser.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ module.exports = {
4545
'./Logo': './src/Logo.jsx',
4646
'./ToolTip': './src/ToolTip.jsx',
4747
},
48+
shared: {
49+
react: { singleton: true, requiredVersion: '19.2.3' },
50+
'react-dom': { singleton: true, requiredVersion: '19.2.3' },
51+
},
4852
}),
4953
new HtmlRspackPlugin({ template: './public/index.html' }),
5054
],

examples/federation/component-app/rspack.node.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ module.exports = {
7272
'./Logo': './src/Logo.jsx',
7373
'./ToolTip': './src/ToolTip.jsx',
7474
},
75+
shared: {
76+
react: { singleton: true, requiredVersion: '19.2.3' },
77+
'react-dom': { singleton: true, requiredVersion: '19.2.3' },
78+
},
7579
}),
7680
],
7781
};

examples/federation/component-app/rstest.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export default defineConfig({
2323
)}`,
2424
},
2525
runtimePlugins: ['@module-federation/node/runtimePlugin'],
26+
shared: {
27+
react: { singleton: true, eager: true, requiredVersion: '19.2.3' },
28+
'react-dom': {
29+
singleton: true,
30+
eager: true,
31+
requiredVersion: '19.2.3',
32+
},
33+
},
2634
}),
2735
);
2836
return config;

examples/federation/main-app/rspack.browser.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ module.exports = {
3636
'node-local-remote':
3737
'node_local_remote@http://localhost:3004/remoteEntry.js',
3838
},
39+
shared: {
40+
react: { singleton: true, requiredVersion: '19.2.3' },
41+
'react-dom': { singleton: true, requiredVersion: '19.2.3' },
42+
},
3943
}),
4044
new HtmlRspackPlugin({ template: './public/index.html' }),
4145
],

examples/federation/node-local-remote/rspack.browser.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
name: 'node_local_remote',
1818
filename: 'remoteEntry.js',
1919
exposes: { './test': './src/test.js' },
20+
shared: {
21+
react: { singleton: true, requiredVersion: '19.2.3' },
22+
'react-dom': { singleton: true, requiredVersion: '19.2.3' },
23+
},
2024
}),
2125
],
2226
};

examples/federation/node-local-remote/rspack.node.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ module.exports = {
2222
exposes: {
2323
'./test': './src/test.js',
2424
},
25+
shared: {
26+
react: { singleton: true, requiredVersion: '19.2.3' },
27+
'react-dom': { singleton: true, requiredVersion: '19.2.3' },
28+
},
2529
}),
2630
],
2731
};

0 commit comments

Comments
 (0)