@module-federation/esbuild 0.0.0-next-20240524231356 → 0.0.0-next-20240528203231

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 CHANGED
@@ -17,45 +17,34 @@ To use the Module Federation plugin with esbuild, add it to your esbuild configu
17
17
  ```js
18
18
  const esbuild = require('esbuild');
19
19
  const path = require('path');
20
- const fs = require('fs');
21
20
  const { moduleFederationPlugin } = require('@module-federation/esbuild/esbuild-adapter');
22
- const { federationBuilder } = require('@module-federation/esbuild/build');
21
+ const federationConfig = require('./federation.config.js');
23
22
 
24
- async function build() {
23
+ async function buildApp() {
25
24
  const tsConfig = 'tsconfig.json';
26
25
  const outputPath = path.join('dist', 'host');
27
26
 
28
- await federationBuilder.init({
29
- options: {
30
- workspaceRoot: path.join(__dirname, '..'),
31
- outputPath,
32
- tsConfig,
33
- federationConfig: path.join('host', 'federation.config.js'),
34
- verbose: false,
35
- watch: false,
36
- },
37
- });
38
-
39
- await esbuild.build({
40
- entryPoints: [path.join('host', 'main.ts')],
41
- external: federationBuilder.externals,
42
- outdir: outputPath,
43
- bundle: true,
44
- platform: 'browser',
45
- format: 'esm',
46
- mainFields: ['es2020', 'browser', 'module', 'main'],
47
- conditions: ['es2020', 'es2015', 'module'],
48
- resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
49
- tsconfig: tsConfig,
50
- splitting: true,
51
- plugins: [moduleFederationPlugin(federationBuilder)],
52
- });
27
+ try {
28
+ await esbuild.build({
29
+ entryPoints: [path.join('host', 'main.ts')],
30
+ outdir: outputPath,
31
+ bundle: true,
32
+ platform: 'browser',
33
+ format: 'esm',
34
+ mainFields: ['es2020', 'browser', 'module', 'main'],
35
+ conditions: ['es2020', 'es2015', 'module'],
36
+ resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
37
+ tsconfig: tsConfig,
38
+ splitting: true,
39
+ plugins: [moduleFederationPlugin(federationConfig)],
40
+ });
41
+ } catch (err) {
42
+ console.error(err);
43
+ process.exit(1);
44
+ }
53
45
  }
54
46
 
55
- build().catch((err) => {
56
- console.error(err);
57
- process.exit(1);
58
- }
47
+ buildApp();
59
48
 
60
49
  // Example of federation.config.js
61
50
 
@@ -112,3 +101,4 @@ Creates an esbuild plugin for Module Federation.
112
101
 
113
102
  Returns an esbuild plugin instance.
114
103
 
104
+