@module-federation/vite 1.15.4 → 1.16.0
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 +30 -1
- package/lib/index.cjs +1123 -870
- package/lib/index.d.cts +22 -6
- package/lib/index.d.mts +22 -6
- package/lib/index.mjs +1063 -793
- package/lib/packageUtils-CbbnJvKu.cjs +358 -0
- package/lib/packageUtils-DOekOsFz.mjs +250 -0
- package/lib/pluginDts-B5pcUmam.mjs +309 -0
- package/lib/pluginDts-BEOKyKQ-.cjs +311 -0
- package/lib/utils/ssrEntryLoader.cjs +301 -0
- package/lib/utils/ssrEntryLoader.d.cts +65 -0
- package/lib/utils/ssrEntryLoader.d.mts +66 -0
- package/lib/utils/ssrEntryLoader.mjs +301 -0
- package/package.json +13 -5
package/lib/index.d.cts
CHANGED
|
@@ -78,6 +78,12 @@ type ModuleFederationOptions = {
|
|
|
78
78
|
* @default 'web' (or 'node' if build.ssr is enabled)
|
|
79
79
|
*/
|
|
80
80
|
target?: 'web' | 'node';
|
|
81
|
+
/**
|
|
82
|
+
* Additional packages to mark as external in the SSR remote entry build.
|
|
83
|
+
* Shared packages and MF runtime packages are always external. Use this to
|
|
84
|
+
* add any other Node-only packages that should not be bundled into the SSR entry.
|
|
85
|
+
*/
|
|
86
|
+
ssrExternals?: string[];
|
|
81
87
|
};
|
|
82
88
|
type HostInitInjectLocationOptions = 'entry' | 'html';
|
|
83
89
|
interface PluginDevOptions {
|
|
@@ -88,11 +94,20 @@ interface PluginDevOptions {
|
|
|
88
94
|
* Controls cross-federation HMR for remote modules.
|
|
89
95
|
*
|
|
90
96
|
* - `false` / `undefined` — HMR disabled (default).
|
|
91
|
-
* - `true` — HMR enabled with auto-detected strategy
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
97
|
+
* - `true` — HMR enabled with auto-detected strategy. When a framework
|
|
98
|
+
* plugin with cross-federation HMR support is detected, broadcast/relay
|
|
99
|
+
* is suppressed and the framework's native HMR handles updates:
|
|
100
|
+
* - React (`@vitejs/plugin-react` / `@vitejs/plugin-react-swc`) — the
|
|
101
|
+
* plugin serves a `/@react-refresh` proxy on remotes that delegates
|
|
102
|
+
* to the host's `RefreshRuntime`, unifying the component registry.
|
|
103
|
+
* - Vue (`@vitejs/plugin-vue` / `@vitejs/plugin-vue-jsx`) — the plugin
|
|
104
|
+
* injects a `__VUE_HMR_RUNTIME__` guard into the host page so the
|
|
105
|
+
* first-loaded (host) Vue runtime is pinned and remote-loaded Vue
|
|
106
|
+
* copies cannot overwrite it.
|
|
107
|
+
* For any host, the plugin also injects a script that clears the
|
|
108
|
+
* federation `moduleCache` on `vite:beforeUpdate` so subsequent
|
|
109
|
+
* `loadRemote()` calls return the freshly patched module.
|
|
110
|
+
* Other frameworks fall back to full page reloads.
|
|
96
111
|
* - `'full-reload'` — HMR enabled, always use full page reloads even when
|
|
97
112
|
* a framework with native cross-federation HMR is detected.
|
|
98
113
|
*/
|
|
@@ -147,5 +162,6 @@ interface DtsHostOptions {
|
|
|
147
162
|
//#endregion
|
|
148
163
|
//#region src/index.d.ts
|
|
149
164
|
declare function federation(mfUserOptions: ModuleFederationOptions): any[];
|
|
165
|
+
declare function createModuleFederationConfig<T extends ModuleFederationOptions>(options: T): T;
|
|
150
166
|
//#endregion
|
|
151
|
-
export { type ModuleFederationOptions, type PluginManifestOptions, federation };
|
|
167
|
+
export { type ModuleFederationOptions, type PluginManifestOptions, createModuleFederationConfig, federation };
|
package/lib/index.d.mts
CHANGED
|
@@ -78,6 +78,12 @@ type ModuleFederationOptions = {
|
|
|
78
78
|
* @default 'web' (or 'node' if build.ssr is enabled)
|
|
79
79
|
*/
|
|
80
80
|
target?: 'web' | 'node';
|
|
81
|
+
/**
|
|
82
|
+
* Additional packages to mark as external in the SSR remote entry build.
|
|
83
|
+
* Shared packages and MF runtime packages are always external. Use this to
|
|
84
|
+
* add any other Node-only packages that should not be bundled into the SSR entry.
|
|
85
|
+
*/
|
|
86
|
+
ssrExternals?: string[];
|
|
81
87
|
};
|
|
82
88
|
type HostInitInjectLocationOptions = 'entry' | 'html';
|
|
83
89
|
interface PluginDevOptions {
|
|
@@ -88,11 +94,20 @@ interface PluginDevOptions {
|
|
|
88
94
|
* Controls cross-federation HMR for remote modules.
|
|
89
95
|
*
|
|
90
96
|
* - `false` / `undefined` — HMR disabled (default).
|
|
91
|
-
* - `true` — HMR enabled with auto-detected strategy
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
97
|
+
* - `true` — HMR enabled with auto-detected strategy. When a framework
|
|
98
|
+
* plugin with cross-federation HMR support is detected, broadcast/relay
|
|
99
|
+
* is suppressed and the framework's native HMR handles updates:
|
|
100
|
+
* - React (`@vitejs/plugin-react` / `@vitejs/plugin-react-swc`) — the
|
|
101
|
+
* plugin serves a `/@react-refresh` proxy on remotes that delegates
|
|
102
|
+
* to the host's `RefreshRuntime`, unifying the component registry.
|
|
103
|
+
* - Vue (`@vitejs/plugin-vue` / `@vitejs/plugin-vue-jsx`) — the plugin
|
|
104
|
+
* injects a `__VUE_HMR_RUNTIME__` guard into the host page so the
|
|
105
|
+
* first-loaded (host) Vue runtime is pinned and remote-loaded Vue
|
|
106
|
+
* copies cannot overwrite it.
|
|
107
|
+
* For any host, the plugin also injects a script that clears the
|
|
108
|
+
* federation `moduleCache` on `vite:beforeUpdate` so subsequent
|
|
109
|
+
* `loadRemote()` calls return the freshly patched module.
|
|
110
|
+
* Other frameworks fall back to full page reloads.
|
|
96
111
|
* - `'full-reload'` — HMR enabled, always use full page reloads even when
|
|
97
112
|
* a framework with native cross-federation HMR is detected.
|
|
98
113
|
*/
|
|
@@ -147,5 +162,6 @@ interface DtsHostOptions {
|
|
|
147
162
|
//#endregion
|
|
148
163
|
//#region src/index.d.ts
|
|
149
164
|
declare function federation(mfUserOptions: ModuleFederationOptions): any[];
|
|
165
|
+
declare function createModuleFederationConfig<T extends ModuleFederationOptions>(options: T): T;
|
|
150
166
|
//#endregion
|
|
151
|
-
export { type ModuleFederationOptions, type PluginManifestOptions, federation };
|
|
167
|
+
export { type ModuleFederationOptions, type PluginManifestOptions, createModuleFederationConfig, federation };
|