@@ -38,7 +38,7 @@ import { defineConfig } from '@rslib/core';
3838export default defineConfig ({
3939 lib: [
4040 // ... other format
41- // [!code highlight:35 ]
41+ // [!code highlight:37 ]
4242 {
4343 format: ' mf' ,
4444 output: {
@@ -126,23 +126,24 @@ import { pluginReact } from '@rsbuild/plugin-react';
126126export default defineConfig ({
127127 plugins: [
128128 pluginReact (),
129- pluginModuleFederation ({ // [!code highlight]
130- name: ' rsbuild_host' , // [!code highlight]
131- remotes: { // [!code highlight]
132- rslib: ' rslib@http://localhost:3001/mf/mf-manifest.json' , // [!code highlight]
133- }, // [!code highlight]
134- shared: { // [!code highlight]
135- react: { // [!code highlight]
136- singleton: true , // [!code highlight]
137- }, // [!code highlight]
138- ' react-dom' : { // [!code highlight]
139- singleton: true , // [!code highlight]
140- }, // [!code highlight]
141- }, // [!code highlight]
142- // Enable this when the output of Rslib is build under 'production' mode, while the host app is 'development'. // [!code highlight]
143- // Reference: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs // [!code highlight]
144- shareStrategy: ' loaded-first' , // [!code highlight]
145- }), // [!code highlight]
129+ // [!code highlight:17]
130+ pluginModuleFederation ({
131+ name: ' rsbuild_host' ,
132+ remotes: {
133+ rslib: ' rslib@http://localhost:3001/mf/mf-manifest.json' ,
134+ },
135+ shared: {
136+ react: {
137+ singleton: true ,
138+ },
139+ ' react-dom' : {
140+ singleton: true ,
141+ },
142+ },
143+ // Enable this when the output of Rslib is build under 'production' mode, while the host app is 'development'.
144+ // Reference: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs
145+ shareStrategy: ' loaded-first' ,
146+ }),
146147 ],
147148});
148149```
@@ -200,7 +201,8 @@ First, set up Storybook with the Rslib project. You can refer to the [Storybook
200201 options: {},
201202 },
202203 addons: [
203- { // [!code highlight:20]
204+ // [!code highlight:21]
205+ {
204206 name: getAbsolutePath (' storybook-addon-rslib' ),
205207 options: {
206208 rslib: {
@@ -233,8 +235,9 @@ Import components from remote module.
233235
234236``` ts title="stories/index.stories.tsx"
235237import React from ' react' ;
236- // Load your remote module here, Storybook will act as the host app. // [!code highlight]
237- import { Counter } from ' rslib-module' ; // [!code highlight]
238+ // [!code highlight:2]
239+ // Load your remote module here, Storybook will act as the host app.
240+ import { Counter } from ' rslib-module' ;
238241
239242const Component = () => <Counter />;
240243
0 commit comments