@module-federation/vite 1.6.0 → 1.7.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
@@ -537,6 +537,14 @@ function getNodeModulesDir() {
537
537
  }
538
538
  return cachedNodeModulesDir;
539
539
  }
540
+ function getSuffix(name) {
541
+ var base = path.basename(name);
542
+ var dotIndex = base.lastIndexOf('.');
543
+ if (dotIndex > 0 && dotIndex < base.length - 1) {
544
+ return base.slice(dotIndex);
545
+ }
546
+ return '.js';
547
+ }
540
548
  var patternMap = {};
541
549
  var cacheMap = {};
542
550
  /**
@@ -544,7 +552,6 @@ var cacheMap = {};
544
552
  */
545
553
  var VirtualModule = /*#__PURE__*/function () {
546
554
  function VirtualModule(name, tag, suffix) {
547
- var _name$split$slice$pop;
548
555
  if (tag === void 0) {
549
556
  tag = '__mf_v__';
550
557
  }
@@ -557,7 +564,7 @@ var VirtualModule = /*#__PURE__*/function () {
557
564
  this.inited = false;
558
565
  this.name = name;
559
566
  this.tag = tag;
560
- this.suffix = suffix || ((_name$split$slice$pop = name.split('.').slice(1).pop()) == null ? void 0 : _name$split$slice$pop.replace(/(.)/, '.$1')) || '.js';
567
+ this.suffix = suffix || getSuffix(name);
561
568
  if (!cacheMap[this.tag]) cacheMap[this.tag] = {};
562
569
  cacheMap[this.tag][this.name] = this;
563
570
  }
package/lib/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import defu from 'defu';
2
2
  import * as fs from 'fs';
3
3
  import { mkdirSync, writeFileSync, existsSync, writeFile } from 'fs';
4
4
  import * as path from 'pathe';
5
- import path__default, { resolve, parse, join, dirname, relative } from 'pathe';
5
+ import path__default, { resolve, basename, parse, join, dirname, relative } from 'pathe';
6
6
  import { createFilter } from '@rollup/pluginutils';
7
7
  import { walk } from 'estree-walker';
8
8
  import MagicString from 'magic-string';
@@ -513,6 +513,14 @@ function getNodeModulesDir() {
513
513
  }
514
514
  return cachedNodeModulesDir;
515
515
  }
516
+ function getSuffix(name) {
517
+ var base = basename(name);
518
+ var dotIndex = base.lastIndexOf('.');
519
+ if (dotIndex > 0 && dotIndex < base.length - 1) {
520
+ return base.slice(dotIndex);
521
+ }
522
+ return '.js';
523
+ }
516
524
  var patternMap = {};
517
525
  var cacheMap = {};
518
526
  /**
@@ -520,7 +528,6 @@ var cacheMap = {};
520
528
  */
521
529
  var VirtualModule = /*#__PURE__*/function () {
522
530
  function VirtualModule(name, tag, suffix) {
523
- var _name$split$slice$pop;
524
531
  if (tag === void 0) {
525
532
  tag = '__mf_v__';
526
533
  }
@@ -533,7 +540,7 @@ var VirtualModule = /*#__PURE__*/function () {
533
540
  this.inited = false;
534
541
  this.name = name;
535
542
  this.tag = tag;
536
- this.suffix = suffix || ((_name$split$slice$pop = name.split('.').slice(1).pop()) == null ? void 0 : _name$split$slice$pop.replace(/(.)/, '.$1')) || '.js';
543
+ this.suffix = suffix || getSuffix(name);
537
544
  if (!cacheMap[this.tag]) cacheMap[this.tag] = {};
538
545
  cacheMap[this.tag][this.name] = this;
539
546
  }
@@ -2,7 +2,7 @@ import defu from 'defu';
2
2
  import * as fs from 'fs';
3
3
  import { mkdirSync, writeFileSync, existsSync, writeFile } from 'fs';
4
4
  import * as path from 'pathe';
5
- import path__default, { resolve, parse, join, dirname, relative } from 'pathe';
5
+ import path__default, { resolve, basename, parse, join, dirname, relative } from 'pathe';
6
6
  import { createFilter } from '@rollup/pluginutils';
7
7
  import { walk } from 'estree-walker';
8
8
  import MagicString from 'magic-string';
@@ -481,6 +481,14 @@ function getNodeModulesDir() {
481
481
  }
482
482
  return cachedNodeModulesDir;
483
483
  }
484
+ function getSuffix(name) {
485
+ const base = basename(name);
486
+ const dotIndex = base.lastIndexOf('.');
487
+ if (dotIndex > 0 && dotIndex < base.length - 1) {
488
+ return base.slice(dotIndex);
489
+ }
490
+ return '.js';
491
+ }
484
492
  const patternMap = {};
485
493
  const cacheMap = {};
486
494
  /**
@@ -521,14 +529,13 @@ class VirtualModule {
521
529
  return undefined;
522
530
  }
523
531
  constructor(name, tag = '__mf_v__', suffix = '') {
524
- var _name$split$slice$pop;
525
532
  this.name = void 0;
526
533
  this.tag = void 0;
527
534
  this.suffix = void 0;
528
535
  this.inited = false;
529
536
  this.name = name;
530
537
  this.tag = tag;
531
- this.suffix = suffix || ((_name$split$slice$pop = name.split('.').slice(1).pop()) == null ? void 0 : _name$split$slice$pop.replace(/(.)/, '.$1')) || '.js';
538
+ this.suffix = suffix || getSuffix(name);
532
539
  if (!cacheMap[this.tag]) cacheMap[this.tag] = {};
533
540
  cacheMap[this.tag][this.name] = this;
534
541
  }
package/lib/index.umd.js CHANGED
@@ -535,6 +535,14 @@
535
535
  }
536
536
  return cachedNodeModulesDir;
537
537
  }
538
+ function getSuffix(name) {
539
+ var base = path.basename(name);
540
+ var dotIndex = base.lastIndexOf('.');
541
+ if (dotIndex > 0 && dotIndex < base.length - 1) {
542
+ return base.slice(dotIndex);
543
+ }
544
+ return '.js';
545
+ }
538
546
  var patternMap = {};
539
547
  var cacheMap = {};
540
548
  /**
@@ -542,7 +550,6 @@
542
550
  */
543
551
  var VirtualModule = /*#__PURE__*/function () {
544
552
  function VirtualModule(name, tag, suffix) {
545
- var _name$split$slice$pop;
546
553
  if (tag === void 0) {
547
554
  tag = '__mf_v__';
548
555
  }
@@ -555,7 +562,7 @@
555
562
  this.inited = false;
556
563
  this.name = name;
557
564
  this.tag = tag;
558
- this.suffix = suffix || ((_name$split$slice$pop = name.split('.').slice(1).pop()) == null ? void 0 : _name$split$slice$pop.replace(/(.)/, '.$1')) || '.js';
565
+ this.suffix = suffix || getSuffix(name);
559
566
  if (!cacheMap[this.tag]) cacheMap[this.tag] = {};
560
567
  cacheMap[this.tag][this.name] = this;
561
568
  }
@@ -1,3 +1,4 @@
1
+ export declare function getSuffix(name: string): string;
1
2
  /**
2
3
  * Physically generate files as virtual modules under node_modules/__mf__virtual/*
3
4
  */
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/vite",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Vite plugin for Module Federation",
5
5
  "type": "module",
6
6
  "source": "src/index.ts",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "homepage": "https://github.com/module-federation/vite#readme",
31
31
  "dependencies": {
32
- "@module-federation/runtime": "^0.16.0",
32
+ "@module-federation/runtime": "^0.17.1",
33
33
  "@rollup/pluginutils": "^5.1.0",
34
34
  "defu": "^6.1.4",
35
35
  "estree-walker": "^2",