Skip to content

Commit 2ac188d

Browse files
committed
docs(nf-core): mention esbuild adapter
1 parent 4bbd348 commit 2ac188d

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

libs/native-federation-core/README.md

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ Big thanks to:
5050

5151
## Using this Library
5252

53+
### Installing the Library
54+
55+
```
56+
npm i @softarc/native-federation
57+
```
58+
59+
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:
60+
61+
```
62+
npm i @softarc/native-federation-esbuild
63+
```
64+
65+
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.
66+
67+
You can also provide your own adapter by providing a function aligning with the ``BuildAdapter`` type.
68+
69+
5370
### Augment your Build Process
5471

5572
Just call three helper methods provided by our ``federationBuilder`` in your build process to adjust it for Native Federation.
@@ -58,7 +75,7 @@ Just call three helper methods provided by our ``federationBuilder`` in your bui
5875
import * as esbuild from 'esbuild';
5976
import * as path from 'path';
6077
import * as fs from 'fs';
61-
import { esBuildAdapter } from './esbuild-adapter';
78+
import { esBuildAdapter } from '@softarc/native-federation-esbuild';
6279
import { federationBuilder } from '@softarc/native-federation/build';
6380

6481

@@ -115,32 +132,7 @@ await esbuild.build({
115132
await federationBuilder.build();
116133
```
117134

118-
The method ``federationBuilder.build`` bundles the shared and exposed parts of your app. For this, it needs a bundler. As this solution is tooling-agnostic, you need to provide an adapter for your bundler:
119-
120-
```typescript
121-
import { BuildAdapter } from '@softarc/native-federation/build';
122-
import * as esbuild from 'esbuild';
123-
124-
export const esBuildAdapter: BuildAdapter = async (options) => {
125-
126-
const {
127-
entryPoint,
128-
external,
129-
outfile,
130-
} = options;
131-
132-
await esbuild.build({
133-
entryPoints: [entryPoint],
134-
external,
135-
outfile,
136-
bundle: true,
137-
sourcemap: true,
138-
minify: true,
139-
format: 'esm',
140-
target: ['esnext']
141-
});
142-
}
143-
```
135+
The method ``federationBuilder.build`` bundles the shared and exposed parts of your app.
144136

145137
### Configuring Hosts
146138

0 commit comments

Comments
 (0)