@module-federation/vite 1.1.2 → 1.1.3

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 CHANGED
@@ -383,7 +383,7 @@ function normalizeModuleFederationOptions(options) {
383
383
  dev: options.dev,
384
384
  dts: options.dts,
385
385
  getPublicPath: options.getPublicPath,
386
- shareStrategy: options.shareStrategy
386
+ shareStrategy: options.shareStrategy || 'version-first'
387
387
  };
388
388
  }
389
389
 
@@ -621,7 +621,7 @@ function generateRemoteEntry(options) {
621
621
  return item[1];
622
622
  }).join('\n') + "\n import exposesMap from \"" + VIRTUAL_EXPOSES + "\"\n import {usedShared, usedRemotes} from \"" + getLocalSharedImportMapPath() + "\"\n import {\n initResolve\n } from \"" + virtualRuntimeInitStatus.getImportId() + "\"\n async function init(shared = {}) {\n const initRes = runtimeInit({\n name: " + JSON.stringify(options.name) + ",\n remotes: usedRemotes,\n shared: usedShared,\n plugins: [" + pluginImportNames.map(function (item) {
623
623
  return item[0] + "()";
624
- }).join(', ') + "],\n " + (options.shareStrategy ? "shareStrategy: " + options.shareStrategy : '') + "\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n initResolve(initRes)\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
624
+ }).join(', ') + "],\n " + (options.shareStrategy ? "shareStrategy: '" + options.shareStrategy + "'" : '') + "\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n try {\n await Promise.all(await initRes.initializeSharing('" + options.shareScope + "', {strategy: '" + options.shareStrategy + "'}));\n } catch (e) {\n console.error(e)\n }\n initResolve(initRes)\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
625
625
  }
