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
Copy file name to clipboardExpand all lines: libs/mf-tools/README.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ This can help to **balance the trade-off** between bundle size and isolation of
14
14
15
15
> **Disclaimer:** Multi-Framework and -Version Micro increase the overall complexity and call for some workarounds. This library tries to hide some of them.
Beginning with Angular 13, the CLI is emitting EcmaScript modules. Hence, we need to adjust the usage of the WebComponentWrapper when loading a remote that has been created with the CLI 13 or higher. For this, set ``type`` to ``remote`` and skip the ``remoteName`` property (for Modules, we don't need a remoteName):
118
+
119
+
```typescript
120
+
exportconstAPP_ROUTES: Routes= [
121
+
[...]
122
+
{
123
+
path: 'angular1',
124
+
component: WebComponentWrapper,
125
+
data: {
126
+
type: 'module',
127
+
remoteEntry: 'https://your-path/remoteEntry.js',
128
+
exposedModule: './web-components',
129
+
elementName: 'angular1-element'
130
+
} asWebComponentWrapperOptions
131
+
},
132
+
[...]
133
+
}
134
+
```
135
+
113
136
## Sub-Routes
114
137
115
138
If a web component has it's own router, you can use our UrlMatchers ``startsWith`` and ``endsWith`` to define, which part of the URL is intended for the shell and for the micro frontend:
The ``bootstrap.ts`` file contains the source code normally found in ``main.ts`` and hence, it calls ``platform.bootstrapModule(AppModule)``. You really need this combination of an upfront file calling loadRemoteEntry and a dynamic import loading another file bootstrapping Angular because Angular itself is already a shared library respected during the version negotiation.
157
158
158
-
Then, when loading the remote Module, just skip the ``remoteEntry`` property:
159
+
Then, when loading the remote Module, you set to mention the ``remoteEntry`` property anyway, as it also acts as an internal identifier for the remote:
Copy file name to clipboardExpand all lines: migration-guide.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,6 +128,10 @@ To prevent issues with live reloads, you need to add a ``publicHost`` property t
128
128
[...]
129
129
```
130
130
131
+
### Deployment: Enable CORS
132
+
133
+
As remotes are now loaded as EcmaScript modules, the same origin policy is in place. Hence, if your micro frontends and the shell are deployed to different origins, you need to enable CORS. The same holds true if you run your application after building it with a command line web server like ``serve`` (``serve``, e. g., has a ``--cors`` options).
134
+
131
135
### Advanced: Dynamic Federation with Script-based Remotes
132
136
133
137
If you also want to load (existing) script-based remotes into your shell, e. g. remotes built with Angular 12 used for a [Multi-Version/Multi-Framework setup](https://www.npmjs.com/package/@angular-architects/module-federation-tools), you can pass ``type: 'script'`` to both, ``loadRemoteModule`` and ``loadRemoteEntry``. In this case, you also need to pass a ``remoteName``.
0 commit comments