@angular-architects/native-federation 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +314 -259
  2. package/builders.json +10 -10
  3. package/collection.json +17 -17
  4. package/executors.json +10 -10
  5. package/generators.json +12 -12
  6. package/package.json +19 -9
  7. package/src/builders/build/builder.js +99 -177
  8. package/src/builders/build/builder.js.map +1 -1
  9. package/src/builders/build/schema.d.ts +3 -3
  10. package/src/builders/build/schema.json +550 -550
  11. package/src/config.d.ts +2 -2
  12. package/src/config.js +7 -7
  13. package/src/config.js.map +1 -1
  14. package/src/executors/build/schema.d.ts +1 -1
  15. package/src/executors/build/schema.json +9 -9
  16. package/src/generators/native-federation/schema.d.ts +5 -5
  17. package/src/generators/native-federation/schema.json +29 -29
  18. package/src/index.d.ts +1 -1
  19. package/src/index.js +1 -1
  20. package/src/index.js.map +1 -1
  21. package/src/schematics/init/files/{federation.config.js → federation.config.js__tmpl__} +0 -4
  22. package/src/schematics/init/schema.d.ts +6 -6
  23. package/src/schematics/init/schema.json +34 -34
  24. package/src/schematics/init/schematic.js +35 -29
  25. package/src/schematics/init/schematic.js.map +1 -1
  26. package/src/utils/angular-esbuild-adapter.d.ts +3 -0
  27. package/src/utils/angular-esbuild-adapter.js +88 -0
  28. package/src/utils/angular-esbuild-adapter.js.map +1 -0
  29. package/src/utils/rollup.d.ts +1 -0
  30. package/src/utils/rollup.js +58 -0
  31. package/src/utils/rollup.js.map +1 -0
  32. package/src/utils/shared-mappings-plugin.d.ts +1 -1
  33. package/src/config/federation-config.d.ts +0 -26
  34. package/src/config/federation-config.js +0 -3
  35. package/src/config/federation-config.js.map +0 -1
  36. package/src/config/index.d.ts +0 -2
  37. package/src/config/index.js +0 -10
  38. package/src/config/index.js.map +0 -1
  39. package/src/config/with-native-federation.d.ts +0 -2
  40. package/src/config/with-native-federation.js +0 -53
  41. package/src/config/with-native-federation.js.map +0 -1
  42. package/src/utils/build-utils.d.ts +0 -9
  43. package/src/utils/build-utils.js +0 -38
  44. package/src/utils/build-utils.js.map +0 -1
  45. package/src/utils/hash-file.d.ts +0 -1
  46. package/src/utils/hash-file.js +0 -13
  47. package/src/utils/hash-file.js.map +0 -1
  48. package/src/utils/mapped-paths.d.ts +0 -10
  49. package/src/utils/mapped-paths.js +0 -37
  50. package/src/utils/mapped-paths.js.map +0 -1
  51. package/src/utils/package-info.d.ts +0 -7
  52. package/src/utils/package-info.js +0 -94
  53. package/src/utils/package-info.js.map +0 -1