626
626
  /**
627
627
  * Inject entry file, automatically init when used as host,
package/lib/index.esm.js CHANGED
@@ -360,7 +360,7 @@ function normalizeModuleFederationOptions(options) {
360
360
  dev: options.dev,
361
361
  dts: options.dts,
362
362
  getPublicPath: options.getPublicPath,
363
- shareStrategy: options.shareStrategy
363
+ shareStrategy: options.shareStrategy || 'version-first'
364
364
  };
365
365
  }
366
366
 
@@ -598,7 +598,7 @@ function generateRemoteEntry(options) {
598
598
  return item[1];
599
599
  }).join('\n') + "\n import exposesMap from \"" + VIRTUAL_EXPOSES + "\"\n import {usedShared, usedRemotes} from \"" + getLocalSharedImportMapPath() + "\"\n import {\n initResolve\n } from \"" + virtualRuntimeInitStatus.getImportId() + "\"\n async function init(shared = {}) {\n const initRes = runtimeInit({\n name: " + JSON.stringify(options.name) + ",\n remotes: usedRemotes,\n shared: usedShared,\n plugins: [" + pluginImportNames.map(function (item) {
600
600
  return item[0] + "()";
601
- }).join(', ') + "],\n " + (options.shareStrategy ? "shareStrategy: " + options.shareStrategy : '') + "\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n initResolve(initRes)\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
601
+ }).join(', ') + "],\n " + (options.shareStrategy ? "shareStrategy: '" + options.shareStrategy + "'" : '') + "\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n try {\n await Promise.all(await initRes.initializeSharing('" + options.shareScope + "', {strategy: '" + options.shareStrategy + "'}));\n } catch (e) {\n console.error(e)\n }\n initResolve(initRes)\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
602
602
  }
603
603
  /**
604
604
  * Inject entry file, automatically init when used as host,
@@ -333,7 +333,7 @@ function normalizeModuleFederationOptions(options) {
333
333
  dev: options.dev,
334
334
  dts: options.dts,
335
335
  getPublicPath: options.getPublicPath,
336
- shareStrategy: options.shareStrategy
336
+ shareStrategy: options.shareStrategy || 'version-first'
337
337
  };
338
338
  }
339
339
 
@@ -663,9 +663,14 @@ function generateRemoteEntry(options) {
663
663
  remotes: usedRemotes,
664
664
  shared: usedShared,
665
665
  plugins: [${pluginImportNames.map(item => `${item[0]}()`).join(', ')}],
666
- ${options.shareStrategy ? `shareStrategy: ${options.shareStrategy}` : ''}
666
+ ${options.shareStrategy ? `shareStrategy: '${options.shareStrategy}'` : ''}
667
667
  });
668
668
  initRes.initShareScopeMap('${options.shareScope}', shared);
669
+ try {
670
+ await Promise.all(await initRes.initializeSharing('${options.shareScope}', {strategy: '${options.shareStrategy}'}));
671
+ } catch (e) {
672
+ console.error(e)
673
+ }
669
674
  initResolve(initRes)
670
675
  return initRes
671
676
  }
package/lib/index.umd.js CHANGED
@@ -381,7 +381,7 @@
381
381
  dev: options.dev,
382
382
  dts: options.dts,
383
383
  getPublicPath: options.getPublicPath,
384
- shareStrategy: options.shareStrategy
384
+ shareStrategy: options.shareStrategy || 'version-first'
385
385
  };
386
386
  }
387
387
 
@@ -619,7 +619,7 @@
619
619
  return item[1];
620
620
  }).join('\n') + "\n import exposesMap from \"" + VIRTUAL_EXPOSES + "\"\n import {usedShared, usedRemotes} from \"" + getLocalSharedImportMapPath() + "\"\n import {\n initResolve\n } from \"" + virtualRuntimeInitStatus.getImportId() + "\"\n async function init(shared = {}) {\n const initRes = runtimeInit({\n name: " + JSON.stringify(options.name) + ",\n remotes: usedRemotes,\n shared: usedShared,\n plugins: [" + pluginImportNames.map(function (item) {
621
621
  return item[0] + "()";
622
- }).join(', ') + "],\n " + (options.shareStrategy ? "shareStrategy: " + options.shareStrategy : '') + "\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n initResolve(initRes)\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
622
+ }).join(', ') + "],\n " + (options.shareStrategy ? "shareStrategy: '" + options.shareStrategy + "'" : '') + "\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n try {\n await Promise.all(await initRes.initializeSharing('" + options.shareScope + "', {strategy: '" + options.shareStrategy + "'}));\n } catch (e) {\n console.error(e)\n }\n initResolve(initRes)\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
623
623
  }
624
624
  /**
625
625
  * Inject entry file, automatically init when used as host,
@@ -66,7 +66,7 @@ export interface NormalizedModuleFederationOptions {
66
66
  manifest: ManifestOptions | boolean;
67
67
  dev?: boolean | PluginDevOptions;
68
68
  dts?: boolean | PluginDtsOptions;
69
- shareStrategy?: ShareStrategy;
69
+ shareStrategy: ShareStrategy;
70
70
  getPublicPath?: string;
71
71
  }
72
72
  interface PluginDevOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/vite",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "source": "src/index.ts",
@@ -9,22 +9,6 @@
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
- },
28
12
  "repository": {
29
13
  "type": "git",
30
14
  "url": "git+https://github.com/module-federation/vite.git"
@@ -44,7 +28,6 @@
44
28
  "url": "https://github.com/module-federation/vite/issues"
45
29
  },
46
30
  "homepage": "https://github.com/module-federation/vite#readme",
47
- "packageManager": "pnpm@9.1.3",
48
31
  "dependencies": {
49
32
  "@module-federation/runtime": "^0.6.8",
50
33
  "@rollup/pluginutils": "^5.1.0",
@@ -65,5 +48,20 @@
65
48
  "rimraf": "^6.0.1",
66
49
  "vite": "^5.4.3",
67
50
  "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"
68
66
  }
69
- }
67
+ }