@module-federation/vite 1.11.0 → 1.12.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.
Files changed (47) hide show
  1. package/README.md +4 -1
  2. package/lib/index.cjs +2113 -2109
  3. package/lib/index.d.cts +131 -0
  4. package/lib/index.d.mts +131 -0
  5. package/lib/index.mjs +2239 -0
  6. package/package.json +40 -28
  7. package/lib/index.d.ts +0 -4
  8. package/lib/index.esm.js +0 -2236
  9. package/lib/index.modern.js +0 -2288
  10. package/lib/index.umd.js +0 -2257
  11. package/lib/plugins/__tests__/pluginCheckAliasConflicts.test.d.ts +0 -1
  12. package/lib/plugins/__tests__/pluginDts.test.d.ts +0 -1
  13. package/lib/plugins/pluginAddEntry.d.ts +0 -10
  14. package/lib/plugins/pluginCheckAliasConflicts.d.ts +0 -9
  15. package/lib/plugins/pluginDevProxyModuleTopLevelAwait.d.ts +0 -2
  16. package/lib/plugins/pluginDts.d.ts +0 -3
  17. package/lib/plugins/pluginMFManifest.d.ts +0 -3
  18. package/lib/plugins/pluginModuleParseEnd.d.ts +0 -10
  19. package/lib/plugins/pluginProxyRemoteEntry.d.ts +0 -2
  20. package/lib/plugins/pluginProxyRemotes.d.ts +0 -3
  21. package/lib/plugins/pluginProxySharedModule_preBuild.d.ts +0 -7
  22. package/lib/plugins/pluginVarRemoteEntry.d.ts +0 -3
  23. package/lib/utils/PromiseStore.d.ts +0 -16
  24. package/lib/utils/VirtualModule.d.ts +0 -26
  25. package/lib/utils/__tests__/VirtualModule.test.d.ts +0 -1
  26. package/lib/utils/__tests__/cssModuleHelpers.test.d.ts +0 -1
  27. package/lib/utils/__tests__/helpers.d.ts +0 -2
  28. package/lib/utils/__tests__/normalizeModuleFederationOption.test.d.ts +0 -1
  29. package/lib/utils/__tests__/publicPath.test.d.ts +0 -1
  30. package/lib/utils/__tests__/serializeRuntimeOptions.test.d.ts +0 -1
  31. package/lib/utils/aliasToArrayPlugin.d.ts +0 -10
  32. package/lib/utils/bundleHelpers.d.ts +0 -2
  33. package/lib/utils/cssModuleHelpers.d.ts +0 -75
  34. package/lib/utils/localSharedImportMap_temp.d.ts +0 -2
  35. package/lib/utils/mapCodeToCodeWithSourcemap.d.ts +0 -4
  36. package/lib/utils/normalizeModuleFederationOptions.d.ts +0 -164
  37. package/lib/utils/normalizeOptimizeDeps.d.ts +0 -9
  38. package/lib/utils/packageNameUtils.d.ts +0 -22
  39. package/lib/utils/publicPath.d.ts +0 -9
  40. package/lib/utils/serializeRuntimeOptions.d.ts +0 -10
  41. package/lib/utils/wrapManualChunks.d.ts +0 -1
  42. package/lib/virtualModules/index.d.ts +0 -6
  43. package/lib/virtualModules/virtualExposes.d.ts +0 -2
  44. package/lib/virtualModules/virtualRemoteEntry.d.ts +0 -16
  45. package/lib/virtualModules/virtualRemotes.d.ts +0 -6
  46. package/lib/virtualModules/virtualRuntimeInitStatus.d.ts +0 -3
  47. package/lib/virtualModules/virtualShared_preBuild.d.ts +0 -17