package/README.md CHANGED
@@ -1,259 +1,314 @@
1
- # Native Federation
2
-
3
- Native Federation is a "browser-native" implementation of the successful mental model behind wepback Module Federation for building Micro Frontends.
4
-
5
- ## Features
6
-
7
- - ✅ Mental Model of Module Federation
8
- - ✅ Future Proof: Independent of build tools like webpack
9
- - ✅ Embraces Import Maps - an emerging web standard
10
- - ✅ Easy to configure: We use the same API and Schematics as for our Module Federation plugin
11
- - ✅ Blazing Fast: The reference implementation not only uses the fast esbuild; it also caches already built shared dependencies (like Angular itself).
12
-
13
- ## Today and Tomorrow
14
-
15
- ### Bundler
16
-
17
- The current version uses **esbuild**. Future versions will allow to easily **switch out the build tool**.
18
-
19
- ### Frameworks
20
-
21
- **Angular** is a first-class citizen: The package ships with **Schematics** for the Angular CLI and a **builder** (that delegates to the experimental esbuild builder the CLI team is current working on). Future versions will also make it easy to use the implementation **with other frameworks**.
22
-
23
- ### Design
24
-
25
- This is possible, because by design, most of the implementation runs outside of the bundler und independently of CLI mechanisms. Hence, we will expose 2-3 helper functions everyone can call in their build process regardless of the framework or build tool used.
26
-
27
- ## Current Limitations
28
-
29
- This is a first experimental version. The results look very promising, however it's not intended to be used in production. Feel free to try it out and to provide feedback!
30
-
31
- Limitations:
32
-
33
- - 🔷 As we use a fork of the experimental esbuild builder the CLI team is current working on, there is currently **only a builder for ng build**. ng serve or ng test are currently not supported. This support will be added with a future version.
34
-
35
- - 🔷 Libraries are currently only shared if two or more remotes (Micro Frontends) request the very same version. This is also what works best with Angular. In a future version, we will add optional "version negotiation" for the sake of feature parity with Module Federation. This allows Native Federation to decide for a "higher compatible version" (e. g. a higher minor version provided by another Micro Frontend) at runtime.
36
-
37
- ## Credits
38
-
39
- Big thanks to:
40
-
41
- - [Zack Jackson](https://twitter.com/ScriptedAlchemy) for originally coming up with the great idea of Module Federation and its successful mental model
42
- - [Tobias Koppers](https://twitter.com/wSokra) for helping to make Module Federation a first class citizen of webpack
43
- - [The Nx Team](https://twitter.com/NxDevTools), esp. [Colum Ferry](https://twitter.com/FerryColum), who seamlessly integrated webpack Module Federation into Nx and hence helped to spread the word about it (Nx + Module Federation === ❤️)
44
- - [Michael Egger-Zikes](https://twitter.com/MikeZks) for contributing to our Module Federation efforts and brining in valuable feedback
45
- - The Angular CLI-Team, esp. [Alan Agius](https://twitter.com/AlanAgius4) and [Charles Lyding](https://twitter.com/charleslyding), for working on the experimental esbuild builder for Angular
46
-
47
- ## Example
48
-
49
- We migrated our webpack Module Federation example to Native Federation:
50
-
51
- ![Example](https://raw.githubusercontent.com/angular-architects/module-federation-plugin/main/libs/native-federation/example.png)
52
-
53
- Please find the example [here (branch: ng-solution)](https://github.com/manfredsteyer/module-federation-plugin-example/tree/nf-solution):
54
-
55
- ```
56
- git clone https://github.com/manfredsteyer/module-federation-plugin-example.git --branch nf-solution
57
-
58
- cd module-federation-plugin-example
59
-
60
- npm i
61
- npm run build
62
- npm run start
63
- ```
64
-
65
- Then, open http://localhost:3000 in your browser.
66
-
67
- Please note, that the current **experimental** version does **not** support ``ng serve``. Hence, you need to build it and serve it from the ``dist`` folder (this is what npm run build && npm run start in the above shown example do).
68
-
69
- ## Usage
70
-
71
- > You can checkout the [nf-starter branch](https://github.com/manfredsteyer/module-federation-plugin-example/tree/nf-solution) to try out Native Federation.
72
-
73
- ### Adding Native Federation
74
-
75
- ```
76
- npm i @angular-architects/native-federation -D
77
- ```
78
-
79
- Making an application a host:
80
-
81
- ```
82
- ng g @angular-architects/native-federation:init --project shell --type host
83
- ```
84
-
85
- A dynamic host is a host reading the configuration data at runtime from a ``.json`` file:
86
-
87
- ```
88
- ng g @angular-architects/native-federation:init --project shell --type dynamic-host
89
- ```
90
-
91
- Making an application a remote:
92
-
93
- ```
94
- ng g @angular-architects/native-federation:init --project mfe1 --type remote
95
- ```
96
-
97
- ### Configuring the Host
98
-
99
- The host configuration looks like what you know from our Module Federation plugin:
100
-
101
- ```javascript
102
- // projects/shell/federation.config.js
103
-
104
- const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
105
-
106
- module.exports = withNativeFederation({
107
-
108
- shared: {
109
- ...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
110
- },
111
-
112
- });
113
- ```
114
-
115
- ### Configuring the Remote
116
-
117
- Also the remote configuration looks familiar:
118
-
119
- ```javascript
120
- // projects/mfe1/federation.config.js
121
-
122
- const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
123
-
124
- module.exports = withNativeFederation({
125
-
126
- name: 'mfe1',
127
-
128
- exposes: {
129
- './Module': './projects/mfe1/src/app/flights/flights.module.ts',
130
- },
131
-
132
- shared: {
133
- ...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
134
- },
135
-
136
- });
137
- ```
138
-
139
- ### Initializing the Host
140
-
141
- Call ``initFederation`` before bootstrapping your ``main.ts``:
142
-
143
- ```typescript
144
- // projects/shell/src/main.ts
145
-
146
- import { initFederation } from '@angular-architects/native-federation';
147
-
148
- initFederation({
149
- mfe1: 'http://localhost:3001/remoteEntry.json'
150
- })
151
- .catch(err => console.error(err))
152
- .then(_ => import('./bootstrap'))
153
- .catch(err => console.error(err));
154
- ```
155
-
156
- > Our ``init`` schematic shown above generates all of this if you pass ``--type host``.
157
-
158
- You can directly pass a mapping between remote names and their ``remoteEntry.json``. The ``remoteEntry.json`` contains the necessary metadata. It is generated when compiling the remote.
159
-
160
- Please note that in Native Federation, the remote entry is just a ``.json`` file while its a ``.js`` file in Module Federation.
161
-
162
- However, you don't need to hardcode this mapping. Feel free to point to the file name of a federation manifest:
163
-
164
- ```typescript
165
- // projects/shell/src/main.ts
166
-
167
- import { initFederation } from '@angular-architects/native-federation';
168
-
169
- initFederation('/assets/federation.manifest.json')
170
- .catch(err => console.error(err))
171
- .then(_ => import('./bootstrap'))
172
- .catch(err => console.error(err));
173
- ```
174
-
175
- This manifest can be exchanged when deploying the solution. Hence, you can adopt the solution to the current environment.
176
-
177
- > Our ``init`` schematic shown above generates this variation if you pass ``--type dynamic-host``.
178
-
179
- Credits: The Nx team originally came up with the idea for the manifest.
180
-
181
- This is what the (also generated) federation manifest looks like:
182
-
183
- ```json
184
- {
185
- "mfe1": "http://localhost:3001/remoteEntry.json"
186
- }
187
- ```
188
-
189
- ### Initializing the Remote
190
-
191
- Also, the remote needs to be initialized. If a remote doesn't load further remotes, you don't need to pass any mappings to ``initFederation``:
192
-
193
- ```typescript
194
- import { initFederation } from '@angular-architects/native-federation';
195
-
196
- initFederation()
197
- .catch(err => console.error(err))
198
- .then(_ => import('./bootstrap'))
199
- .catch(err => console.error(err));
200
- ```
201
-
202
- ### Loading a Remote
203
-
204
- Use the helper function ``loadRemoteModule`` to load a configured remote:
205
-
206
- ```typescript
207
- import { loadRemoteModule } from '@angular-architects/native-federation';
208
- [...]
209
-
210
- export const APP_ROUTES: Routes = [
211
- [...]
212
-
213
- {
214
- path: 'flights',
215
- loadChildren: () => loadRemoteModule({
216
- remoteName: 'mfe1',
217
- exposedModule: './Module'
218
- }).then(m => m.FlightsModule)
219
- },
220
-
221
- [...]
222
- }
223
- ```
224
-
225
- This can be used with and without routing; with ``NgModule``s but also with **standalone** building blocks. Just use it instead of dynamic imports.
226
-
227
- For the sake of compatibility with our Module Federation API, you can also use the ``remoteEntry`` to identify the remote in question:
228
-
229
- ```typescript
230
- import { loadRemoteModule } from '@angular-architects/native-federation';
231
- [...]
232
-
233
- export const APP_ROUTES: Routes = [
234
- [...]
235
-
236
- {
237
- path: 'flights',
238
- loadChildren: () => loadRemoteModule({
239
- // Alternative: You can also use the remoteEntry i/o the remoteName:
240
- remoteEntry: 'http://localhost:3001/remoteEntry.json',
241
- exposedModule: './Module'
242
- }).then(m => m.FlightsModule)
243
- },
244
-
245
- [...]
246
- }
247
- ```
248
-
249
- However, we prefer the first option where just the ``remoteName`` is passed.
250
-
251
- ## More: Blog Articles
252
-
253
- Find out more about our work including Micro Frontends and Module Federation but also about alternatives to these approaches in our [blog](https://www.angulararchitects.io/en/aktuelles/the-microfrontend-revolution-part-2-module-federation-with-angular/).
254
-
255
- ## More: Angular Architecture Workshop (100% online, interactive)
256
-
257
- In our [Angular Architecture Workshop](https://www.angulararchitects.io/en/angular-workshops/advanced-angular-enterprise-architecture-incl-ivy/), we cover all these topics and far more. We provide different options and alternatives and show up their consequences.
258
-
259
- [Details: Angular Architecture Workshop](https://www.angulararchitects.io/en/angular-workshops/advanced-angular-enterprise-architecture-incl-ivy/)
1
+ # Native Federation
2
+
3
+ Native Federation is a "browser-native" implementation of the successful mental model behind wepback Module Federation for building Micro Frontends.
4
+
5
+ ## Features
6
+
7
+ - ✅ Mental Model of Module Federation
8
+ - ✅ Future Proof: Independent of build tools like webpack
9
+ - ✅ Embraces Import Maps - an emerging web standard
10
+ - ✅ Easy to configure: We use the same API and Schematics as for our Module Federation plugin
11
+ - ✅ Blazing Fast: The reference implementation not only uses the fast esbuild; it also caches already built shared dependencies (like Angular itself).
12
+
13
+ ## Today and Tomorrow
14
+
15
+ ### Bundler
16
+
17
+ The current version uses **esbuild**. Future versions will allow to easily **switch out the build tool**.
18
+
19
+ ### Frameworks
20
+
21
+ **Angular** is a first-class citizen: The package ships with **Schematics** for the Angular CLI and a **builder** (that delegates to the experimental esbuild builder the CLI team is current working on). Future versions will also make it easy to use the implementation **with other frameworks**.
22
+
23
+ ### Design
24
+
25
+ This is possible, because by design, most of the implementation runs outside of the bundler und independently of CLI mechanisms. Hence, we will expose 2-3 helper functions everyone can call in their build process regardless of the framework or build tool used.
26
+
27
+ ## Current Limitations
28
+
29
+ This is a first experimental version. The results look very promising, however it's not intended to be used in production. Feel free to try it out and to provide feedback!
30
+
31
+ Limitations:
32
+
33
+ - 🔷 As we use a fork of the experimental esbuild builder the CLI team is current working on, there is currently **only a builder for ng build**. ng serve or ng test are currently not supported. This support will be added with a future version. Also, as the forked esbuile builder is still experimental, you cannot expect to get all the features you are used to. This will also change over time.
34
+ - 🔷 Libraries are currently only shared if two or more remotes (Micro Frontends) request the very same version. This is also what works best with Angular. In a future version, we will add optional "version negotiation" for the sake of feature parity with Module Federation. This allows Native Federation to decide for a "higher compatible version" (e. g. a higher minor version provided by another Micro Frontend) at runtime.
35
+
36
+ ## Credits
37
+
38
+ Big thanks to:
39
+
40
+ - [Zack Jackson](https://twitter.com/ScriptedAlchemy) for originally coming up with the great idea of Module Federation and its successful mental model
41
+ - [Tobias Koppers](https://twitter.com/wSokra) for helping to make Module Federation a first class citizen of webpack
42
+ - [Florian Rappl](https://twitter.com/FlorianRappl) for an good discussion about these topics during a speakers dinner in Nuremberg
43
+ - [The Nx Team](https://twitter.com/NxDevTools), esp. [Colum Ferry](https://twitter.com/FerryColum), who seamlessly integrated webpack Module Federation into Nx and hence helped to spread the word about it (Nx + Module Federation === ❤️)
44
+ - [Michael Egger-Zikes](https://twitter.com/MikeZks) for contributing to our Module Federation efforts and brining in valuable feedback
45
+ - The Angular CLI-Team, esp. [Alan Agius](https://twitter.com/AlanAgius4) and [Charles Lyding](https://twitter.com/charleslyding), for working on the experimental esbuild builder for Angular
46
+
47
+ ## Example
48
+
49
+ We migrated our webpack Module Federation example to Native Federation:
50
+
51
+ ![Example](https://raw.githubusercontent.com/angular-architects/module-federation-plugin/main/libs/native-federation/example.png)
52
+
53
+ Please find the example [here (branch: ng-solution)](https://github.com/manfredsteyer/module-federation-plugin-example/tree/nf-solution):
54
+
55
+ ```
56
+ git clone https://github.com/manfredsteyer/module-federation-plugin-example.git --branch nf-solution
57
+
58
+ cd module-federation-plugin-example
59
+
60
+ npm i
61
+ npm run build
62
+ npm start
63
+ ```
64
+
65
+ Then, open http://localhost:3000 in your browser.
66
+
67
+ Please note, that the current **experimental** version does **not** support `ng serve`. Hence, you need to build it and serve it from the `dist` folder (this is what npm run build && npm run start in the above shown example do).
68
+
69
+ ## About the Mental Model
70
+
71
+ The underlying mental model allows for runtime integration: Loading a part of a separately built and deployed application into your's. This is needed for Micro Frontend architectures but also for plugin-based solutions.
72
+
73
+ For this, the mental model introduces several concepts:
74
+
75
+ - **Remote:** The remote is a separately built and deployed application. It can **expose EcmaScript** modules that can be loaded into other applications.
76
+ - **Host:** The host loads one or several remotes on demand. For your framework's perspective, this looks like traditional lazy loading. The big difference is that the host doesn't know the remotes at compilation time.
77
+ - **Shared Dependencies:** If a several remotes and the host use the same library, you might not want to download it several times. Instead, you might want to just download it once and share it at runtime. For this use case, the mental model allows for defining such shared dependencies.
78
+ - **Version Mismatch:** If two or more applications use a different version of the same shared library, we need to prevent a version mismatch. To deal with it, the mental model defines several strategies, like falling back to another version that fits the application, using a different compatible one (according to semantic versioning) or throwing an error.
79
+
80
+ ## Usage
81
+
82
+ > You can checkout the [nf-starter branch](https://github.com/manfredsteyer/module-federation-plugin-example/tree/nf-solution) to try out Native Federation.
83
+
84
+ ### Adding Native Federation
85
+
86
+ ```
87
+ npm i @angular-architects/native-federation -D
88
+ ```
89
+
90
+ Making an application a host:
91
+
92
+ ```
93
+ ng g @angular-architects/native-federation:init --project shell --type host
94
+ ```
95
+
96
+ A dynamic host is a host reading the configuration data at runtime from a `.json` file:
97
+
98
+ ```
99
+ ng g @angular-architects/native-federation:init --project shell --type dynamic-host
100
+ ```
101
+
102
+ Making an application a remote:
103
+
104
+ ```
105
+ ng g @angular-architects/native-federation:init --project mfe1 --type remote
106
+ ```
107
+
108
+ ### Configuring the Host
109
+
110
+ The host configuration looks like what you know from our Module Federation plugin:
111
+
112
+ ```javascript
113
+ // projects/shell/federation.config.js
114
+
115
+ const {
116
+ withNativeFederation,
117
+ shareAll,
118
+ } = require('@angular-architects/native-federation/config');
119
+
120
+ module.exports = withNativeFederation({
121
+ shared: {
122
+ ...shareAll({
123
+ singleton: true,
124
+ strictVersion: true,
125
+ requiredVersion: 'auto',
126
+ }),
127
+ },
128
+ });
129
+ ```
130
+
131
+ ### Configuring the Remote
132
+
133
+ Also the remote configuration looks familiar:
134
+
135
+ ```javascript
136
+ // projects/mfe1/federation.config.js
137
+
138
+ const {
139
+ withNativeFederation,
140
+ shareAll,
141
+ } = require('@angular-architects/native-federation/config');
142
+
143
+ module.exports = withNativeFederation({
144
+ name: 'mfe1',
145
+
146
+ exposes: {
147
+ './Module': './projects/mfe1/src/app/flights/flights.module.ts',
148
+ },
149
+
150
+ shared: {
151
+ ...shareAll({
152
+ singleton: true,
153
+ strictVersion: true,
154
+ requiredVersion: 'auto',
155
+ }),
156
+ },
157
+ });
158
+ ```
159
+
160
+ ### Initializing the Host
161
+
162
+ Call `initFederation` before bootstrapping your `main.ts`:
163
+
164
+ ```typescript
165
+ // projects/shell/src/main.ts
166
+
167
+ import { initFederation } from '@angular-architects/native-federation';
168
+
169
+ initFederation({
170
+ mfe1: 'http://localhost:3001/remoteEntry.json',
171
+ })
172
+ .catch((err) => console.error(err))
173
+ .then((_) => import('./bootstrap'))
174
+ .catch((err) => console.error(err));
175
+ ```
176
+
177
+ > Our `init` schematic shown above generates all of this if you pass `--type host`.
178
+
179
+ You can directly pass a mapping between remote names and their `remoteEntry.json`. The `remoteEntry.json` contains the necessary metadata. It is generated when compiling the remote.
180
+
181
+ Please note that in Native Federation, the remote entry is just a `.json` file while its a `.js` file in Module Federation.
182
+
183
+ However, you don't need to hardcode this mapping. Feel free to point to the file name of a federation manifest:
184
+
185
+ ```typescript
186
+ // projects/shell/src/main.ts
187
+
188
+ import { initFederation } from '@angular-architects/native-federation';
189
+
190
+ initFederation('/assets/federation.manifest.json')
191
+ .catch((err) => console.error(err))
192
+ .then((_) => import('./bootstrap'))
193
+ .catch((err) => console.error(err));
194
+ ```
195
+
196
+ This manifest can be exchanged when deploying the solution. Hence, you can adopt the solution to the current environment.
197
+
198
+ > Our `init` schematic shown above generates this variation if you pass `--type dynamic-host`.
199
+
200
+ Credits: The Nx team originally came up with the idea for the manifest.
201
+
202
+ This is what the (also generated) federation manifest looks like:
203
+
204
+ ```json
205
+ {
206
+ "mfe1": "http://localhost:3001/remoteEntry.json"
207
+ }
208
+ ```
209
+
210
+ ### Initializing the Remote
211
+
212
+ Also, the remote needs to be initialized. If a remote doesn't load further remotes, you don't need to pass any mappings to `initFederation`:
213
+
214
+ ```typescript
215
+ import { initFederation } from '@angular-architects/native-federation';
216
+
217
+ initFederation()
218
+ .catch((err) => console.error(err))
219
+ .then((_) => import('./bootstrap'))
220
+ .catch((err) => console.error(err));
221
+ ```
222
+
223
+ ### Loading a Remote
224
+
225
+ Use the helper function `loadRemoteModule` to load a configured remote:
226
+
227
+ ```typescript
228
+ import { loadRemoteModule } from '@angular-architects/native-federation';
229
+ [...]
230
+
231
+ export const APP_ROUTES: Routes = [
232
+ [...]
233
+
234
+ {
235
+ path: 'flights',
236
+ loadChildren: () => loadRemoteModule({
237
+ remoteName: 'mfe1',
238
+ exposedModule: './Module'
239
+ }).then(m => m.FlightsModule)
240
+ },
241
+
242
+ [...]
243
+ }
244
+ ```
245
+
246
+ This can be used with and without routing; with `NgModule`s but also with **standalone** building blocks. Just use it instead of dynamic imports.
247
+
248
+ For the sake of compatibility with our Module Federation API, you can also use the `remoteEntry` to identify the remote in question:
249
+
250
+ ```typescript
251
+ import { loadRemoteModule } from '@angular-architects/native-federation';
252
+ [...]
253
+
254
+ export const APP_ROUTES: Routes = [
255
+ [...]
256
+
257
+ {
258
+ path: 'flights',
259
+ loadChildren: () => loadRemoteModule({
260
+ // Alternative: You can also use the remoteEntry i/o the remoteName:
261
+ remoteEntry: 'http://localhost:3001/remoteEntry.json',
262
+ exposedModule: './Module'
263
+ }).then(m => m.FlightsModule)
264
+ },
265
+
266
+ [...]
267
+ }
268
+ ```
269
+
270
+ However, we prefer the first option where just the `remoteName` is passed.
271
+
272
+ ### Polyfill
273
+
274
+ This library uses Import Maps. As of today, not all browsers support this emerging browser feature, we need a polyfill. We recommend the polyfill `es-module-shims` which has been developed for production use cases. Our schematics install it via npm and add it to your `polyfills.ts`.
275
+
276
+ Also, the schematics add the following to your `index.html`:
277
+
278
+ ```html
279
+ <script type="esms-options">
280
+ {
281
+ "shimMode": true
282
+ }
283
+ </script>
284
+
285
+ <script type="module" src="polyfills.js"></script>
286
+
287
+ <script type="module-shim" src="main.js"></script>
288
+ ```
289
+
290
+ The script with the type `esms-options` configures the polyfill. This library was built for shim mode. In this mode, the polyfill provides some additional features beyond the proposal for Import Maps. These features, for instance, allow for dynamically creating an import map after loading the first EcmaScript module. Native Federation uses this possibility.
291
+
292
+ To make the polyfill to load your EcmaScript modules (bundles) in shim mode, assign the type `module-shim`. However, please just use module for the polyfill bundle itself to prevent an hen/egg-issue.
293
+
294
+ ## FAQ
295
+
296
+ ### Should we Already use Native Federation in Production?
297
+
298
+ For production, we would stick with Module Federation for the time being. Native Federation, however, shows that you don't need to fear that you are left alone, once you (or the community) wants to move over to other build tools.
299
+
300
+ We will evolve Native Federation but also our Module Federation support and keep you posted.
301
+
302
+ ### How does Native Federation Work under the Covers?
303
+
304
+ We use Import Maps at runtime. As they are currently not supported in every browser, our `init` schematic installs the `es-module-shims` polyfill. In addition to Import Maps, we use some code at build time and at runtime to provide the Mental Model of Module Federation.
305
+
306
+ ## More: Blog Articles
307
+
308
+ Find out more about our work including Micro Frontends and Module Federation but also about alternatives to these approaches in our [blog](https://www.angulararchitects.io/en/aktuelles/the-microfrontend-revolution-part-2-module-federation-with-angular/).
309
+
310
+ ## More: Angular Architecture Workshop (100% online, interactive)
311
+
312
+ In our [Angular Architecture Workshop](https://www.angulararchitects.io/en/angular-workshops/advanced-angular-enterprise-architecture-incl-ivy/), we cover all these topics and far more. We provide different options and alternatives and show up their consequences.
313
+
314
+ [Details: Angular Architecture Workshop](https://www.angulararchitects.io/en/angular-workshops/advanced-angular-enterprise-architecture-incl-ivy/)
package/builders.json CHANGED
@@ -1,10 +1,10 @@
1
- {
2
- "$schema": "../../node_modules/@angular-devkit/architect/src/builders-schema.json",
3
- "builders": {
4
- "build": {
5
- "implementation": "./src/builders/build/builder",
6
- "schema": "./src/builders/build/schema.json",
7
- "description": "build builder"
8
- }
9
- }
10
- }
1
+ {
2
+ "$schema": "../../node_modules/@angular-devkit/architect/src/builders-schema.json",
3
+ "builders": {
4
+ "build": {
5
+ "implementation": "./src/builders/build/builder",
6
+ "schema": "./src/builders/build/schema.json",
7
+ "description": "build builder"
8
+ }
9
+ }
10
+ }
package/collection.json CHANGED
@@ -1,17 +1,17 @@
1
- {
2
- "$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
- "name": "module-federation",
4
- "version": "0.0.1",
5
- "schematics": {
6
- "ng-add": {
7
- "factory": "./src/schematics/init/schematic",
8
- "schema": "./src/schematics/init/schema.json",
9
- "description": "Initialize an angular project for webpack module federation"
10
- },
11
- "init": {
12
- "factory": "./src/schematics/init/schematic",
13
- "schema": "./src/schematics/init/schema.json",
14
- "description": "Initialize an angular project for webpack module federation"
15
- }
16
- }
17
- }
1
+ {
2
+ "$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "name": "module-federation",
4
+ "version": "0.0.1",
5
+ "schematics": {
6
+ "ng-add": {
7
+ "factory": "./src/schematics/init/schematic",
8
+ "schema": "./src/schematics/init/schema.json",
9
+ "description": "Initialize an angular project for webpack module federation"
10
+ },
11
+ "init": {
12
+ "factory": "./src/schematics/init/schematic",
13
+ "schema": "./src/schematics/init/schema.json",
14
+ "description": "Initialize an angular project for webpack module federation"
15
+ }
16
+ }
17
+ }