@module-federation/esbuild 0.0.0-next-20240524225331 → 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
@@ -1,6 +1,3 @@
1
- Here's an updated README.md that incorporates the plugin options and ensures they are met:
2
-
3
-
4
1
  # @module-federation/esbuild
5
2
 
6
3
  This package provides an esbuild plugin for Module Federation, enabling you to easily share code between independently built and deployed applications.
@@ -20,45 +17,34 @@ To use the Module Federation plugin with esbuild, add it to your esbuild configu
20
17
  ```js
21
18
  const esbuild = require('esbuild');
22
19
  const path = require('path');
23
- const fs = require('fs');
24
20
  const { moduleFederationPlugin } = require('@module-federation/esbuild/esbuild-adapter');
25
- const { federationBuilder } = require('@module-federation/esbuild/build');
21
+ const federationConfig = require('./federation.config.js');
26
22
 
27
- async function build() {
23
+ async function buildApp() {
28
24
  const tsConfig = 'tsconfig.json';
29
25
  const outputPath = path.join('dist', 'host');
30
26
 
31
- await federationBuilder.init({
32
- options: {
33
- workspaceRoot: path.join(__dirname, '..'),
34
- outputPath,
35
- tsConfig,
36
- federationConfig: path.join('host', 'federation.config.js'),
37
- verbose: false,
38
- watch: false,
39
- },
40
- });
41
-
42
- await esbuild.build({
43
- entryPoints: [path.join('host', 'main.ts')],
44
- external: federationBuilder.externals,
45
- outdir: outputPath,
46
- bundle: true,
47
- platform: 'browser',
48
- format: 'esm',
49
- mainFields: ['es2020', 'browser', 'module', 'main'],
50
- conditions: ['es2020', 'es2015', 'module'],
51
- resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
52
- tsconfig: tsConfig,
53
- splitting: true,
54
- plugins: [moduleFederationPlugin(federationBuilder)],
55
- });
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
+ }
56
45
  }
57
46
 
58
- build().catch((err) => {
59
- console.error(err);
60
- process.exit(1);
61
- }
47
+ buildApp();
62
48
 
63
49
  // Example of federation.config.js
64
50
 
@@ -115,3 +101,4 @@ Creates an esbuild plugin for Module Federation.
115
101
 
116
102
  Returns an esbuild plugin instance.
117
103
 
104
+