@module-federation/vite 0.2.8 → 1.0.0-alpha-ffc6e23

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,4 +1,4 @@
1
- # Vite/Rollup plugin for Module Federation
1
+ # Vite plugin for Module Federation
2
2
 
3
3
  ## Reason why 🤔
4
4
 
@@ -10,64 +10,69 @@ This plugin makes Module Federation work together with [Vite](https://vitejs.dev
10
10
  ## Working implementations
11
11
 
12
12
  ### [React](https://github.com/module-federation/module-federation-examples/tree/master/vite-react-microfrontends)<br>
13
+
13
14
  ### [Svelte](https://github.com/module-federation/module-federation-examples/tree/master/vite-svelte-microfrontends)<br>
14
- ### [Vue](https://github.com/module-federation/module-federation-examples/tree/master/vite-vue-microfrontends)
15
15
 
16
+ ### [Vue](https://github.com/module-federation/module-federation-examples/tree/master/vite-vue-microfrontends)
16
17
 
17
18
  ## Getting started 🚀
18
19
 
19
- This plugin is based on top of [native-federation](https://www.npmjs.com/package/@softarc/native-federation) so this library is a [peer dependency](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependencies).
20
+ https://module-federation.io/guide/basic/webpack.html
20
21
 
21
- You need to extend the Vite configuration with this plugin:
22
-
23
- ```typescript
22
+ ```js
23
+ // vite.config.js
24
24
  import { defineConfig } from 'vite';
25
- import { federation } from '@module-federation/vite';
26
- import { createEsBuildAdapter } from '@softarc/native-federation-esbuild';
25
+ import vue from '@vitejs/plugin-vue';
26
+ import { federation } from 'module-federation-vite';
27
+ import topLevelAwait from 'vite-plugin-top-level-await';
27
28
 
28
29
  // https://vitejs.dev/config/
29
- export default defineConfig(async ({ command }) => ({
30
- server: {
31
- fs: {
32
- allow: ['.', '../shared'],
33
- },
34
- },
30
+ export default defineConfig({
35
31
  plugins: [
36
- await federation({
37
- options: {
38
- workspaceRoot: __dirname,
39
- outputPath: 'dist',
40
- tsConfig: 'tsconfig.json',
41
- federationConfig: 'module-federation/federation.config.cjs',
42
- verbose: false,
43
- dev: command === 'serve',
32
+ federation({
33
+ name: 'bbc',
34
+ remotes: {
35
+ mfapp01: 'mfapp01@https://unpkg.com/mf-app-01@1.0.9/dist/remoteEntry.js',
36
+ remote2: 'mfapp02@https://unpkg.com/mf-app-02/dist/remoteEntry.js',
37
+ remote3:
38
+ 'remote1@https://unpkg.com/react-manifest-example_remote1@1.0.6/dist/mf-manifest.json',
39
+ // "remote4": {
40
+ // entry: "http://localhost:5174/dd/remoteEntry.js",
41
+ // globalEntryName: "bb",
42
+ // type: "esm"
43
+ // }
44
+ },
45
+ exposes: {
46
+ App: './src/App.vue',
47
+ },
48
+ filename: 'dd/remoteEntry.js',
49
+ shared: {
50
+ vue: {},
51
+ react: {
52
+ requiredVersion: '18',
53
+ },
44
54
  },
45
- adapter: createEsBuildAdapter({ plugins: [...], }),
46
55
  }),
47
- [...]
56
+ // If you set build.target: "chrome89", you can remove this plugin
57
+ // topLevelAwait(),
48
58
  ],
49
- }));
59
+ build: {
60
+ target: 'chrome89',
61
+ },
62
+ });
50
63
  ```
51
64
 
52
- <br>
65
+ ## roadmap
53
66
 
54
- ### Define configs
67
+ - feat: generate mf-manifest.json
68
+ - feat: support chrome plugin
55
69
 
56
- You need to define two different configurations in the `federationConfig` property.<br>
57
- Here are two examples:
70
+ * ~~feat: support runtime plugins~~
58
71
 
59
- - [host](https://www.npmjs.com/package/@softarc/native-federation#configuring-hosts)
60
- - [remote](https://www.npmjs.com/package/@softarc/native-federation#configuring-remotes)
61
- <br><br>
72
+ - feat: download remote d.ts
73
+ - feat: generate d.ts
74
+ - feat: support @vitejs/plugin-legacy
62
75
 
63
76
  ### So far so good 🎉
64
77
 
65
78
  Now you are ready to use Module Federation in Vite!
66
-
67
- ## Thanks 🤝
68
-
69
- Big thanks to:
70
-
71
- [Manfred Steyer](https://twitter.com/manfredsteyer), Speaker, Trainer, Consultant and Author with focus on Angular. Google Developer Expert (GDE) and Microsoft MVP.
72
-
73
- who collaborate with me to make this possible.