You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -116,7 +123,10 @@ If you don't want to do the upstream tutorial first, you can use [this example](
116
123
];
117
124
```
118
125
119
-
Hint: Add the missing imports using your IDE's auto import feature.
126
+
**Hint:** Add the missing imports using your IDE's auto import feature.
127
+
128
+
**Remarks:** Please note that we are using ``type: 'script'`` here. This is needed for classic webpack setups as normally used in the Vue and React world as well as for Angular before version 13. Beginning with version 13, the CLI emits EcmaScript module instead of "plain old" JavaScript files. Hence, when loading a remote compiled with Angular 13 or higher, you need to set `type` to ``module``. In our case, however, the remotes we find at the shown URLs in the cloud are Angular 12-based, hence we need ``type: 'script'``.
129
+
120
130
121
131
4. Open your shell's ``app.component.html`` and add the following links:
Copy file name to clipboardExpand all lines: libs/mf/tutorial/tutorial.md
+32-41Lines changed: 32 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ This tutorial shows how to use Webpack Module Federation together with the Angul
6
6

7
7
8
8
9
+
**Important**: This tutorial is written for Angular and **Angular CLI 13.1** and higher. To find out about the small differences for lower versions of Angular and for the migration from such a lower version, please have a look to our [migration guide](https://github.com/angular-architects/module-federation-plugin/blob/main/migration-guide.md).
10
+
11
+
9
12
## Part 1: Clone and Inspect the Starterkit
10
13
11
14
In this part you will clone the starterkit and inspect its projects.
This activates module federation, assigns a port for ng serve, and generates the skeleton of a module federation configuration.
48
51
49
-
2. Switch into the project ``mfe1`` and open the generated configuration file ``projects\mfe1\webpack.config.js``. It contains the module federation configuration for ``mfe1``. Adjust it as follows:
52
+
2. Open the ``tsconfig.json`` in your workspace's root and ensure your self that the ``target`` property points to ``ES2020`` or higher. This is a prerequisite for using Module Federation with Angular 13.1 or higher.
53
+
54
+
3. Switch into the project ``mfe1`` and open the generated configuration file ``projects\mfe1\webpack.config.js``. It contains the module federation configuration for ``mfe1``. Adjust it as follows:
@@ -185,9 +196,11 @@ Now, let's remove the need for registering the micro frontends upfront with with
185
196
]
186
197
```
187
198
188
-
2. Restart both, the ``shell`` and the micro frontend (``mfe1``).
199
+
*Remarks:* ``type: 'module'`` is needed for Angular 13.1 or higher as beginning with version 13 the CLI emits EcmaScript modules instead of "plain old" JavaScript files.
200
+
201
+
3. Restart both, the ``shell`` and the micro frontend (``mfe1``).
189
202
190
-
3. The shell should still be able to load the micro frontend. However, now it's loaded dynamically.
203
+
4. The shell should still be able to load the micro frontend. However, now it's loaded dynamically.
191
204
192
205
This was quite easy, wasn't it? However, we can improve this solution a bit. Ideally, we load the remote entry upfront before Angular bootstraps. In this early phase, Module Federation tries to determine the highest compatible versions of all dependencies. Let's assume, the shell provides version 1.0.0 of a dependency (specifying ^1.0.0 in its ``package.json``) and the micro frontend uses version 1.1.0 (specifying ^1.1.0 in its ``package.json``). In this case, they would go with version 1.1.0. However, this is only possible if the remote's entry is loaded upfront.
193
206
@@ -197,34 +210,12 @@ This was quite easy, wasn't it? However, we can improve this solution a bit. Ide
197
210
import { loadRemoteEntry } from '@angular-architects/module-federation';
Also, don't use the settings introduced above for Angular 13.1+:
171
+
172
+
173
+
```diff
174
+
[...]
175
+
module.exports = {
176
+
[...]
177
+
- experiments: {
178
+
- outputModule: true
179
+
- },
180
+
plugins: [
181
+
new ModuleFederationPlugin({
182
+
- library: { type: "module" },
183
+
184
+
[...]
185
+
})
186
+
]
187
+
};
188
+
```
189
+
190
+
## SSR
191
+
192
+
We have a sound solution including Schematics for SSR in Angular 12. However, because of a bug in Angular Universal 13, SSR is currently not supported for Angular 13. However, we are monitoring this situation and providing a solution as soon as these issues are fixed.
193
+
170
194
## Example
171
195
172
196
see https://github.com/manfredsteyer/mf-angular-13
0 commit comments