Skip to content

Commit 00d63a9

Browse files
committed
[Blog] [Ajay]: Add more details
1 parent 2a6f021 commit 00d63a9

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

TestArena/Blog/React/ModuleFederationDemo.razor

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,17 @@ module-federation-demo/
120120

121121
<h4>🔌 Step 1: Setup the Remote App</h4>
122122
<p>The <code>remote-app</code> exposes a <code>FruitsTable</code> component.</p>
123+
<p>
124+
The below code snippet configures the Webpack Module Federation Plugin for the <code>remote-app</code>. It specifies:
125+
<ul>
126+
<li><strong>name</strong>: The unique name of the remote application (<code>remoteApp</code>).</li>
127+
<li><strong>filename</strong>: The name of the file (<code>remoteEntry.js</code>) that will act as the entry point for exposing modules.</li>
128+
<li><strong>exposes</strong>: Declares the modules/components to be exposed by the remote app. Here, the <code>FruitsTable</code> component is exposed.</li>
129+
<li><strong>shared</strong>: Specifies shared dependencies like <code>react</code> and <code>react-dom</code>, ensuring they are loaded as singletons to avoid duplication.</li>
130+
</ul>
131+
</p>
123132

124-
<h5>remote-app/webpack.config.js</h5>
133+
<h5>📜 remote-app/webpack.config.js</h5>
125134
<CodeSnippet Number="1" Language="js" Description="Running remote app">
126135
new ModuleFederationPlugin({
127136
name: "remoteApp",
@@ -140,7 +149,7 @@ module-federation-demo/
140149
})
141150
</CodeSnippet>
142151

143-
<h5>remote-app/src/FruitsTable.js</h5>
152+
<h5>📜 remote-app/src/FruitsTable.js</h5>
144153
<CodeSnippet Number="2" Language="js" Description="FruitsTable remote component">
145154
const FruitsTable = () => (
146155
&lt;div&gt;
@@ -176,12 +185,20 @@ npm start
176185
</CodeSnippet>
177186

178187
<h4>🧲 Step 2: Consume in the Host App</h4>
188+
<p>
189+
The above code snippet configures the Webpack Module Federation Plugin for the host application. It specifies:
190+
<ul>
191+
<li><strong>name</strong>: The unique name of the host application (<code>hostApp</code>).</li>
192+
<li><strong>remotes</strong>: Declares the remote application (<code>remoteApp</code>) and its entry point (<code>http://localhost:3001/remoteEntry.js</code>).</li>
193+
<li><strong>shared</strong>: Ensures that dependencies like <code>react</code> and <code>react-dom</code> are loaded as singletons to avoid duplication across the host and remote apps.</li>
194+
</ul>
195+
</p>
179196

180-
<h5>host-app/webpack.config.js</h5>
197+
<h5>📜 host-app/webpack.config.js</h5>
181198

182199
<CodeSnippet Number="4" Language="js" Description="Module Federation Plugin setup in webpack config">
183200
new ModuleFederationPlugin({
184-
name: "host_app",
201+
name: "hostApp",
185202
remotes: {
186203
remote_app: "remoteApp@http://localhost:3001/remoteEntry.js",
187204
},

0 commit comments

Comments
 (0)