Skip to content

Commit a12bc09

Browse files
committed
docs(nf) update docs for 18 and 19
1 parent dbb6162 commit a12bc09

File tree

4 files changed

+93
-14
lines changed

4 files changed

+93
-14
lines changed

libs/native-federation-core/src/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ export {
3131
export { logger, setLogLevel } from './lib/utils/logger';
3232
export { hashFile } from './lib/utils/hash-file';
3333
export * from './lib/utils/build-result-map';
34-

libs/native-federation/README.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ Native Federation is a "browser-native" implementation of the successful mental
55
## Features 🔥
66

77
- ✅ Mental Model of Module Federation
8-
- ✅ Future Proof: Independent of build tools like webpack
9-
- ✅ Embraces Import Maps - an emerging web standard
8+
- ✅ Future Proof: Uses **Web Standards** to be **independent** of build tools like webpack
9+
- ✅ Neat Angular-Integration: **Directly delegates** to Angular's new ultra-fast esbuild-based ApplicationBuilder to **prevent diverging** from the Angular standard.
10+
11+
### More
12+
13+
- ✅ Embraces ESM and Import Maps - an emerging web standard
1014
- ✅ Easy to configure: We use the same API and Schematics as for our Module Federation plugin
1115
- ✅ Blazing Fast: The reference implementation not only uses the fast esbuild; it also caches already built shared dependencies.
16+
- ✅ Supports Angular SSR and Incremental Hydration (since 18@latest)
1217

1318
## Prerequisite
1419

@@ -23,15 +28,20 @@ We will at least provide a new version of this package per Angular major. If nec
2328
- Use version 16.1.x for Angular 16.1.x
2429
- Use version 16.2.x for Angular 16.2.x
2530
- Use version 17.x for Angular 17.x
26-
- Use version 17.1.x for Angular 17.1+
27-
- Use version 18.x for Angular 18+
28-
- Use version 18.1.x for Angular 18.1+
29-
- Use version 18.2.x for Angular 18.2+
31+
- Use version 17.1.x for Angular 17.1
32+
- Use version 18.x for Angular 18.0.x
33+
- Use version 18.1.x for Angular 18.1.x
34+
- Use version 18.2.x for Angular 18.2.x
35+
- Use version 19.x for Angular 19.x
3036

3137
## Migration from Module Federation
3238

3339
If you currently use Angular with Module Federation, you can follow our [Migration Guide](https://github.com/angular-architects/module-federation-plugin/blob/main/libs/native-federation/docs/migrate.md) to migrate to Native Federation and Angular's new fast esbuild-based build system.
3440

41+
## Using Module Federation and Native Federation Side-by-Side
42+
43+
[In this article](https://www.angulararchitects.io/en/blog/combining-native-federation-and-module-federation/) we describe, how to use both technologies side-by-side.
44+
3545
## Updates
3646

3747
You can use `ng update` for updating Native Federation.
@@ -40,7 +50,7 @@ Notes for [updating to version 18](https://github.com/angular-architects/module-
4050

4151
## Angular Integration
4252

43-
Since 17.1, Native Federation for Angular uses the Angular CLI's `esbuild`-based **Application Builder** and the CLI's **Dev Server** to keep track with all the innovations and performance-improvements in that space.
53+
Since 17.1, Native Federation for Angular uses the Angular CLI's `esbuild`-based **Application Builder** and the CLI's **Dev Server** to **keep track with all the innovations and performance-improvements provided by the Angular CLI team.**
4454

4555
Please find some [information for upgrading to 17.1. here](https://github.com/angular-architects/module-federation-plugin/blob/main/libs/native-federation/migrate-appbuilder.md).
4656

@@ -318,11 +328,7 @@ Now, by clicking at the 2nd menu item, you can load the remote directly into the
318328

319329
### When to use this package?
320330

321-
If you like the idea of webpack Module Federation but want to switch over to Angular's new esbuild builder (currently in developer preview), you can use this package.
322-
323-
### Error: File 'src\main.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
324-
325-
It seems like the current version of Angular's esbuild builder has an issue with paths on Windows when using the traditional command prompt. For the time being, try to ng serve and ng build your application via PowerShell, the git bash, or WSL.
331+
If you like the idea of webpack Module Federation but want to switch over to Angular's new esbuild builder, you can use this package.
326332

327333
### I get an error when preparing shared packages. What to do?
328334

@@ -338,6 +344,39 @@ For this, there are several reasons:
338344

339345
- Perhaps your shared packages contain some code esbuild cannot transfer to EcmaScript modules. This should not be the case for packages, built with the Angular CLI or Nx and the underlying package ng-packagr. If this happens, please let us know about the package causing troubles.
340346

347+
### How to deal with CommonJS Packages?
348+
349+
The good message is, that the official Angular Package Format defines the usage of ECMA Script Modules (ESM) for years. This is the future-proof standard, Native Federation is built upon and all npm packages created with the Angular CLI follow. If you use older CommonJS-based packages, Native Federation automatically converts them to ESM. Depending on the package, this might change some details. Here, you find some [information for dealing with CommonJS packages](https://shorturl.at/jmzH0).
350+
351+
## How to Deal with Transitive Dependencies?
352+
353+
Since version 18@latest, also transitive dependencies are shared. For instance, `primeng` uses a lib `@primeuix/styled` for theming. The latter one is now shared too if `primeng` is. This prevents possible challanges but also results in more bundles. If you don't want to share such a transitive dependency, just put it into the `skip` list.
354+
355+
## How to Manually Define a Package's Entry Point?
356+
357+
Usually, Native Federation automatically detects entry points into shared packages. If the packages neither align with the official standard nor with typical conventions beyond these standards, you can also directly provide the entry point:
358+
359+
```js
360+
module.exports = withNativeFederation({
361+
shared: {
362+
...shareAll({
363+
singleton: true,
364+
strictVersion: true,
365+
requiredVersion: 'auto',
366+
}),
367+
'test-pkg': {
368+
packageInfo: {
369+
entryPoint: '/path/to/test-pkg/entry.mjs',
370+
version: '1.0.0',
371+
esm: true,
372+
},
373+
},
374+
},
375+
});
376+
```
377+
378+
As in such cases, we cannot expect to find a `package.json` nearby, you also have to specifiy the `version` and the `esm` flag by hand.
379+
341380
### How to speed up package preparation during the build process
342381

343382
The already prepared packages are cached in `node_modules/.cache`. Make sure, this folder is reused across subsequent build process runs.

libs/native-federation/docs/share-faq.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,44 @@ skip: [
5555
/^my-package/, // RegExp
5656
];
5757
```
58+
59+
As an alternative, you can also provide a lambda expression:
60+
61+
```typescript
62+
skip: [
63+
'this-package', // string-based entry
64+
'that-package', // another string-based one
65+
(p) => p.startsWith('my-package'), // RegExp
66+
];
67+
```
68+
69+
Please note, that a provided string is fully compared (not with startsWith semantic). Hence, in this example shown, `this-package` is excluded but not secondary entry points like `this-package/interop`.
70+
71+
## Transitive Dependencies
72+
73+
Since version 18@latest, also transitive dependencies are shared. For instance, `primeng` and individual theming packages for `primeng` communicate via the lib `@primeuix/styled`. The latter one is now shared too together with the two former ones. This prevents possible challanges but also results in more bundles. If you don't want to share such a transitive dependency, just put it into the `skip` list.
74+
75+
## Manually Providing a Package's Entry Point
76+
77+
Usually, Native Federation automatically detects entry points into shared packages. If the packages neither align with the official standard nor with typical conventions beyond these standards, you can also directly provide the entry point:
78+
79+
```js
80+
module.exports = withNativeFederation({
81+
shared: {
82+
...shareAll({
83+
singleton: true,
84+
strictVersion: true,
85+
requiredVersion: 'auto',
86+
}),
87+
'test-pkg': {
88+
packageInfo: {
89+
entryPoint: '/path/to/test-pkg/entry.mjs',
90+
version: '1.0.0',
91+
esm: true,
92+
},
93+
},
94+
},
95+
});
96+
```
97+
98+
As in such cases, we cannot expect to find a `package.json` nearby, you also have to specifiy the `version` and the `esm` flag by hand.

libs/native-federation/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export {
33
findRootTsConfigJson,
44
share,
55
shareAll,
6-
DEFAULT_SKIP_LIST
6+
DEFAULT_SKIP_LIST,
77
} from '@softarc/native-federation/build';

0 commit comments

Comments
 (0)