@module-federation/vite 1.15.3 → 1.15.5

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 CHANGED
@@ -19,11 +19,13 @@ Examples live in [`gioboa/module-federation-vite-examples`](https://github.com/g
19
19
  | [Angular](https://github.com/gioboa/module-federation-vite-examples/tree/main/angular) | `angular-host` | `angular-remote` | Angular |
20
20
  | [Lit](https://github.com/gioboa/module-federation-vite-examples/tree/main/lit) | `lit-host` | `lit-remote` | Lit |
21
21
  | [Nuxt](https://github.com/gioboa/module-federation-vite-examples/tree/main/nuxt) | `nuxt-host` | `nuxt-remote` | Nuxt 4 |
22
+ | [Nx](https://github.com/gioboa/react-nx-microfrontend-demo) | `host` | `remote` | React + Nx |
22
23
  | [Preact](https://github.com/gioboa/module-federation-vite-examples/tree/main/preact) | `preact-host` | `preact-remote` | Preact 10 |
23
24
  | [React](https://github.com/gioboa/module-federation-vite-examples/tree/main/react) | `react-host` | `react-remote` | React 19 |
24
25
  | [Solid](https://github.com/gioboa/module-federation-vite-examples/tree/main/solid) | `solid-host` | `solid-remote` | Solid |
25
26
  | [Svelte](https://github.com/gioboa/module-federation-vite-examples/tree/main/svelte) | `svelte-host` | `svelte-remote` | Svelte 5 |
26
27
  | [TanStack](https://github.com/gioboa/module-federation-vite-examples/tree/main/tanstack) | `tanstack-host` | `tanstack-remote` | TanStack Router + React 19 |
28
+ | [Turborepo](https://github.com/gioboa/react-turborepo-microfrontend-demo) | `host` | `remote` | React + Turborepo |
27
29
  | [Vinext](https://github.com/gioboa/module-federation-vite-examples/tree/main/vinext) | `vinext-host` | `vinext-remote` | Vinext + Next 16 + React 19 |
28
30
  | [Vue](https://github.com/gioboa/module-federation-vite-examples/tree/main/vue) | `vue-host` | `vue-remote` | Vue 3 |
29
31
 
@@ -45,7 +47,7 @@ pnpm run multi-example
45
47
 
46
48
  ## Getting started 🚀
47
49
 
48
- https://module-federation.io/guide/basic/webpack.html
50
+ [https://module-federation.io/guide/build-plugins/plugins-vite.html](https://module-federation.io/guide/build-plugins/plugins-vite.html)
49
51
 
50
52
  With **@module-federation/vite**, the process becomes delightfully simple, you will only find the differences from a normal Vite configuration.
51
53
 
package/lib/index.cjs CHANGED
@@ -1168,10 +1168,14 @@ function writePreBuildLibPath(pkg, shareItem) {
1168
1168
  }
1169
1169
  const namedExports = getPackageNamedExports(pkg);
1170
1170
  if (namedExports.length > 0) {
1171
+ const namedExportVars = namedExports.map((_name, i) => `__mf_${i}`);
1172
+ const declarations = namedExports.map((name, i) => `const ${namedExportVars[i]} = __mfPrebuildExports[${escapeGeneratedStringLiteral(name)}];`).join("\n ");
1173
+ const namedExportLine = `export { ${namedExports.map((name, i) => `${namedExportVars[i]} as ${name}`).join(", ")} };`;
1171
1174
  preBuildCacheMap[pkg].writeSync(`
1172
1175
  import * as __mfPrebuildNamespace from ${escapeGeneratedStringLiteral(importSource)};
1173
1176
  const __mfPrebuildExports = __mfPrebuildNamespace;
1174
- ${namedExports.map((name) => `export const ${name} = __mfPrebuildExports[${escapeGeneratedStringLiteral(name)}];`).join("\n ")}
1177
+ ${declarations}
1178
+ ${namedExportLine}
1175
1179
  export default __mfPrebuildExports;
1176
1180
  `, true);
1177
1181
  return;
@@ -4505,7 +4509,10 @@ export default __mfShared.default ?? __mfShared;`
4505
4509
  if (isLitShare(key)) optimizeDeps.exclude.push(key);
4506
4510
  else optimizeDeps.include.push(key);
4507
4511
  for (const subpath of getCommonSharedSubpaths(key)) {
4512
+ getLoadShareModulePath(subpath, isRolldown);
4513
+ writeLoadShareModule(subpath, shareItem, _command, isRolldown);
4508
4514
  writePreBuildLibPath(subpath, shareItem);
4515
+ addUsedShares(subpath);
4509
4516
  optimizeDeps.include.push(subpath);
4510
4517
  }
4511
4518
  }
package/lib/index.mjs CHANGED
@@ -1148,10 +1148,14 @@ function writePreBuildLibPath(pkg, shareItem) {
1148
1148
  }
1149
1149
  const namedExports = getPackageNamedExports(pkg);
1150
1150
  if (namedExports.length > 0) {
1151
+ const namedExportVars = namedExports.map((_name, i) => `__mf_${i}`);
1152
+ const declarations = namedExports.map((name, i) => `const ${namedExportVars[i]} = __mfPrebuildExports[${escapeGeneratedStringLiteral(name)}];`).join("\n ");
1153
+ const namedExportLine = `export { ${namedExports.map((name, i) => `${namedExportVars[i]} as ${name}`).join(", ")} };`;
1151
1154
  preBuildCacheMap[pkg].writeSync(`
1152
1155
  import * as __mfPrebuildNamespace from ${escapeGeneratedStringLiteral(importSource)};
1153
1156
  const __mfPrebuildExports = __mfPrebuildNamespace;
1154
- ${namedExports.map((name) => `export const ${name} = __mfPrebuildExports[${escapeGeneratedStringLiteral(name)}];`).join("\n ")}
1157
+ ${declarations}
1158
+ ${namedExportLine}
1155
1159
  export default __mfPrebuildExports;
1156
1160
  `, true);
1157
1161
  return;
@@ -4485,7 +4489,10 @@ export default __mfShared.default ?? __mfShared;`
4485
4489
  if (isLitShare(key)) optimizeDeps.exclude.push(key);
4486
4490
  else optimizeDeps.include.push(key);
4487
4491
  for (const subpath of getCommonSharedSubpaths(key)) {
4492
+ getLoadShareModulePath(subpath, isRolldown);
4493
+ writeLoadShareModule(subpath, shareItem, _command, isRolldown);
4488
4494
  writePreBuildLibPath(subpath, shareItem);
4495
+ addUsedShares(subpath);
4489
4496
  optimizeDeps.include.push(subpath);
4490
4497
  }
4491
4498
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/vite",
3
- "version": "1.15.3",
3
+ "version": "1.15.5",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "main": "./lib/index.cjs",