@@ -0,0 +1,131 @@
1
+ import { Plugin } from "vite";
2
+ import { ShareStrategy } from "@module-federation/runtime/types";
3
+ import { sharePlugin } from "@module-federation/sdk";
4
+
5
+ //#region src/utils/normalizeModuleFederationOptions.d.ts
6
+ interface RemoteObjectConfig {
7
+ type?: string;
8
+ name: string;
9
+ entry: string;
10
+ entryGlobalName?: string;
11
+ shareScope?: string;
12
+ }
13
+ interface ManifestOptions {
14
+ filePath?: string;
15
+ disableAssetsAnalyze?: boolean;
16
+ fileName?: string;
17
+ }
18
+ type ModuleFederationOptions = {
19
+ exposes?: Record<string, string | {
20
+ import: string;
21
+ }> | undefined;
22
+ filename?: string;
23
+ library?: any;
24
+ name: string;
25
+ remotes?: Record<string, string | RemoteObjectConfig> | undefined;
26
+ runtime?: any;
27
+ shareScope?: string;
28
+ /**
29
+ * Override the public path used for remote entries
30
+ * Defaults to Vite's base config or "auto" if base is empty
31
+ */
32
+ publicPath?: string;
33
+ /**
34
+ * Controls whether all CSS assets from the bundle should be added to every exposed module.
35
+ * When false (default), the plugin will not process any CSS assets.
36
+ * When true, all CSS assets are bundled into every exposed module.
37
+ */
38
+ bundleAllCSS?: boolean;
39
+ shared?: string[] | Record<string, string | {
40
+ name?: string;
41
+ version?: string;
42
+ shareScope?: string;
43
+ singleton?: boolean;
44
+ requiredVersion?: string;
45
+ strictVersion?: boolean;
46
+ import?: sharePlugin.SharedConfig['import'];
47
+ }> | undefined;
48
+ runtimePlugins?: Array<string | [string, Record<string, unknown>]>;
49
+ getPublicPath?: string;
50
+ implementation?: string;
51
+ manifest?: ManifestOptions | boolean;
52
+ dev?: boolean | PluginDevOptions;
53
+ dts?: boolean | PluginDtsOptions;
54
+ shareStrategy?: ShareStrategy;
55
+ ignoreOrigin?: boolean;
56
+ virtualModuleDir?: string;
57
+ hostInitInjectLocation?: HostInitInjectLocationOptions;
58
+ /**
59
+ * Timeout for parsing modules in seconds.
60
+ * Defaults to 10 seconds.
61
+ */
62
+ moduleParseTimeout?: number;
63
+ /**
64
+ * Allows generate additional remoteEntry file for "var" host environment
65
+ */
66
+ varFilename?: string;
67
+ /**
68
+ * Target environment for the build to enable effective tree-shaking.
69
+ *
70
+ * @see https://module-federation.io/configure/experiments#target
71
+ * @default 'web' (or 'node' if build.ssr is enabled)
72
+ */
73
+ target?: 'web' | 'node';
74
+ };
75
+ type HostInitInjectLocationOptions = 'entry' | 'html';
76
+ interface PluginDevOptions {
77
+ disableLiveReload?: boolean;
78
+ disableHotTypesReload?: boolean;
79
+ disableDynamicRemoteTypeHints?: boolean;
80
+ }
81
+ interface RemoteTypeUrl {
82
+ alias?: string;
83
+ api: string;
84
+ zip: string;
85
+ }
86
+ interface RemoteTypeUrls {
87
+ [remoteName: string]: RemoteTypeUrl;
88
+ }
89
+ interface PluginDtsOptions {
90
+ generateTypes?: boolean | DtsRemoteOptions;
91
+ consumeTypes?: boolean | DtsHostOptions;
92
+ tsConfigPath?: string;
93
+ extraOptions?: Record<string, unknown>;
94
+ implementation?: string;
95
+ cwd?: string;
96
+ displayErrorInTerminal?: boolean;
97
+ }
98
+ interface DtsRemoteOptions {
99
+ tsConfigPath?: string;
100
+ typesFolder?: string;
101
+ compiledTypesFolder?: string;
102
+ deleteTypesFolder?: boolean;
103
+ additionalFilesToCompile?: string[];
104
+ compilerInstance?: 'tsc' | 'vue-tsc' | 'tspc' | string;
105
+ compileInChildProcess?: boolean;
106
+ generateAPITypes?: boolean;
107
+ extractThirdParty?: boolean | {
108
+ exclude?: Array<string | RegExp>;
109
+ };
110
+ extractRemoteTypes?: boolean;
111
+ abortOnError?: boolean;
112
+ deleteTsConfig?: boolean;
113
+ }
114
+ interface DtsHostOptions {
115
+ typesFolder?: string;
116
+ abortOnError?: boolean;
117
+ remoteTypesFolder?: string;
118
+ deleteTypesFolder?: boolean;
119
+ maxRetries?: number;
120
+ consumeAPITypes?: boolean;
121
+ runtimePkgs?: string[];
122
+ remoteTypeUrls?: (() => Promise<RemoteTypeUrls>) | RemoteTypeUrls;
123
+ timeout?: number;
124
+ family?: 4 | 6;
125
+ typesOnBuild?: boolean;
126
+ }
127
+ //#endregion
128
+ //#region src/index.d.ts
129
+ declare function federation(mfUserOptions: ModuleFederationOptions): Plugin[];
130
+ //#endregion
131
+ export { federation };
@@ -0,0 +1,131 @@
1
+ import { sharePlugin } from "@module-federation/sdk";
2
+ import { Plugin } from "vite";
3
+ import { ShareStrategy } from "@module-federation/runtime/types";
4
+
5
+ //#region src/utils/normalizeModuleFederationOptions.d.ts
6
+ interface RemoteObjectConfig {
7
+ type?: string;
8
+ name: string;
9
+ entry: string;
10
+ entryGlobalName?: string;
11
+ shareScope?: string;
12
+ }
13
+ interface ManifestOptions {
14
+ filePath?: string;
15
+ disableAssetsAnalyze?: boolean;
16
+ fileName?: string;
17
+ }
18
+ type ModuleFederationOptions = {
19
+ exposes?: Record<string, string | {
20
+ import: string;
21
+ }> | undefined;
22
+ filename?: string;
23
+ library?: any;
24
+ name: string;
25
+ remotes?: Record<string, string | RemoteObjectConfig> | undefined;
26
+ runtime?: any;
27
+ shareScope?: string;
28
+ /**
29
+ * Override the public path used for remote entries
30
+ * Defaults to Vite's base config or "auto" if base is empty
31
+ */
32
+ publicPath?: string;
33
+ /**
34
+ * Controls whether all CSS assets from the bundle should be added to every exposed module.
35
+ * When false (default), the plugin will not process any CSS assets.
36
+ * When true, all CSS assets are bundled into every exposed module.
37
+ */
38
+ bundleAllCSS?: boolean;
39
+ shared?: string[] | Record<string, string | {
40
+ name?: string;
41
+ version?: string;
42
+ shareScope?: string;
43
+ singleton?: boolean;
44
+ requiredVersion?: string;
45
+ strictVersion?: boolean;
46
+ import?: sharePlugin.SharedConfig['import'];
47
+ }> | undefined;
48
+ runtimePlugins?: Array<string | [string, Record<string, unknown>]>;
49
+ getPublicPath?: string;
50
+ implementation?: string;
51
+ manifest?: ManifestOptions | boolean;
52
+ dev?: boolean | PluginDevOptions;
53
+ dts?: boolean | PluginDtsOptions;
54
+ shareStrategy?: ShareStrategy;
55
+ ignoreOrigin?: boolean;
56
+ virtualModuleDir?: string;
57
+ hostInitInjectLocation?: HostInitInjectLocationOptions;
58
+ /**
59
+ * Timeout for parsing modules in seconds.
60
+ * Defaults to 10 seconds.
61
+ */
62
+ moduleParseTimeout?: number;
63
+ /**
64
+ * Allows generate additional remoteEntry file for "var" host environment
65
+ */
66
+ varFilename?: string;
67
+ /**
68
+ * Target environment for the build to enable effective tree-shaking.
69
+ *
70
+ * @see https://module-federation.io/configure/experiments#target
71
+ * @default 'web' (or 'node' if build.ssr is enabled)
72
+ */
73
+ target?: 'web' | 'node';
74
+ };
75
+ type HostInitInjectLocationOptions = 'entry' | 'html';
76
+ interface PluginDevOptions {
77
+ disableLiveReload?: boolean;
78
+ disableHotTypesReload?: boolean;
79
+ disableDynamicRemoteTypeHints?: boolean;
80
+ }
81
+ interface RemoteTypeUrl {
82
+ alias?: string;
83
+ api: string;
84
+ zip: string;
85
+ }
86
+ interface RemoteTypeUrls {
87
+ [remoteName: string]: RemoteTypeUrl;
88
+ }
89
+ interface PluginDtsOptions {
90
+ generateTypes?: boolean | DtsRemoteOptions;
91
+ consumeTypes?: boolean | DtsHostOptions;
92
+ tsConfigPath?: string;
93
+ extraOptions?: Record<string, unknown>;
94
+ implementation?: string;
95
+ cwd?: string;
96
+ displayErrorInTerminal?: boolean;
97
+ }
98
+ interface DtsRemoteOptions {
99
+ tsConfigPath?: string;
100
+ typesFolder?: string;
101
+ compiledTypesFolder?: string;
102
+ deleteTypesFolder?: boolean;
103
+ additionalFilesToCompile?: string[];
104
+ compilerInstance?: 'tsc' | 'vue-tsc' | 'tspc' | string;
105
+ compileInChildProcess?: boolean;
106
+ generateAPITypes?: boolean;
107
+ extractThirdParty?: boolean | {
108
+ exclude?: Array<string | RegExp>;
109
+ };
110
+ extractRemoteTypes?: boolean;
111
+ abortOnError?: boolean;
112
+ deleteTsConfig?: boolean;
113
+ }
114
+ interface DtsHostOptions {
115
+ typesFolder?: string;
116
+ abortOnError?: boolean;
117
+ remoteTypesFolder?: string;
118
+ deleteTypesFolder?: boolean;
119
+ maxRetries?: number;
120
+ consumeAPITypes?: boolean;
121
+ runtimePkgs?: string[];
122
+ remoteTypeUrls?: (() => Promise<RemoteTypeUrls>) | RemoteTypeUrls;
123
+ timeout?: number;
124
+ family?: 4 | 6;
125
+ typesOnBuild?: boolean;
126
+ }
127
+ //#endregion
128
+ //#region src/index.d.ts
129
+ declare function federation(mfUserOptions: ModuleFederationOptions): Plugin[];
130
+ //#endregion
131
+ export { federation };