@module-federation/vite 1.1.0 → 1.1.1

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
@@ -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
@@ -1249,13 +1257,15 @@ function federation(mfUserOptions) {
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;
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');
1259
1269
  }
1260
1270
  }], Manifest());
1261
1271
  }
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
@@ -1226,13 +1234,15 @@ function federation(mfUserOptions) {
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;
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');
1236
1246
  }
1237
1247
  }], Manifest());
1238
1248
  }
@@ -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
@@ -1272,13 +1280,15 @@ 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;
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');
1282
1292
  }
1283
1293
  }, ...Manifest()];
1284
1294
  }
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
@@ -1247,13 +1255,15 @@
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;
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');
1257
1267
  }
1258
1268
  }], Manifest());
1259
1269
  }
@@ -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.1",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "source": "src/index.ts",