@softarc/native-federation 0.9.2-beta.6 → 1.0.0-beta.1
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.
- package/README.md +111 -84
- package/package.json +6 -4
- package/src/build.d.ts +4 -2
- package/src/build.js +7 -1
- package/src/build.js.map +1 -1
- package/src/lib/config/federation-config.d.ts +2 -1
- package/src/lib/config/share-utils.d.ts +2 -1
- package/src/lib/config/share-utils.js +9 -2
- package/src/lib/config/share-utils.js.map +1 -1
- package/src/lib/config/with-native-federation.js +8 -3
- package/src/lib/config/with-native-federation.js.map +1 -1
- package/src/lib/core/build-adapter.d.ts +3 -0
- package/src/lib/core/build-adapter.js +2 -1
- package/src/lib/core/build-adapter.js.map +1 -1
- package/src/lib/core/bundle-exposed.js +31 -15
- package/src/lib/core/bundle-exposed.js.map +1 -1
- package/src/lib/core/bundle-shared-mappings.js +35 -9
- package/src/lib/core/bundle-shared-mappings.js.map +1 -1
- package/src/lib/core/bundle-shared.js +46 -15
- package/src/lib/core/bundle-shared.js.map +1 -1
- package/src/lib/core/default-skip-list.d.ts +12 -1
- package/src/lib/core/default-skip-list.js +34 -6
- package/src/lib/core/default-skip-list.js.map +1 -1
- package/src/lib/core/federation-builder.d.ts +5 -0
- package/src/lib/core/federation-builder.js +10 -0
- package/src/lib/core/federation-builder.js.map +1 -1
- package/src/lib/core/federation-options.d.ts +1 -0
- package/src/lib/core/get-externals.js +2 -2
- package/src/lib/core/get-externals.js.map +1 -1
- package/src/lib/core/load-federation-config.js +3 -3
- package/src/lib/core/load-federation-config.js.map +1 -1
- package/src/lib/core/write-federation-info.js +3 -2
- package/src/lib/core/write-federation-info.js.map +1 -1
- package/src/lib/core/write-import-map.js +3 -2
- package/src/lib/core/write-import-map.js.map +1 -1
- package/src/lib/utils/copy-src-map-if-exists.js +2 -1
- package/src/lib/utils/copy-src-map-if-exists.js.map +1 -1
- package/src/lib/utils/hash-file.js +3 -2
- package/src/lib/utils/hash-file.js.map +1 -1
- package/src/lib/utils/logger.d.ts +10 -0
- package/src/lib/utils/logger.js +39 -0
- package/src/lib/utils/logger.js.map +1 -0
- package/src/lib/utils/mapped-paths.js +4 -3
- package/src/lib/utils/mapped-paths.js.map +1 -1
- package/src/lib/utils/normalize.d.ts +1 -0
- package/src/lib/utils/normalize.js +8 -0
- package/src/lib/utils/normalize.js.map +1 -0
- package/src/lib/utils/package-info.d.ts +2 -0
- package/src/lib/utils/package-info.js +34 -9
- package/src/lib/utils/package-info.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @softarc/native-federation
|
|
2
2
|
|
|
3
|
-
Native Federation is a "browser-native"
|
|
3
|
+
Native Federation is a "browser-native" implementation of the successful mental model behind wepback Module Federation for building Micro Frontends and plugin-based solutions. It can be **used with any framework and build tool** for implementing **Micro Frontends** and plugin-based architectures.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- ✅ Mental Model of Module Federation
|
|
8
8
|
- ✅ Future Proof: Independent of build tools like webpack and frameworks
|
|
9
|
-
- ✅ Embraces Import Maps
|
|
9
|
+
- ✅ Embraces Import Maps -- an emerging browser technology -- and EcmaScript modules
|
|
10
10
|
- ✅ Easy to configure
|
|
11
11
|
- ✅ Blazing Fast: The reference implementation not only uses the fast esbuild; it also caches already built shared dependencies (like Angular itself). However, as mentioned above, feel free to use it with any other build tool.
|
|
12
12
|
|
|
@@ -20,11 +20,23 @@ While this core library can be used with any framework and build tool, there is
|
|
|
20
20
|
|
|
21
21
|
> Please find the [Angular-based version here](https://www.npmjs.com/package/@angular-architects/native-federation).
|
|
22
22
|
|
|
23
|
-
Also, other higher level abstractions on top of this core library are possible.
|
|
23
|
+
Also, other higher level abstractions on top of this core library are possible.
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## About the Mental Model
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
For this, the mental model introduces several concepts:
|
|
30
|
+
|
|
31
|
+
- **Remote:** The remote is a separately built and deployed application. It can **expose EcmaScript** modules that can be loaded into other applications.
|
|
32
|
+
- **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.
|
|
33
|
+
- **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.
|
|
34
|
+
- **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.
|
|
35
|
+
|
|
36
|
+
## Example
|
|
37
|
+
|
|
38
|
+
- [VanillaJS example](https://github.com/manfredsteyer/native-federation-core-microfrontend).
|
|
39
|
+
- [React example](https://github.com/manfredsteyer/native-federation-react-example)
|
|
28
40
|
|
|
29
41
|
## Credits
|
|
30
42
|
|
|
@@ -32,22 +44,38 @@ Big thanks to:
|
|
|
32
44
|
|
|
33
45
|
- [Zack Jackson](https://twitter.com/ScriptedAlchemy) for originally coming up with the great idea of Module Federation and its successful mental model
|
|
34
46
|
- [Tobias Koppers](https://twitter.com/wSokra) for helping to make Module Federation a first class citizen of webpack
|
|
35
|
-
- [Florian Rappl](https://twitter.com/FlorianRappl) for an good discussion about these topics during a speakers dinner in Nuremberg
|
|
47
|
+
- [Florian Rappl](https://twitter.com/FlorianRappl) for an good discussion about these topics during a speakers dinner in Nuremberg
|
|
36
48
|
- [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 === ❤️)
|
|
37
49
|
- [Michael Egger-Zikes](https://twitter.com/MikeZks) for contributing to our Module Federation efforts and brining in valuable feedback
|
|
38
50
|
- 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
|
|
39
51
|
|
|
40
52
|
## Using this Library
|
|
41
53
|
|
|
54
|
+
### Installing the Library
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
npm i @softarc/native-federation
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
As Native Federation is tooling agnostic, we need an adapter to make it work with specific build tools. The package `@softarc/native-federation-esbuild` contains a simple adapter that uses esbuild:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
npm i @softarc/native-federation-esbuild
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
In some situations, this builder also delegates to rollup. This is necessary b/c esbuild does not provide all features we need (yet). We hope to minimize the usage of rollup in the future.
|
|
67
|
+
|
|
68
|
+
You can also provide your own adapter by providing a function aligning with the `BuildAdapter` type.
|
|
69
|
+
|
|
42
70
|
### Augment your Build Process
|
|
43
71
|
|
|
44
|
-
Just call three helper methods provided by our
|
|
72
|
+
Just call three helper methods provided by our `federationBuilder` in your build process to adjust it for Native Federation.
|
|
45
73
|
|
|
46
74
|
```typescript
|
|
47
75
|
import * as esbuild from 'esbuild';
|
|
48
76
|
import * as path from 'path';
|
|
49
77
|
import * as fs from 'fs';
|
|
50
|
-
import { esBuildAdapter } from '
|
|
78
|
+
import { esBuildAdapter } from '@softarc/native-federation-esbuild';
|
|
51
79
|
import { federationBuilder } from '@softarc/native-federation/build';
|
|
52
80
|
|
|
53
81
|
|
|
@@ -77,13 +105,13 @@ await federationBuilder.init({
|
|
|
77
105
|
});
|
|
78
106
|
|
|
79
107
|
/*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
* Step 2: Trigger your build process
|
|
109
|
+
*
|
|
110
|
+
* You can use any tool for this. Here, we go
|
|
111
|
+
* with a very simple esbuild-based build.
|
|
112
|
+
*
|
|
113
|
+
* Just respect the externals in
|
|
114
|
+
* `federationBuilder.externals`.
|
|
87
115
|
*/
|
|
88
116
|
|
|
89
117
|
[...]
|
|
@@ -97,43 +125,18 @@ await esbuild.build({
|
|
|
97
125
|
[...]
|
|
98
126
|
|
|
99
127
|
/*
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
* Step 3: Let the build method do the additional tasks
|
|
129
|
+
* for supporting Native Federation
|
|
102
130
|
*/
|
|
103
131
|
|
|
104
132
|
await federationBuilder.build();
|
|
105
133
|
```
|
|
106
134
|
|
|
107
|
-
The method
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
import { BuildAdapter } from '@softarc/native-federation/build';
|
|
111
|
-
import * as esbuild from 'esbuild';
|
|
112
|
-
|
|
113
|
-
export const esBuildAdapter: BuildAdapter = async (options) => {
|
|
114
|
-
|
|
115
|
-
const {
|
|
116
|
-
entryPoint,
|
|
117
|
-
external,
|
|
118
|
-
outfile,
|
|
119
|
-
} = options;
|
|
120
|
-
|
|
121
|
-
await esbuild.build({
|
|
122
|
-
entryPoints: [entryPoint],
|
|
123
|
-
external,
|
|
124
|
-
outfile,
|
|
125
|
-
bundle: true,
|
|
126
|
-
sourcemap: true,
|
|
127
|
-
minify: true,
|
|
128
|
-
format: 'esm',
|
|
129
|
-
target: ['esnext']
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
```
|
|
135
|
+
The method `federationBuilder.build` bundles the shared and exposed parts of your app.
|
|
133
136
|
|
|
134
|
-
### Configuring Hosts
|
|
137
|
+
### Configuring Hosts
|
|
135
138
|
|
|
136
|
-
The
|
|
139
|
+
The `withNativeFederation` function sets up a configuration for your applications. This is an example configuration for a host:
|
|
137
140
|
|
|
138
141
|
```typescript
|
|
139
142
|
// shell/federation.config.js
|
|
@@ -141,28 +144,27 @@ The ``withNativeFederation`` function sets up a configuration for your applicati
|
|
|
141
144
|
const {
|
|
142
145
|
withNativeFederation,
|
|
143
146
|
shareAll,
|
|
144
|
-
} = require(
|
|
147
|
+
} = require('@softarc/native-federation/build');
|
|
145
148
|
|
|
146
149
|
module.exports = withNativeFederation({
|
|
147
|
-
name:
|
|
150
|
+
name: 'host',
|
|
148
151
|
|
|
149
152
|
shared: {
|
|
150
153
|
...shareAll({
|
|
151
154
|
singleton: true,
|
|
152
155
|
strictVersion: true,
|
|
153
|
-
requiredVersion:
|
|
156
|
+
requiredVersion: 'auto',
|
|
154
157
|
includeSecondaries: false,
|
|
155
158
|
}),
|
|
156
159
|
},
|
|
157
|
-
|
|
158
160
|
});
|
|
159
161
|
```
|
|
160
162
|
|
|
161
|
-
The API for configuring and using Native Federation is very similar to the one provided by our Module Federation plugin @angular-architects/module-federation. Hence, most the articles on it are also valid for Native Federation.
|
|
163
|
+
The API for configuring and using Native Federation is very similar to the one provided by our Module Federation plugin [@angular-architects/module-federation](https://www.npmjs.com/package/@angular-architects/native-federation). Hence, most the articles on it are also valid for Native Federation.
|
|
162
164
|
|
|
163
165
|
### Sharing
|
|
164
166
|
|
|
165
|
-
The
|
|
167
|
+
The `shareAll`-helper used here shares all dependencies found in your `package.json`. Hence, they only need to be loaded once (instead of once per remote and host). If you don't want to share all of them, you can opt-out of sharing by using the `skip` option:
|
|
166
168
|
|
|
167
169
|
```typescript
|
|
168
170
|
module.exports = withNativeFederation({
|
|
@@ -177,7 +179,9 @@ module.exports = withNativeFederation({
|
|
|
177
179
|
}
|
|
178
180
|
```
|
|
179
181
|
|
|
180
|
-
|
|
182
|
+
### Sharing Mapped Paths (Monorepo-internal Libraries)
|
|
183
|
+
|
|
184
|
+
Paths mapped in your `tsconfig.json` are shared by default too. While they are part of your (mono) repository, they are treaded like libraries:
|
|
181
185
|
|
|
182
186
|
```json
|
|
183
187
|
{
|
|
@@ -192,52 +196,49 @@ Also pahts, mapped in your ``tsconfig.json`` are shared by default. They are tre
|
|
|
192
196
|
}
|
|
193
197
|
```
|
|
194
198
|
|
|
195
|
-
If you don't want to share (all of)
|
|
199
|
+
If you don't want to share (all of) them, put their names into the skip array (see above).
|
|
196
200
|
|
|
197
201
|
### Configuring Remotes
|
|
198
202
|
|
|
199
|
-
When configuring a remote, you can
|
|
203
|
+
When configuring a remote, you can expose files that can be loaded into the shell at runtime:
|
|
200
204
|
|
|
201
205
|
```javascript
|
|
202
206
|
const {
|
|
203
207
|
withNativeFederation,
|
|
204
208
|
shareAll,
|
|
205
|
-
} = require(
|
|
209
|
+
} = require('@softarc/native-federation/build');
|
|
206
210
|
|
|
207
211
|
module.exports = withNativeFederation({
|
|
208
|
-
name:
|
|
212
|
+
name: 'mfe1',
|
|
209
213
|
|
|
210
214
|
exposes: {
|
|
211
|
-
|
|
215
|
+
'./component': './mfe1/component',
|
|
212
216
|
},
|
|
213
217
|
|
|
214
218
|
shared: {
|
|
215
219
|
...shareAll({
|
|
216
220
|
singleton: true,
|
|
217
221
|
strictVersion: true,
|
|
218
|
-
requiredVersion:
|
|
222
|
+
requiredVersion: 'auto',
|
|
219
223
|
includeSecondaries: false,
|
|
220
224
|
}),
|
|
221
225
|
},
|
|
222
|
-
|
|
223
226
|
});
|
|
224
227
|
```
|
|
225
228
|
|
|
226
229
|
### Initializing a Host
|
|
227
230
|
|
|
228
|
-
On startup, call the
|
|
231
|
+
On startup, call the `initFederation` method. It takes a mapping between the names of remotes and their `remoteEntry.json`. This is a file containing meta data generated by the augmented build process (see above).
|
|
229
232
|
|
|
230
233
|
```typescript
|
|
231
234
|
import { initFederation } from '@softarc/native-federation';
|
|
232
235
|
|
|
233
236
|
(async () => {
|
|
237
|
+
await initFederation({
|
|
238
|
+
mfe1: 'http://localhost:3001/remoteEntry.json',
|
|
239
|
+
});
|
|
234
240
|
|
|
235
|
-
|
|
236
|
-
"mfe1": "http://localhost:3001/remoteEntry.json"
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
await import('./app');
|
|
240
|
-
|
|
241
|
+
await import('./app');
|
|
241
242
|
})();
|
|
242
243
|
```
|
|
243
244
|
|
|
@@ -247,19 +248,17 @@ You can also pass the name of a file with the key data about your remotes:
|
|
|
247
248
|
import { initFederation } from '@softarc/native-federation';
|
|
248
249
|
|
|
249
250
|
(async () => {
|
|
251
|
+
await initFederation('assets/manifest.json');
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
await import('./app');
|
|
254
|
-
|
|
253
|
+
await import('./app');
|
|
255
254
|
})();
|
|
256
255
|
```
|
|
257
256
|
|
|
258
|
-
Following the
|
|
257
|
+
Following the ideas of our friends at [Nrwl](https://nrwl.io), we call such a file a manifest:
|
|
259
258
|
|
|
260
259
|
```json
|
|
261
260
|
{
|
|
262
|
-
|
|
261
|
+
"mfe1": "http://localhost:3001/remoteEntry.json"
|
|
263
262
|
}
|
|
264
263
|
```
|
|
265
264
|
|
|
@@ -267,35 +266,63 @@ Manifests allow to adjust your application to different environments without any
|
|
|
267
266
|
|
|
268
267
|
## Initializing a Remote
|
|
269
268
|
|
|
270
|
-
|
|
269
|
+
For initializing a remote, also call `initFederation`. If you don't plan to load further remotes into your remote, you don't need to pass any parameters:
|
|
271
270
|
|
|
272
271
|
```typescript
|
|
273
272
|
import { initFederation } from '@softarc/native-federation';
|
|
274
273
|
|
|
275
274
|
(async () => {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
await import('./component');
|
|
279
|
-
|
|
275
|
+
await initFederation();
|
|
276
|
+
await import('./component');
|
|
280
277
|
})();
|
|
281
278
|
```
|
|
282
279
|
|
|
283
280
|
### Loading a Remote
|
|
284
281
|
|
|
285
|
-
To load a remote, just call the
|
|
282
|
+
To load a remote, just call the `loadRemoteModule` function:
|
|
286
283
|
|
|
287
284
|
```typescript
|
|
288
285
|
const module = await loadRemoteModule({
|
|
289
|
-
|
|
290
|
-
|
|
286
|
+
remoteName: 'mfe1',
|
|
287
|
+
exposedModule: './component',
|
|
291
288
|
});
|
|
292
289
|
```
|
|
293
290
|
|
|
294
|
-
If you know the type of the loaded module (perhaps you have a shared interface),
|
|
291
|
+
If you know the type of the loaded module (perhaps you have a shared interface), you can use it as a type parameter:
|
|
295
292
|
|
|
296
293
|
```typescript
|
|
297
294
|
const module = await loadRemoteModule<MyRemoteType>({
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
remoteName: 'mfe1',
|
|
296
|
+
exposedModule: './component',
|
|
300
297
|
});
|
|
301
|
-
```
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Polyfill
|
|
301
|
+
|
|
302
|
+
This library uses Import Maps. As currently 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:
|
|
303
|
+
|
|
304
|
+
```html
|
|
305
|
+
<script type="esms-options">
|
|
306
|
+
{
|
|
307
|
+
"shimMode": true
|
|
308
|
+
}
|
|
309
|
+
</script>
|
|
310
|
+
|
|
311
|
+
<script src="https://ga.jspm.io/npm:es-module-shims@1.5.17/dist/es-module-shims.js"></script>
|
|
312
|
+
|
|
313
|
+
<script type="module-shim" src="main.js"></script>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
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 a first EcmaScript module. Native Federation uses this possibility.
|
|
317
|
+
|
|
318
|
+
To make the polyfill to load your EcmaScript modules (bundles) in shim mode, assign the type `module-shim`.
|
|
319
|
+
|
|
320
|
+
## More: Blog Articles
|
|
321
|
+
|
|
322
|
+
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/).
|
|
323
|
+
|
|
324
|
+
## More: Angular Architecture Workshop (100% online, interactive)
|
|
325
|
+
|
|
326
|
+
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.
|
|
327
|
+
|
|
328
|
+
[Details: Angular Architecture Workshop](https://www.angulararchitects.io/en/angular-workshops/advanced-angular-enterprise-architecture-incl-ivy/)
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softarc/native-federation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
|
-
"
|
|
5
|
+
"dependencies": {
|
|
6
6
|
"json5": "^2.2.0",
|
|
7
|
-
"
|
|
7
|
+
"npmlog": "^6.0.2"
|
|
8
8
|
},
|
|
9
9
|
"main": "./src/index.js",
|
|
10
10
|
"typings": "./src/index.d.ts",
|
|
11
|
-
"
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@softarc/native-federation-runtime": "1.0.0-beta.1"
|
|
13
|
+
}
|
|
12
14
|
}
|
package/src/build.d.ts
CHANGED
|
@@ -9,8 +9,10 @@ export { bundleExposed } from './lib/core/bundle-exposed';
|
|
|
9
9
|
export { getExternals } from './lib/core/get-externals';
|
|
10
10
|
export { loadFederationConfig } from './lib/core/load-federation-config';
|
|
11
11
|
export { MappedPath } from './lib/utils/mapped-paths';
|
|
12
|
-
export { BuildAdapter } from './lib/core/build-adapter';
|
|
12
|
+
export { BuildAdapter, BuildAdapterOptions } from './lib/core/build-adapter';
|
|
13
13
|
export { withNativeFederation } from './lib/config/with-native-federation';
|
|
14
14
|
export { buildForFederation } from './lib/core/build-for-federation';
|
|
15
|
-
export { share, shareAll } from './lib/config/share-utils';
|
|
15
|
+
export { share, shareAll, findRootTsConfigJson, } from './lib/config/share-utils';
|
|
16
16
|
export { federationBuilder, BuildHelperParams, } from './lib/core/federation-builder';
|
|
17
|
+
export { logger, setLogLevel } from './lib/utils/logger';
|
|
18
|
+
export { hashFile } from './lib/utils/hash-file';
|
package/src/build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.federationBuilder = exports.shareAll = exports.share = exports.buildForFederation = exports.withNativeFederation = exports.loadFederationConfig = exports.getExternals = exports.bundleExposed = exports.bundleSharedMappings = exports.bundleShared = exports.writeFederationInfo = exports.writeImportMap = exports.setBuildAdapter = void 0;
|
|
3
|
+
exports.hashFile = exports.setLogLevel = exports.logger = exports.federationBuilder = exports.findRootTsConfigJson = exports.shareAll = exports.share = exports.buildForFederation = exports.withNativeFederation = exports.loadFederationConfig = exports.getExternals = exports.bundleExposed = exports.bundleSharedMappings = exports.bundleShared = exports.writeFederationInfo = exports.writeImportMap = exports.setBuildAdapter = void 0;
|
|
4
4
|
var build_adapter_1 = require("./lib/core/build-adapter");
|
|
5
5
|
Object.defineProperty(exports, "setBuildAdapter", { enumerable: true, get: function () { return build_adapter_1.setBuildAdapter; } });
|
|
6
6
|
var write_import_map_1 = require("./lib/core/write-import-map");
|
|
@@ -24,6 +24,12 @@ Object.defineProperty(exports, "buildForFederation", { enumerable: true, get: fu
|
|
|
24
24
|
var share_utils_1 = require("./lib/config/share-utils");
|
|
25
25
|
Object.defineProperty(exports, "share", { enumerable: true, get: function () { return share_utils_1.share; } });
|
|
26
26
|
Object.defineProperty(exports, "shareAll", { enumerable: true, get: function () { return share_utils_1.shareAll; } });
|
|
27
|
+
Object.defineProperty(exports, "findRootTsConfigJson", { enumerable: true, get: function () { return share_utils_1.findRootTsConfigJson; } });
|
|
27
28
|
var federation_builder_1 = require("./lib/core/federation-builder");
|
|
28
29
|
Object.defineProperty(exports, "federationBuilder", { enumerable: true, get: function () { return federation_builder_1.federationBuilder; } });
|
|
30
|
+
var logger_1 = require("./lib/utils/logger");
|
|
31
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
32
|
+
Object.defineProperty(exports, "setLogLevel", { enumerable: true, get: function () { return logger_1.setLogLevel; } });
|
|
33
|
+
var hash_file_1 = require("./lib/utils/hash-file");
|
|
34
|
+
Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return hash_file_1.hashFile; } });
|
|
29
35
|
//# sourceMappingURL=build.js.map
|
package/src/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../libs/native-federation-core/src/build.ts"],"names":[],"mappings":";;;AAEA,0DAA2D;AAAlD,gHAAA,eAAe,OAAA;AACxB,gEAA6D;AAApD,kHAAA,cAAc,OAAA;AACvB,0EAAuE;AAA9D,4HAAA,mBAAmB,OAAA;AAC5B,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,4EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAC7B,4DAA0D;AAAjD,+GAAA,aAAa,OAAA;AACtB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,4EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAG7B,8EAA2E;AAAlE,8HAAA,oBAAoB,OAAA;AAC7B,wEAAqE;AAA5D,0HAAA,kBAAkB,OAAA;AAC3B,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../libs/native-federation-core/src/build.ts"],"names":[],"mappings":";;;AAEA,0DAA2D;AAAlD,gHAAA,eAAe,OAAA;AACxB,gEAA6D;AAApD,kHAAA,cAAc,OAAA;AACvB,0EAAuE;AAA9D,4HAAA,mBAAmB,OAAA;AAC5B,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,4EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAC7B,4DAA0D;AAAjD,+GAAA,aAAa,OAAA;AACtB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,4EAAyE;AAAhE,8HAAA,oBAAoB,OAAA;AAG7B,8EAA2E;AAAlE,8HAAA,oBAAoB,OAAA;AAC7B,wEAAqE;AAA5D,0HAAA,kBAAkB,OAAA;AAC3B,wDAIkC;AAHhC,oGAAA,KAAK,OAAA;AACL,uGAAA,QAAQ,OAAA;AACR,mHAAA,oBAAoB,OAAA;AAEtB,oEAGuC;AAFrC,uHAAA,iBAAiB,OAAA;AAGnB,6CAAyD;AAAhD,gGAAA,MAAM,OAAA;AAAE,qGAAA,WAAW,OAAA;AAC5B,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SkipList } from '../core/default-skip-list';
|
|
1
2
|
import { MappedPath } from '../utils/mapped-paths';
|
|
2
3
|
export interface SharedConfig {
|
|
3
4
|
singleton?: boolean;
|
|
@@ -11,7 +12,7 @@ export interface FederationConfig {
|
|
|
11
12
|
exposes?: Record<string, string>;
|
|
12
13
|
shared?: Record<string, SharedConfig>;
|
|
13
14
|
sharedMappings?: Array<string>;
|
|
14
|
-
skip?:
|
|
15
|
+
skip?: SkipList;
|
|
15
16
|
}
|
|
16
17
|
export interface NormalizedSharedConfig {
|
|
17
18
|
singleton: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SharedConfig } from './federation-config';
|
|
2
|
+
import { SkipList } from '../core/default-skip-list';
|
|
2
3
|
export declare const DEFAULT_SECONARIES_SKIP_LIST: string[];
|
|
3
4
|
declare type IncludeSecondariesOptions = {
|
|
4
5
|
skip: string | string[];
|
|
@@ -9,7 +10,7 @@ declare type CustomSharedConfig = SharedConfig & {
|
|
|
9
10
|
declare type ConfigObject = Record<string, CustomSharedConfig>;
|
|
10
11
|
declare type Config = (string | ConfigObject)[] | ConfigObject;
|
|
11
12
|
export declare function findRootTsConfigJson(): string;
|
|
12
|
-
export declare function shareAll(config?: CustomSharedConfig, skip?:
|
|
13
|
+
export declare function shareAll(config?: CustomSharedConfig, skip?: SkipList, packageJsonPath?: string): Config | null;
|
|
13
14
|
export declare function setInferVersion(infer: boolean): void;
|
|
14
15
|
export declare function share(shareObjects: Config, packageJsonPath?: string): Config;
|
|
15
16
|
export {};
|
|
@@ -71,6 +71,9 @@ function _findSecondaries(libPath, excludes, shareObject, acc) {
|
|
|
71
71
|
if (excludes.includes(secondaryLibName)) {
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
74
|
+
if ((0, default_skip_list_1.isInSkipList)(secondaryLibName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
74
77
|
acc[secondaryLibName] = Object.assign({}, shareObject);
|
|
75
78
|
_findSecondaries(s, excludes, shareObject, acc);
|
|
76
79
|
}
|
|
@@ -123,19 +126,23 @@ function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
|
|
|
123
126
|
if (exclude.includes(secondaryName)) {
|
|
124
127
|
continue;
|
|
125
128
|
}
|
|
129
|
+
if ((0, default_skip_list_1.isInSkipList)(secondaryName, default_skip_list_1.PREPARED_DEFAULT_SKIP_LIST)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
126
132
|
result[secondaryName] = Object.assign({}, shareObject);
|
|
127
133
|
}
|
|
128
134
|
return result;
|
|
129
135
|
}
|
|
130
|
-
function shareAll(config = {}, skip =
|
|
136
|
+
function shareAll(config = {}, skip = default_skip_list_1.DEFAULT_SKIP_LIST, packageJsonPath = '') {
|
|
131
137
|
if (!packageJsonPath) {
|
|
132
138
|
packageJsonPath = (0, process_1.cwd)();
|
|
133
139
|
}
|
|
134
140
|
const packagePath = findPackageJson(packageJsonPath);
|
|
135
141
|
const versions = readVersionMap(packagePath);
|
|
136
142
|
const share = {};
|
|
143
|
+
const preparedSkipList = (0, default_skip_list_1.prepareSkipList)(skip);
|
|
137
144
|
for (const key in versions) {
|
|
138
|
-
if (
|
|
145
|
+
if ((0, default_skip_list_1.isInSkipList)(key, preparedSkipList)) {
|
|
139
146
|
continue;
|
|
140
147
|
}
|
|
141
148
|
share[key] = Object.assign({}, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-utils.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/share-utils.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,yBAA0B;AAC1B,qCAA8B;AAE9B,
|
|
1
|
+
{"version":3,"file":"share-utils.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/share-utils.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAC9B,yBAA0B;AAC1B,qCAA8B;AAE9B,iEAMmC;AAEnC,IAAI,YAAY,GAAG,KAAK,CAAC;AAEZ,QAAA,4BAA4B,GAAG;IAC1C,yBAAyB;IACzB,yBAAyB;CAC1B,CAAC;AAUF,SAAgB,oBAAoB;IAClC,MAAM,WAAW,GAAG,eAAe,CAAC,IAAA,aAAG,GAAE,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;IACtE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAE7D,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACnC,OAAO,gBAAgB,CAAC;KACzB;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QACtC,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;AAChF,CAAC;AAbD,oDAaC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,OACE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM,EAC/B;QACA,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;KAC/B;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnD,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE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,EACX,GAAG,EACH,WAAW,CACZ,CAAC;YACF,IAAI,WAAW,EAAE;gBACf,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aACrC;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAjDD,sBAiDC;AAED,SAAS,cAAc,CACrB,WAAyC,EACzC,MAAW;IAEX,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;KAChC;AACH,CAAC"}
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withNativeFederation = void 0;
|
|
4
4
|
const mapped_paths_1 = require("../utils/mapped-paths");
|
|
5
5
|
const share_utils_1 = require("./share-utils");
|
|
6
|
+
const default_skip_list_1 = require("../core/default-skip-list");
|
|
7
|
+
const logger_1 = require("../utils/logger");
|
|
6
8
|
function withNativeFederation(config) {
|
|
7
9
|
var _a, _b, _c;
|
|
8
|
-
const skip = (_a =
|
|
10
|
+
const skip = (0, default_skip_list_1.prepareSkipList)((_a = config.skip) !== null && _a !== void 0 ? _a : []);
|
|
9
11
|
return {
|
|
10
12
|
name: (_b = config.name) !== null && _b !== void 0 ? _b : '',
|
|
11
13
|
exposes: (_c = config.exposes) !== null && _c !== void 0 ? _c : {},
|
|
@@ -38,7 +40,7 @@ function normalizeShared(config, skip) {
|
|
|
38
40
|
result = (0, share_utils_1.share)(result);
|
|
39
41
|
}
|
|
40
42
|
result = Object.keys(result)
|
|
41
|
-
.filter((key) => !
|
|
43
|
+
.filter((key) => !(0, default_skip_list_1.isInSkipList)(key, skip))
|
|
42
44
|
.reduce((acc, cur) => (Object.assign(Object.assign({}, acc), { [cur]: result[cur] })), {});
|
|
43
45
|
return result;
|
|
44
46
|
}
|
|
@@ -48,7 +50,10 @@ function normalizeSharedMappings(config, skip) {
|
|
|
48
50
|
rootTsConfigPath,
|
|
49
51
|
sharedMappings: config.sharedMappings,
|
|
50
52
|
});
|
|
51
|
-
const result = paths.filter((p) => !
|
|
53
|
+
const result = paths.filter((p) => !(0, default_skip_list_1.isInSkipList)(p.key, skip) && !p.key.includes('*'));
|
|
54
|
+
if (paths.find((p) => p.key.includes('*'))) {
|
|
55
|
+
logger_1.logger.warn('Sharing mapped paths with wildcards (*) not supported');
|
|
56
|
+
}
|
|
52
57
|
return result;
|
|
53
58
|
}
|
|
54
59
|
//# sourceMappingURL=with-native-federation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-native-federation.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/with-native-federation.ts"],"names":[],"mappings":";;;AAAA,wDAAmE;AACnE,+CAAsE;
|
|
1
|
+
{"version":3,"file":"with-native-federation.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/config/with-native-federation.ts"],"names":[],"mappings":";;;AAAA,wDAAmE;AACnE,+CAAsE;AAMtE,iEAImC;AACnC,4CAAyC;AAEzC,SAAgB,oBAAoB,CAClC,MAAwB;;IAExB,MAAM,IAAI,GAAG,IAAA,mCAAe,EAAC,MAAA,MAAM,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC;IAEhD,OAAO;QACL,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,EAAE;QACvB,OAAO,EAAE,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE;QAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC;QACrC,cAAc,EAAE,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC;KACtD,CAAC;AACJ,CAAC;AAXD,oDAWC;AAED,SAAS,eAAe,CACtB,MAAwB,EACxB,IAAsB;IAEtB,IAAI,MAAM,GAA2C,EAAE,CAAC;IAExD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE7B,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,IAAA,sBAAQ,EAAC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EAAE,MAAM,CAAC,cAAc;KACtC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAA,gCAAY,EAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAC1D,CAAC;IAEF,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE;QAC1C,eAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;KACtE;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -5,6 +5,9 @@ export interface BuildAdapterOptions {
|
|
|
5
5
|
external: Array<string>;
|
|
6
6
|
outfile: string;
|
|
7
7
|
mappedPaths: MappedPath[];
|
|
8
|
+
packageName?: string;
|
|
9
|
+
esm?: boolean;
|
|
10
|
+
kind: 'shared-package' | 'shared-mapping' | 'exposed';
|
|
8
11
|
}
|
|
9
12
|
export declare type BuildAdapter = (options: BuildAdapterOptions) => Promise<void>;
|
|
10
13
|
export declare function setBuildAdapter(buildAdapter: BuildAdapter): void;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBuildAdapter = exports.setBuildAdapter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const logger_1 = require("../utils/logger");
|
|
5
6
|
let _buildAdapter = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
6
7
|
// TODO: add logger
|
|
7
|
-
|
|
8
|
+
logger_1.logger.error('Please set a BuildAdapter!');
|
|
8
9
|
});
|
|
9
10
|
function setBuildAdapter(buildAdapter) {
|
|
10
11
|
_buildAdapter = buildAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-adapter.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/build-adapter.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"build-adapter.js","sourceRoot":"","sources":["../../../../../../libs/native-federation-core/src/lib/core/build-adapter.ts"],"names":[],"mappings":";;;;AAAA,4CAAyC;AAGzC,IAAI,aAAa,GAAiB,GAAS,EAAE;IAC3C,mBAAmB;IACnB,eAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAC7C,CAAC,CAAA,CAAC;AAeF,SAAgB,eAAe,CAAC,YAA0B;IACxD,aAAa,GAAG,YAAY,CAAC;AAC/B,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe;IAC7B,OAAO,aAAa,CAAC;AACvB,CAAC;AAFD,0CAEC"}
|