@module-federation/vite 1.1.0 → 1.1.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.
package/README.md CHANGED
@@ -15,6 +15,10 @@ This plugin makes Module Federation work together with [Vite](https://vitejs.dev
15
15
 
16
16
  ### [React](https://github.com/gioboa/react-microfrontend-demo)<br>
17
17
 
18
+ ### [Svelte](https://github.com/gioboa/svelte-microfrontend-demo)<br>
19
+
20
+ ### [SolidJS](https://github.com/gioboa/solid-microfrontend-demo)<br>
21
+
18
22
  ### [More examples here](https://github.com/module-federation/vite/tree/main/examples)<br>
19
23
 
20
24
  ## Try this crazy example with all these bundlers together
package/lib/index.cjs CHANGED
@@ -364,8 +364,8 @@ function getNormalizeShareItem(key) {
364
364
  return shareItem;
365
365
  }
366
366
  function normalizeModuleFederationOptions(options) {
367
- if (options.getPublicPath || options.publicPath) {
368
- warn("We are ignoring the getPublicPath and publicPath options because they are natively supported by Vite\nwith the \"experimental.renderBuiltUrl\" configuration https://vitejs.dev/guide/build#advanced-base-options");
367
+ if (options.getPublicPath) {
368
+ warn("We are ignoring the getPublicPath options because they are natively supported by Vite\nwith the \"experimental.renderBuiltUrl\" configuration https://vitejs.dev/guide/build#advanced-base-options");
369
369
  }
370
370
  return config = {
371
371
  exposes: normalizeExposes(options.exposes),
@@ -382,6 +382,7 @@ function normalizeModuleFederationOptions(options) {
382
382
  manifest: normalizeManifest(options.manifest),
383
383
  dev: options.dev,
384
384
  dts: options.dts,
385
+ getPublicPath: options.getPublicPath,
385
386
  shareStrategy: options.shareStrategy
386
387
  };
387
388
  }
@@ -521,7 +522,7 @@ function generateExposes() {
521
522
 
522
523
  var virtualRuntimeInitStatus = new VirtualModule('runtimeInit');
523
524
  function writeRuntimeInitStatus() {
524
- virtualRuntimeInitStatus.writeSync("\n let initResolve, initReject\n const initPromise = new Promise((re, rj) => {\n initResolve = re\n initReject = rj\n })\n export {\n initPromise,\n initResolve,\n initReject\n }\n ");
525
+ virtualRuntimeInitStatus.writeSync("\n let initResolve, initReject\n const initPromise = new Promise((re, rj) => {\n initResolve = re\n initReject = rj\n })\n module.exports = {\n initPromise,\n initResolve,\n initReject\n }\n ");
525
526
  }
526
527
 
527
528
  var cacheRemoteMap = {};
@@ -647,6 +648,7 @@ var Manifest = function Manifest() {
647
648
  var mfOptions = getNormalizeModuleFederationOptions();
648
649
  var name = mfOptions.name,
649
650
  filename = mfOptions.filename,
651
+ getPublicPath = mfOptions.getPublicPath,
650
652
  manifestOptions = mfOptions.manifest;
651
653
  var mfManifestName = '';
652
654
  if (manifestOptions === true) {
@@ -658,6 +660,7 @@ var Manifest = function Manifest() {
658
660
  var extensions;
659
661
  var root;
660
662
  var remoteEntryFile;
663
+ var publicPath;
661
664
  var _command;
662
665
  return [{
663
666
  name: 'module-federation-manifest',
@@ -696,7 +699,8 @@ var Manifest = function Manifest() {
696
699
  name: ''
697
700
  },
698
701
  globalName: name,
699
- pluginVersion: '0.2.5'
702
+ pluginVersion: '0.2.5',
703
+ publicPath: publicPath
700
704
  }
701
705
  })));
702
706
  } else {
@@ -716,10 +720,10 @@ var Manifest = function Manifest() {
716
720
  configResolved: function configResolved(config) {
717
721
  root = config.root;
718
722
  extensions = config.resolve.extensions || ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'];
719
- config.base ? config.base.replace(/\/?$/, '/') : 'auto';
723
+ publicPath = config.base ? config.base.replace(/\/?$/, '/') : 'auto';
720
724
  if (_command === 'serve') {
721
725
  var origin = config.server.origin;
722
- origin ? origin.replace(/\/?$/, '/') : 'auto';
726
+ publicPath = origin ? origin.replace(/\/?$/, '/') : 'auto';
723
727
  }
724
728
  },
725
729
  generateBundle: function generateBundle(options, bundle) {
@@ -914,7 +918,7 @@ var Manifest = function Manifest() {
914
918
  var result = {
915
919
  id: name,
916
920
  name: name,
917
- metaData: {
921
+ metaData: _extends({
918
922
  name: name,
919
923
  type: 'app',
920
924
  buildInfo: {
@@ -931,7 +935,11 @@ var Manifest = function Manifest() {
931
935
  },
932
936
  globalName: name,
933
937
  pluginVersion: '0.2.5'
934
- },
938
+ }, !!getPublicPath ? {
939
+ getPublicPath: getPublicPath
940
+ } : {
941
+ publicPath: publicPath
942
+ }),
935
943
  shared: shared,
936
944
  remotes: remotes,
937
945
  exposes: exposes
@@ -972,13 +980,13 @@ function pluginModuleParseEnd (excludeFn) {
972
980
  apply: 'build',
973
981
  moduleParsed: function moduleParsed(module) {
974
982
  var id = module.id;
975
- if (excludeFn(id)) {
976
- return;
977
- }
978
983
  if (id === VIRTUAL_EXPOSES) {
979
984
  // When the entry JS file is empty and only contains exposes export code, it’s necessary to wait for the exposes modules to be resolved in order to collect the dependencies being used.
980
985
  exposesParseEnd = true;
981
986
  }
987
+ if (excludeFn(id)) {
988
+ return;
989
+ }
982
990
  parseEndSet.add(id);
983
991
  if (exposesParseEnd && parseStartSet.size === parseEndSet.size) {
984
992
  _resolve(1);
@@ -1242,20 +1250,23 @@ function federation(mfUserOptions) {
1242
1250
  entryName: 'virtualExposes',
1243
1251
  entryPath: VIRTUAL_EXPOSES
1244
1252
  }), [pluginProxyRemoteEntry(), pluginProxyRemotes(options)], pluginModuleParseEnd(function (id) {
1245
- return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
1253
+ return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(VIRTUAL_EXPOSES) || id.includes(getLocalSharedImportMapPath());
1246
1254
  }), proxySharedModule({
1247
1255
  shared: shared
1248
1256
  }), [PluginDevProxyModuleTopLevelAwait(), {
1249
1257
  name: 'module-federation-vite',
1250
1258
  enforce: 'post',
1251
1259
  config: function config(_config, _ref) {
1252
- var _config$optimizeDeps;
1260
+ var _config$optimizeDeps, _config$optimizeDeps2, _config$optimizeDeps3, _config$optimizeDeps4;
1253
1261
  // TODO: singleton
1254
1262
  _config.resolve.alias.push({
1255
1263
  find: '@module-federation/runtime',
1256
1264
  replacement: require.resolve('@module-federation/runtime')
1257
1265
  });
1258
1266
  (_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
1267
+ (_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
1268
+ (_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
1269
+ (_config$optimizeDeps4 = _config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
1259
1270
  }
1260
1271
  }], Manifest());
1261
1272
  }
package/lib/index.esm.js CHANGED
@@ -341,8 +341,8 @@ function getNormalizeShareItem(key) {
341
341
  return shareItem;
342
342
  }
343
343
  function normalizeModuleFederationOptions(options) {
344
- if (options.getPublicPath || options.publicPath) {
345
- warn("We are ignoring the getPublicPath and publicPath options because they are natively supported by Vite\nwith the \"experimental.renderBuiltUrl\" configuration https://vitejs.dev/guide/build#advanced-base-options");
344
+ if (options.getPublicPath) {
345
+ warn("We are ignoring the getPublicPath options because they are natively supported by Vite\nwith the \"experimental.renderBuiltUrl\" configuration https://vitejs.dev/guide/build#advanced-base-options");
346
346
  }
347
347
  return config = {
348
348
  exposes: normalizeExposes(options.exposes),
@@ -359,6 +359,7 @@ function normalizeModuleFederationOptions(options) {
359
359
  manifest: normalizeManifest(options.manifest),
360
360
  dev: options.dev,
361
361
  dts: options.dts,
362
+ getPublicPath: options.getPublicPath,
362
363
  shareStrategy: options.shareStrategy
363
364
  };
364
365
  }
@@ -498,7 +499,7 @@ function generateExposes() {
498
499
 
499
500
  var virtualRuntimeInitStatus = new VirtualModule('runtimeInit');
500
501
  function writeRuntimeInitStatus() {
501
- virtualRuntimeInitStatus.writeSync("\n let initResolve, initReject\n const initPromise = new Promise((re, rj) => {\n initResolve = re\n initReject = rj\n })\n export {\n initPromise,\n initResolve,\n initReject\n }\n ");
502
+ virtualRuntimeInitStatus.writeSync("\n let initResolve, initReject\n const initPromise = new Promise((re, rj) => {\n initResolve = re\n initReject = rj\n })\n module.exports = {\n initPromise,\n initResolve,\n initReject\n }\n ");
502
503
  }
503
504
 
504
505
  var cacheRemoteMap = {};
@@ -624,6 +625,7 @@ var Manifest = function Manifest() {
624
625
  var mfOptions = getNormalizeModuleFederationOptions();
625
626
  var name = mfOptions.name,
626
627
  filename = mfOptions.filename,
628
+ getPublicPath = mfOptions.getPublicPath,
627
629
  manifestOptions = mfOptions.manifest;
628
630
  var mfManifestName = '';
629
631
  if (manifestOptions === true) {
@@ -635,6 +637,7 @@ var Manifest = function Manifest() {
635
637
  var extensions;
636
638
  var root;
637
639
  var remoteEntryFile;
640
+ var publicPath;
638
641
  var _command;
639
642
  return [{
640
643
  name: 'module-federation-manifest',
@@ -673,7 +676,8 @@ var Manifest = function Manifest() {
673
676
  name: ''
674
677
  },
675
678
  globalName: name,
676
- pluginVersion: '0.2.5'
679
+ pluginVersion: '0.2.5',
680
+ publicPath: publicPath
677
681
  }
678
682
  })));
679
683
  } else {
@@ -693,10 +697,10 @@ var Manifest = function Manifest() {
693
697
  configResolved: function configResolved(config) {
694
698
  root = config.root;
695
699
  extensions = config.resolve.extensions || ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'];
696
- config.base ? config.base.replace(/\/?$/, '/') : 'auto';
700
+ publicPath = config.base ? config.base.replace(/\/?$/, '/') : 'auto';
697
701
  if (_command === 'serve') {
698
702
  var origin = config.server.origin;
699
- origin ? origin.replace(/\/?$/, '/') : 'auto';
703
+ publicPath = origin ? origin.replace(/\/?$/, '/') : 'auto';
700
704
  }
701
705
  },
702
706
  generateBundle: function generateBundle(options, bundle) {
@@ -891,7 +895,7 @@ var Manifest = function Manifest() {
891
895
  var result = {
892
896
  id: name,
893
897
  name: name,
894
- metaData: {
898
+ metaData: _extends({
895
899
  name: name,
896
900
  type: 'app',
897
901
  buildInfo: {
@@ -908,7 +912,11 @@ var Manifest = function Manifest() {
908
912
  },
909
913
  globalName: name,
910
914
  pluginVersion: '0.2.5'
911
- },
915
+ }, !!getPublicPath ? {
916
+ getPublicPath: getPublicPath
917
+ } : {
918
+ publicPath: publicPath
919
+ }),
912
920
  shared: shared,
913
921
  remotes: remotes,
914
922
  exposes: exposes
@@ -949,13 +957,13 @@ function pluginModuleParseEnd (excludeFn) {
949
957
  apply: 'build',
950
958
  moduleParsed: function moduleParsed(module) {
951
959
  var id = module.id;
952
- if (excludeFn(id)) {
953
- return;
954
- }
955
960
  if (id === VIRTUAL_EXPOSES) {
956
961
  // When the entry JS file is empty and only contains exposes export code, it’s necessary to wait for the exposes modules to be resolved in order to collect the dependencies being used.
957
962
  exposesParseEnd = true;
958
963
  }
964
+ if (excludeFn(id)) {
965
+ return;
966
+ }
959
967
  parseEndSet.add(id);
960
968
  if (exposesParseEnd && parseStartSet.size === parseEndSet.size) {
961
969
  _resolve(1);
@@ -1219,20 +1227,23 @@ function federation(mfUserOptions) {
1219
1227
  entryName: 'virtualExposes',
1220
1228
  entryPath: VIRTUAL_EXPOSES
1221
1229
  }), [pluginProxyRemoteEntry(), pluginProxyRemotes(options)], pluginModuleParseEnd(function (id) {
1222
- return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
1230
+ return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(VIRTUAL_EXPOSES) || id.includes(getLocalSharedImportMapPath());
1223
1231
  }), proxySharedModule({
1224
1232
  shared: shared
1225
1233
  }), [PluginDevProxyModuleTopLevelAwait(), {
1226
1234
  name: 'module-federation-vite',
1227
1235
  enforce: 'post',
1228
1236
  config: function config(_config, _ref) {
1229
- var _config$optimizeDeps;
1237
+ var _config$optimizeDeps, _config$optimizeDeps2, _config$optimizeDeps3, _config$optimizeDeps4;
1230
1238
  // TODO: singleton
1231
1239
  _config.resolve.alias.push({
1232
1240
  find: '@module-federation/runtime',
1233
1241
  replacement: require.resolve('@module-federation/runtime')
1234
1242
  });
1235
1243
  (_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
1244
+ (_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
1245
+ (_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
1246
+ (_config$optimizeDeps4 = _config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
1236
1247
  }
1237
1248
  }], Manifest());
1238
1249
  }
@@ -314,8 +314,8 @@ function getNormalizeShareItem(key) {
314
314
  return shareItem;
315
315
  }
316
316
  function normalizeModuleFederationOptions(options) {
317
- if (options.getPublicPath || options.publicPath) {
318
- warn(`We are ignoring the getPublicPath and publicPath options because they are natively supported by Vite\nwith the "experimental.renderBuiltUrl" configuration https://vitejs.dev/guide/build#advanced-base-options`);
317
+ if (options.getPublicPath) {
318
+ warn(`We are ignoring the getPublicPath options because they are natively supported by Vite\nwith the "experimental.renderBuiltUrl" configuration https://vitejs.dev/guide/build#advanced-base-options`);
319
319
  }
320
320
  return config = {
321
321
  exposes: normalizeExposes(options.exposes),
@@ -332,6 +332,7 @@ function normalizeModuleFederationOptions(options) {
332
332
  manifest: normalizeManifest(options.manifest),
333
333
  dev: options.dev,
334
334
  dts: options.dts,
335
+ getPublicPath: options.getPublicPath,
335
336
  shareStrategy: options.shareStrategy
336
337
  };
337
338
  }
@@ -480,7 +481,7 @@ function writeRuntimeInitStatus() {
480
481
  initResolve = re
481
482
  initReject = rj
482
483
  })
483
- export {
484
+ module.exports = {
484
485
  initPromise,
485
486
  initResolve,
486
487
  initReject
@@ -708,6 +709,7 @@ const Manifest = () => {
708
709
  const {
709
710
  name,
710
711
  filename,
712
+ getPublicPath,
711
713
  manifest: manifestOptions
712
714
  } = mfOptions;
713
715
  let mfManifestName = '';
@@ -720,6 +722,7 @@ const Manifest = () => {
720
722
  let extensions;
721
723
  let root;
722
724
  let remoteEntryFile;
725
+ let publicPath;
723
726
  let _command;
724
727
  return [{
725
728
  name: 'module-federation-manifest',
@@ -758,7 +761,8 @@ const Manifest = () => {
758
761
  name: ''
759
762
  },
760
763
  globalName: name,
761
- pluginVersion: '0.2.5'
764
+ pluginVersion: '0.2.5',
765
+ publicPath
762
766
  }
763
767
  })));
764
768
  } else {
@@ -779,10 +783,10 @@ const Manifest = () => {
779
783
  configResolved(config) {
780
784
  root = config.root;
781
785
  extensions = config.resolve.extensions || ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'];
782
- config.base ? config.base.replace(/\/?$/, '/') : 'auto';
786
+ publicPath = config.base ? config.base.replace(/\/?$/, '/') : 'auto';
783
787
  if (_command === 'serve') {
784
788
  const origin = config.server.origin;
785
- origin ? origin.replace(/\/?$/, '/') : 'auto';
789
+ publicPath = origin ? origin.replace(/\/?$/, '/') : 'auto';
786
790
  }
787
791
  },
788
792
  async generateBundle(options, bundle) {
@@ -949,7 +953,7 @@ const Manifest = () => {
949
953
  const result = {
950
954
  id: name,
951
955
  name: name,
952
- metaData: {
956
+ metaData: _extends({
953
957
  name: name,
954
958
  type: 'app',
955
959
  buildInfo: {
@@ -966,7 +970,11 @@ const Manifest = () => {
966
970
  },
967
971
  globalName: name,
968
972
  pluginVersion: '0.2.5'
969
- },
973
+ }, !!getPublicPath ? {
974
+ getPublicPath
975
+ } : {
976
+ publicPath
977
+ }),
970
978
  shared,
971
979
  remotes,
972
980
  exposes
@@ -1007,13 +1015,13 @@ function pluginModuleParseEnd (excludeFn) {
1007
1015
  apply: 'build',
1008
1016
  moduleParsed(module) {
1009
1017
  const id = module.id;
1010
- if (excludeFn(id)) {
1011
- return;
1012
- }
1013
1018
  if (id === VIRTUAL_EXPOSES) {
1014
1019
  // When the entry JS file is empty and only contains exposes export code, it’s necessary to wait for the exposes modules to be resolved in order to collect the dependencies being used.
1015
1020
  exposesParseEnd = true;
1016
1021
  }
1022
+ if (excludeFn(id)) {
1023
+ return;
1024
+ }
1017
1025
  parseEndSet.add(id);
1018
1026
  if (exposesParseEnd && parseStartSet.size === parseEndSet.size) {
1019
1027
  _resolve(1);
@@ -1263,7 +1271,7 @@ function federation(mfUserOptions) {
1263
1271
  entryName: 'virtualExposes',
1264
1272
  entryPath: VIRTUAL_EXPOSES
1265
1273
  }), pluginProxyRemoteEntry(), pluginProxyRemotes(options), ...pluginModuleParseEnd(id => {
1266
- return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
1274
+ return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(VIRTUAL_EXPOSES) || id.includes(getLocalSharedImportMapPath());
1267
1275
  }), ...proxySharedModule({
1268
1276
  shared
1269
1277
  }), PluginDevProxyModuleTopLevelAwait(), {
@@ -1272,13 +1280,16 @@ function federation(mfUserOptions) {
1272
1280
  config(config, {
1273
1281
  command: _command
1274
1282
  }) {
1275
- var _config$optimizeDeps;
1283
+ var _config$optimizeDeps, _config$optimizeDeps2, _config$optimizeDeps3, _config$optimizeDeps4;
1276
1284
  // TODO: singleton
1277
1285
  config.resolve.alias.push({
1278
1286
  find: '@module-federation/runtime',
1279
1287
  replacement: require.resolve('@module-federation/runtime')
1280
1288
  });
1281
1289
  (_config$optimizeDeps = config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
1290
+ (_config$optimizeDeps2 = config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
1291
+ (_config$optimizeDeps3 = config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
1292
+ (_config$optimizeDeps4 = config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
1282
1293
  }
1283
1294
  }, ...Manifest()];
1284
1295
  }
package/lib/index.umd.js CHANGED
@@ -362,8 +362,8 @@
362
362
  return shareItem;
363
363
  }
364
364
  function normalizeModuleFederationOptions(options) {
365
- if (options.getPublicPath || options.publicPath) {
366
- warn("We are ignoring the getPublicPath and publicPath options because they are natively supported by Vite\nwith the \"experimental.renderBuiltUrl\" configuration https://vitejs.dev/guide/build#advanced-base-options");
365
+ if (options.getPublicPath) {
366
+ warn("We are ignoring the getPublicPath options because they are natively supported by Vite\nwith the \"experimental.renderBuiltUrl\" configuration https://vitejs.dev/guide/build#advanced-base-options");
367
367
  }
368
368
  return config = {
369
369
  exposes: normalizeExposes(options.exposes),
@@ -380,6 +380,7 @@
380
380
  manifest: normalizeManifest(options.manifest),
381
381
  dev: options.dev,
382
382
  dts: options.dts,
383
+ getPublicPath: options.getPublicPath,
383
384
  shareStrategy: options.shareStrategy
384
385
  };
385
386
  }
@@ -519,7 +520,7 @@
519
520
 
520
521
  var virtualRuntimeInitStatus = new VirtualModule('runtimeInit');
521
522
  function writeRuntimeInitStatus() {
522
- virtualRuntimeInitStatus.writeSync("\n let initResolve, initReject\n const initPromise = new Promise((re, rj) => {\n initResolve = re\n initReject = rj\n })\n export {\n initPromise,\n initResolve,\n initReject\n }\n ");
523
+ virtualRuntimeInitStatus.writeSync("\n let initResolve, initReject\n const initPromise = new Promise((re, rj) => {\n initResolve = re\n initReject = rj\n })\n module.exports = {\n initPromise,\n initResolve,\n initReject\n }\n ");
523
524
  }
524
525
 
525
526
  var cacheRemoteMap = {};
@@ -645,6 +646,7 @@
645
646
  var mfOptions = getNormalizeModuleFederationOptions();
646
647
  var name = mfOptions.name,
647
648
  filename = mfOptions.filename,
649
+ getPublicPath = mfOptions.getPublicPath,
648
650
  manifestOptions = mfOptions.manifest;
649
651
  var mfManifestName = '';
650
652
  if (manifestOptions === true) {
@@ -656,6 +658,7 @@
656
658
  var extensions;
657
659
  var root;
658
660
  var remoteEntryFile;
661
+ var publicPath;
659
662
  var _command;
660
663
  return [{
661
664
  name: 'module-federation-manifest',
@@ -694,7 +697,8 @@
694
697
  name: ''
695
698
  },
696
699
  globalName: name,
697
- pluginVersion: '0.2.5'
700
+ pluginVersion: '0.2.5',
701
+ publicPath: publicPath
698
702
  }
699
703
  })));
700
704
  } else {
@@ -714,10 +718,10 @@
714
718
  configResolved: function configResolved(config) {
715
719
  root = config.root;
716
720
  extensions = config.resolve.extensions || ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'];
717
- config.base ? config.base.replace(/\/?$/, '/') : 'auto';
721
+ publicPath = config.base ? config.base.replace(/\/?$/, '/') : 'auto';
718
722
  if (_command === 'serve') {
719
723
  var origin = config.server.origin;
720
- origin ? origin.replace(/\/?$/, '/') : 'auto';
724
+ publicPath = origin ? origin.replace(/\/?$/, '/') : 'auto';
721
725
  }
722
726
  },
723
727
  generateBundle: function generateBundle(options, bundle) {
@@ -912,7 +916,7 @@
912
916
  var result = {
913
917
  id: name,
914
918
  name: name,
915
- metaData: {
919
+ metaData: _extends({
916
920
  name: name,
917
921
  type: 'app',
918
922
  buildInfo: {
@@ -929,7 +933,11 @@
929
933
  },
930
934
  globalName: name,
931
935
  pluginVersion: '0.2.5'
932
- },
936
+ }, !!getPublicPath ? {
937
+ getPublicPath: getPublicPath
938
+ } : {
939
+ publicPath: publicPath
940
+ }),
933
941
  shared: shared,
934
942
  remotes: remotes,
935
943
  exposes: exposes
@@ -970,13 +978,13 @@
970
978
  apply: 'build',
971
979
  moduleParsed: function moduleParsed(module) {
972
980
  var id = module.id;
973
- if (excludeFn(id)) {
974
- return;
975
- }
976
981
  if (id === VIRTUAL_EXPOSES) {
977
982
  // When the entry JS file is empty and only contains exposes export code, it’s necessary to wait for the exposes modules to be resolved in order to collect the dependencies being used.
978
983
  exposesParseEnd = true;
979
984
  }
985
+ if (excludeFn(id)) {
986
+ return;
987
+ }
980
988
  parseEndSet.add(id);
981
989
  if (exposesParseEnd && parseStartSet.size === parseEndSet.size) {
982
990
  _resolve(1);
@@ -1240,20 +1248,23 @@
1240
1248
  entryName: 'virtualExposes',
1241
1249
  entryPath: VIRTUAL_EXPOSES
1242
1250
  }), [pluginProxyRemoteEntry(), pluginProxyRemotes(options)], pluginModuleParseEnd(function (id) {
1243
- return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
1251
+ return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(VIRTUAL_EXPOSES) || id.includes(getLocalSharedImportMapPath());
1244
1252
  }), proxySharedModule({
1245
1253
  shared: shared
1246
1254
  }), [PluginDevProxyModuleTopLevelAwait(), {
1247
1255
  name: 'module-federation-vite',
1248
1256
  enforce: 'post',
1249
1257
  config: function config(_config, _ref) {
1250
- var _config$optimizeDeps;
1258
+ var _config$optimizeDeps, _config$optimizeDeps2, _config$optimizeDeps3, _config$optimizeDeps4;
1251
1259
  // TODO: singleton
1252
1260
  _config.resolve.alias.push({
1253
1261
  find: '@module-federation/runtime',
1254
1262
  replacement: require.resolve('@module-federation/runtime')
1255
1263
  });
1256
1264
  (_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
1265
+ (_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push('__mf__virtual');
1266
+ (_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push('__mf__virtual');
1267
+ (_config$optimizeDeps4 = _config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
1257
1268
  }
1258
1269
  }], Manifest());
1259
1270
  }
@@ -45,13 +45,12 @@ export type ModuleFederationOptions = {
45
45
  strictVersion?: boolean;
46
46
  }> | undefined;
47
47
  runtimePlugins?: string[];
48
- publicPath?: string;
49
48
  getPublicPath?: string;
50
49
  implementation?: any;
51
50
  manifest?: ManifestOptions | boolean;
52
51
  dev?: boolean | PluginDevOptions;
53
52
  dts?: boolean | PluginDtsOptions;
54
- shareStrategy: ShareStrategy;
53
+ shareStrategy?: ShareStrategy;
55
54
  };
56
55
  export interface NormalizedModuleFederationOptions {
57
56
  exposes: Record<string, ExposesItem>;
@@ -68,6 +67,7 @@ export interface NormalizedModuleFederationOptions {
68
67
  dev?: boolean | PluginDevOptions;
69
68
  dts?: boolean | PluginDtsOptions;
70
69
  shareStrategy?: ShareStrategy;
70
+ getPublicPath?: string;
71
71
  }
72
72
  interface PluginDevOptions {
73
73
  disableLiveReload?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/vite",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "source": "src/index.ts",
@@ -21,8 +21,9 @@
21
21
  "dev-vv": "pnpm -filter 'examples-vite-vite*' run dev",
22
22
  "dev-nv": "pnpm -filter 'examples-nuxt-vite-host' -filter 'examples-vite-vite-remote' run dev",
23
23
  "preview-vv": "pnpm -filter 'examples-vite-vite*' run preview",
24
- "multi-example": "pnpm --filter \"multi-example-*\" run start",
25
- "test": "vitest"
24
+ "multi-example": "pnpm --filter \"multi-example-*\" --parallel run start",
25
+ "test": "vitest",
26
+ "e2e": "playwright test"
26
27
  },
27
28
  "repository": {
28
29
  "type": "git",
@@ -50,16 +51,19 @@
50
51
  "defu": "^6.1.4",
51
52
  "estree-walker": "^2",
52
53
  "magic-string": "^0.30.11",
53
- "pathe": "^1.1.2",
54
- "vitest": "^2.1.1"
54
+ "vitest": "^2.1.1",
55
+ "pathe": "^1.1.2"
55
56
  },
56
57
  "devDependencies": {
58
+ "@playwright/test": "^1.47.2",
59
+ "@types/node": "^22.7.4",
57
60
  "husky": "^8.0.3",
58
61
  "microbundle": "^0.15.1",
59
62
  "mime-types": "^2.1.35",
60
63
  "prettier": "3.3.3",
61
64
  "pretty-quick": "^4.0.0",
62
65
  "rimraf": "^6.0.1",
63
- "vite": "^5.4.3"
66
+ "vite": "^5.4.3",
67
+ "wait-on": "^8.0.1"
64
68
  }
65
69
  }