@module-federation/vite 1.7.0 → 1.7.2

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.
@@ -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>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/vite",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "source": "src/index.ts",
@@ -9,6 +9,22 @@
9
9
  "files": [
10
10
  "lib/**/*"
11
11
  ],
12
+ "scripts": {
13
+ "prepare": "husky install",
14
+ "fmt": "prettier --write src",
15
+ "fmt.check": "prettier --check src",
16
+ "format": "pretty-quick",
17
+ "dev": "microbundle watch --no-sourcemap --compress=false",
18
+ "build": "rimraf lib && microbundle --no-sourcemap --compress=false",
19
+ "dev-rv": "pnpm -filter 'examples-rust-vite*' run dev",
20
+ "preview-rv": "pnpm -filter 'examples-rust-vite*' run preview",
21
+ "dev-vv": "pnpm -filter 'examples-vite-vite*' run dev",
22
+ "dev-nv": "pnpm -filter 'examples-nuxt-vite-host' -filter 'examples-vite-vite-remote' run dev",
23
+ "preview-vv": "pnpm -filter 'examples-vite-vite*' run preview",
24
+ "multi-example": "pnpm --filter \"multi-example-*\" --parallel run start",
25
+ "test": "vitest",
26
+ "e2e": "playwright test"
27
+ },
12
28
  "repository": {
13
29
  "type": "git",
14
30
  "url": "git+https://github.com/module-federation/vite.git"
@@ -28,6 +44,7 @@
28
44
  "url": "https://github.com/module-federation/vite/issues"
29
45
  },
30
46
  "homepage": "https://github.com/module-federation/vite#readme",
47
+ "packageManager": "pnpm@9.1.3",
31
48
  "dependencies": {
32
49
  "@module-federation/runtime": "^0.17.1",
33
50
  "@rollup/pluginutils": "^5.1.0",
@@ -45,23 +62,9 @@
45
62
  "prettier": "3.3.3",
46
63
  "pretty-quick": "^4.0.0",
47
64
  "rimraf": "^6.0.1",
65
+ "rollup": "^4.47.1",
48
66
  "vite": "^5.4.3",
49
67
  "vitest": "^2.1.1",
50
68
  "wait-on": "^8.0.1"
51
- },
52
- "scripts": {
53
- "fmt": "prettier --write src",
54
- "fmt.check": "prettier --check src",
55
- "format": "pretty-quick",
56
- "dev": "microbundle watch --no-sourcemap --compress=false",
57
- "build": "rimraf lib && microbundle --no-sourcemap --compress=false",
58
- "dev-rv": "pnpm -filter 'examples-rust-vite*' run dev",
59
- "preview-rv": "pnpm -filter 'examples-rust-vite*' run preview",
60
- "dev-vv": "pnpm -filter 'examples-vite-vite*' run dev",
61
- "dev-nv": "pnpm -filter 'examples-nuxt-vite-host' -filter 'examples-vite-vite-remote' run dev",
62
- "preview-vv": "pnpm -filter 'examples-vite-vite*' run preview",
63
- "multi-example": "pnpm --filter \"multi-example-*\" --parallel run start",
64
- "test": "vitest",
65
- "e2e": "playwright test"
66
69
  }
67
- }
70
+ }