@module-federation/vite 1.7.1 → 1.8.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/lib/index.cjs +290 -141
- package/lib/index.esm.js +291 -142
- package/lib/index.modern.js +263 -130
- package/lib/index.umd.js +290 -141
- package/lib/plugins/pluginMFManifest.d.ts +1 -1
- package/lib/utils/__tests__/cssModuleHelpers.test.d.ts +1 -0
- package/lib/utils/__tests__/helpers.d.ts +2 -0
- package/lib/utils/__tests__/publicPath.test.d.ts +1 -0
- package/lib/utils/cssModuleHelpers.d.ts +75 -0
- package/lib/utils/normalizeModuleFederationOptions.d.ts +6 -0
- package/lib/utils/publicPath.d.ts +9 -0
- package/package.json +2 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export type OutputBundleItem = {
|
|
2
|
+
type: 'chunk' | 'asset';
|
|
3
|
+
name?: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
modules?: Record<string, unknown> | undefined;
|
|
6
|
+
dynamicImports?: string[] | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const ASSET_TYPES: readonly ["js", "css"];
|
|
9
|
+
export declare const LOAD_TIMINGS: readonly ["sync", "async"];
|
|
10
|
+
export declare const JS_EXTENSIONS: readonly [".ts", ".tsx", ".jsx", ".mjs", ".cjs"];
|
|
11
|
+
export type AssetType = (typeof ASSET_TYPES)[number];
|
|
12
|
+
export type AssetMap = {
|
|
13
|
+
sync: string[];
|
|
14
|
+
async: string[];
|
|
15
|
+
};
|
|
16
|
+
export type PreloadMap = Record<string, {
|
|
17
|
+
[K in (typeof ASSET_TYPES)[number]]: AssetMap;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an empty asset map structure for tracking JS and CSS assets
|
|
21
|
+
* @returns Initialized asset map with sync/async arrays for JS and CSS
|
|
22
|
+
*/
|
|
23
|
+
export declare const createEmptyAssetMap: () => {
|
|
24
|
+
js: AssetMap;
|
|
25
|
+
css: AssetMap;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Tracks an asset in the preload map with deduplication
|
|
29
|
+
* @param map - The preload map to update
|
|
30
|
+
* @param key - The module key to track under
|
|
31
|
+
* @param fileName - The asset filename to track
|
|
32
|
+
* @param isAsync - Whether the asset is loaded async
|
|
33
|
+
* @param type - The asset type ('js' or 'css')
|
|
34
|
+
*/
|
|
35
|
+
export declare const trackAsset: (map: PreloadMap, key: string, fileName: string, isAsync: boolean, type: AssetType) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a file is a CSS file by extension
|
|
38
|
+
* @param fileName - The filename to check
|
|
39
|
+
* @returns True if file has a CSS extension (.css, .scss, .less)
|
|
40
|
+
*/
|
|
41
|
+
export declare const isCSSFile: (fileName: string) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Collects all CSS assets from the bundle
|
|
44
|
+
* @param bundle - The Rollup output bundle
|
|
45
|
+
* @returns Set of CSS asset filenames
|
|
46
|
+
*/
|
|
47
|
+
export declare const collectCssAssets: (bundle: Record<string, OutputBundleItem>) => Set<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Processes module assets and tracks them in the files map
|
|
50
|
+
* @param bundle - The Rollup output bundle
|
|
51
|
+
* @param filesMap - The preload map to populate
|
|
52
|
+
* @param moduleMatcher - Function that matches module paths to keys
|
|
53
|
+
*/
|
|
54
|
+
export declare const processModuleAssets: (bundle: Record<string, OutputBundleItem>, filesMap: PreloadMap, moduleMatcher: (modulePath: string) => string | undefined) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Adds global CSS assets to all module exports
|
|
57
|
+
* @param filesMap - The preload map to update
|
|
58
|
+
* @param cssAssets - Set of CSS asset filenames to add
|
|
59
|
+
*/
|
|
60
|
+
export declare const addCssAssetsToAllExports: (filesMap: PreloadMap, cssAssets: Set<string>) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Deduplicates assets in the files map
|
|
63
|
+
* @param filesMap - The preload map to deduplicate
|
|
64
|
+
* @returns New deduplicated preload map
|
|
65
|
+
*/
|
|
66
|
+
export declare const deduplicateAssets: (filesMap: PreloadMap) => PreloadMap;
|
|
67
|
+
/**
|
|
68
|
+
* Builds a mapping between module files and their share keys
|
|
69
|
+
* @param shareKeys - Set of share keys to map
|
|
70
|
+
* @param resolveFn - Function to resolve module paths
|
|
71
|
+
* @returns Map of file paths to their corresponding share keys
|
|
72
|
+
*/
|
|
73
|
+
export declare const buildFileToShareKeyMap: (shareKeys: Set<string>, resolveFn: (id: string) => Promise<{
|
|
74
|
+
id: string;
|
|
75
|
+
} | null>) => Promise<Map<string, string>>;
|
|
@@ -36,6 +36,11 @@ export type ModuleFederationOptions = {
|
|
|
36
36
|
remotes?: Record<string, string | RemoteObjectConfig> | undefined;
|
|
37
37
|
runtime?: any;
|
|
38
38
|
shareScope?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Override the public path used for remote entries
|
|
41
|
+
* Defaults to Vite's base config or "auto" if base is empty
|
|
42
|
+
*/
|
|
43
|
+
publicPath?: string;
|
|
39
44
|
shared?: string[] | Record<string, string | {
|
|
40
45
|
name?: string;
|
|
41
46
|
version?: string;
|
|
@@ -70,6 +75,7 @@ export interface NormalizedModuleFederationOptions {
|
|
|
70
75
|
dts?: boolean | PluginDtsOptions;
|
|
71
76
|
shareStrategy: ShareStrategy;
|
|
72
77
|
getPublicPath?: string;
|
|
78
|
+
publicPath?: string;
|
|
73
79
|
ignoreOrigin?: boolean;
|
|
74
80
|
virtualModuleDir: string;
|
|
75
81
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NormalizedModuleFederationOptions } from './normalizeModuleFederationOptions';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the public path for remote entries
|
|
4
|
+
* @param options - Module Federation options
|
|
5
|
+
* @param viteBase - Vite's base config value
|
|
6
|
+
* @param originalBase - Original base config before any transformations
|
|
7
|
+
* @returns The resolved public path
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePublicPath(options: NormalizedModuleFederationOptions, viteBase: string, originalBase?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Vite plugin for Module Federation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"prettier": "3.3.3",
|
|
46
46
|
"pretty-quick": "^4.0.0",
|
|
47
47
|
"rimraf": "^6.0.1",
|
|
48
|
+
"rollup": "^4.47.1",
|
|
48
49
|
"vite": "^5.4.3",
|
|
49
50
|
"vitest": "^2.1.1",
|
|
50
51
|
"wait-on": "^8.0.1"
|