@module-federation/vite 1.4.0 → 1.5.0
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 +28 -12
- package/lib/index.esm.js +28 -12
- package/lib/index.modern.js +28 -11
- package/lib/index.umd.js +28 -12
- package/lib/utils/VirtualModule.d.ts +0 -1
- package/lib/utils/normalizeModuleFederationOptions.d.ts +2 -0
- package/package.json +17 -19
package/lib/index.cjs
CHANGED
|
@@ -357,10 +357,19 @@ function searchPackageVersion(sharedName) {
|
|
|
357
357
|
function normalizeShareItem(key, shareItem) {
|
|
358
358
|
var version;
|
|
359
359
|
try {
|
|
360
|
-
|
|
360
|
+
try {
|
|
361
|
+
version = require(path__namespace.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
362
|
+
} catch (e1) {
|
|
363
|
+
try {
|
|
364
|
+
var localPath = path__namespace.join(process.cwd(), 'node_modules', removePathFromNpmPackage(key), 'package.json');
|
|
365
|
+
version = require(localPath).version;
|
|
366
|
+
} catch (e2) {
|
|
367
|
+
version = searchPackageVersion(key);
|
|
368
|
+
if (!version) console.error(e1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
361
371
|
} catch (e) {
|
|
362
|
-
version
|
|
363
|
-
if (!version) console.error(e);
|
|
372
|
+
console.error("Unexpected error resolving version for " + key + ":", e);
|
|
364
373
|
}
|
|
365
374
|
if (typeof shareItem === 'string') {
|
|
366
375
|
return {
|
|
@@ -432,6 +441,9 @@ function normalizeModuleFederationOptions(options) {
|
|
|
432
441
|
if (options.getPublicPath) {
|
|
433
442
|
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");
|
|
434
443
|
}
|
|
444
|
+
if (options.virtualModuleDir && options.virtualModuleDir.includes('/')) {
|
|
445
|
+
throw new Error("Invalid virtualModuleDir: \"" + options.virtualModuleDir + "\". " + "The virtualModuleDir option cannot contain slashes (/). " + "Please use a single directory name like '__mf__virtual__your_app_name'.");
|
|
446
|
+
}
|
|
435
447
|
return config = {
|
|
436
448
|
exposes: normalizeExposes(options.exposes),
|
|
437
449
|
filename: options.filename || 'remoteEntry-[hash]',
|
|
@@ -449,7 +461,8 @@ function normalizeModuleFederationOptions(options) {
|
|
|
449
461
|
dts: options.dts,
|
|
450
462
|
getPublicPath: options.getPublicPath,
|
|
451
463
|
shareStrategy: options.shareStrategy || 'version-first',
|
|
452
|
-
ignoreOrigin: options.ignoreOrigin || false
|
|
464
|
+
ignoreOrigin: options.ignoreOrigin || false,
|
|
465
|
+
virtualModuleDir: options.virtualModuleDir || '__mf__virtual'
|
|
453
466
|
};
|
|
454
467
|
}
|
|
455
468
|
|
|
@@ -524,7 +537,6 @@ function getNodeModulesDir() {
|
|
|
524
537
|
}
|
|
525
538
|
return cachedNodeModulesDir;
|
|
526
539
|
}
|
|
527
|
-
var virtualPackageName = '__mf__virtual';
|
|
528
540
|
var patternMap = {};
|
|
529
541
|
var cacheMap = {};
|
|
530
542
|
/**
|
|
@@ -563,12 +575,14 @@ var VirtualModule = /*#__PURE__*/function () {
|
|
|
563
575
|
*/;
|
|
564
576
|
VirtualModule.ensureVirtualPackageExists = function ensureVirtualPackageExists() {
|
|
565
577
|
var nodeModulesDir = getNodeModulesDir();
|
|
566
|
-
var
|
|
578
|
+
var _getNormalizeModuleFe = getNormalizeModuleFederationOptions(),
|
|
579
|
+
virtualModuleDir = _getNormalizeModuleFe.virtualModuleDir;
|
|
580
|
+
var virtualPackagePath = path.resolve(nodeModulesDir, virtualModuleDir);
|
|
567
581
|
if (!fs.existsSync(virtualPackagePath)) {
|
|
568
582
|
fs.mkdirSync(virtualPackagePath);
|
|
569
583
|
fs.writeFileSync(path.resolve(virtualPackagePath, 'empty.js'), '');
|
|
570
584
|
fs.writeFileSync(path.resolve(virtualPackagePath, 'package.json'), JSON.stringify({
|
|
571
|
-
name:
|
|
585
|
+
name: virtualModuleDir,
|
|
572
586
|
main: 'empty.js'
|
|
573
587
|
}));
|
|
574
588
|
}
|
|
@@ -587,9 +601,10 @@ var VirtualModule = /*#__PURE__*/function () {
|
|
|
587
601
|
return path.resolve(getNodeModulesDir(), this.getImportId());
|
|
588
602
|
};
|
|
589
603
|
_proto.getImportId = function getImportId() {
|
|
590
|
-
var
|
|
591
|
-
mfName =
|
|
592
|
-
|
|
604
|
+
var _getNormalizeModuleFe2 = getNormalizeModuleFederationOptions(),
|
|
605
|
+
mfName = _getNormalizeModuleFe2.name,
|
|
606
|
+
virtualModuleDir = _getNormalizeModuleFe2.virtualModuleDir;
|
|
607
|
+
return virtualModuleDir + "/" + packageNameEncode("" + mfName + this.tag + this.name + this.tag) + this.suffix;
|
|
593
608
|
};
|
|
594
609
|
_proto.writeSync = function writeSync(code, force) {
|
|
595
610
|
if (!force && this.inited) return;
|
|
@@ -1395,9 +1410,10 @@ function federation(mfUserOptions) {
|
|
|
1395
1410
|
strictRequires: 'auto'
|
|
1396
1411
|
}
|
|
1397
1412
|
});
|
|
1413
|
+
var virtualDir = options.virtualModuleDir || '__mf__virtual';
|
|
1398
1414
|
(_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1399
|
-
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(
|
|
1400
|
-
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(
|
|
1415
|
+
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(virtualDir);
|
|
1416
|
+
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(virtualDir);
|
|
1401
1417
|
(_config$optimizeDeps4 = _config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
|
|
1402
1418
|
}
|
|
1403
1419
|
}], Manifest());
|
package/lib/index.esm.js
CHANGED
|
@@ -333,10 +333,19 @@ function searchPackageVersion(sharedName) {
|
|
|
333
333
|
function normalizeShareItem(key, shareItem) {
|
|
334
334
|
var version;
|
|
335
335
|
try {
|
|
336
|
-
|
|
336
|
+
try {
|
|
337
|
+
version = require(path.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
338
|
+
} catch (e1) {
|
|
339
|
+
try {
|
|
340
|
+
var localPath = path.join(process.cwd(), 'node_modules', removePathFromNpmPackage(key), 'package.json');
|
|
341
|
+
version = require(localPath).version;
|
|
342
|
+
} catch (e2) {
|
|
343
|
+
version = searchPackageVersion(key);
|
|
344
|
+
if (!version) console.error(e1);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
337
347
|
} catch (e) {
|
|
338
|
-
version
|
|
339
|
-
if (!version) console.error(e);
|
|
348
|
+
console.error("Unexpected error resolving version for " + key + ":", e);
|
|
340
349
|
}
|
|
341
350
|
if (typeof shareItem === 'string') {
|
|
342
351
|
return {
|
|
@@ -408,6 +417,9 @@ function normalizeModuleFederationOptions(options) {
|
|
|
408
417
|
if (options.getPublicPath) {
|
|
409
418
|
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");
|
|
410
419
|
}
|
|
420
|
+
if (options.virtualModuleDir && options.virtualModuleDir.includes('/')) {
|
|
421
|
+
throw new Error("Invalid virtualModuleDir: \"" + options.virtualModuleDir + "\". " + "The virtualModuleDir option cannot contain slashes (/). " + "Please use a single directory name like '__mf__virtual__your_app_name'.");
|
|
422
|
+
}
|
|
411
423
|
return config = {
|
|
412
424
|
exposes: normalizeExposes(options.exposes),
|
|
413
425
|
filename: options.filename || 'remoteEntry-[hash]',
|
|
@@ -425,7 +437,8 @@ function normalizeModuleFederationOptions(options) {
|
|
|
425
437
|
dts: options.dts,
|
|
426
438
|
getPublicPath: options.getPublicPath,
|
|
427
439
|
shareStrategy: options.shareStrategy || 'version-first',
|
|
428
|
-
ignoreOrigin: options.ignoreOrigin || false
|
|
440
|
+
ignoreOrigin: options.ignoreOrigin || false,
|
|
441
|
+
virtualModuleDir: options.virtualModuleDir || '__mf__virtual'
|
|
429
442
|
};
|
|
430
443
|
}
|
|
431
444
|
|
|
@@ -500,7 +513,6 @@ function getNodeModulesDir() {
|
|
|
500
513
|
}
|
|
501
514
|
return cachedNodeModulesDir;
|
|
502
515
|
}
|
|
503
|
-
var virtualPackageName = '__mf__virtual';
|
|
504
516
|
var patternMap = {};
|
|
505
517
|
var cacheMap = {};
|
|
506
518
|
/**
|
|
@@ -539,12 +551,14 @@ var VirtualModule = /*#__PURE__*/function () {
|
|
|
539
551
|
*/;
|
|
540
552
|
VirtualModule.ensureVirtualPackageExists = function ensureVirtualPackageExists() {
|
|
541
553
|
var nodeModulesDir = getNodeModulesDir();
|
|
542
|
-
var
|
|
554
|
+
var _getNormalizeModuleFe = getNormalizeModuleFederationOptions(),
|
|
555
|
+
virtualModuleDir = _getNormalizeModuleFe.virtualModuleDir;
|
|
556
|
+
var virtualPackagePath = resolve(nodeModulesDir, virtualModuleDir);
|
|
543
557
|
if (!existsSync(virtualPackagePath)) {
|
|
544
558
|
mkdirSync(virtualPackagePath);
|
|
545
559
|
writeFileSync(resolve(virtualPackagePath, 'empty.js'), '');
|
|
546
560
|
writeFileSync(resolve(virtualPackagePath, 'package.json'), JSON.stringify({
|
|
547
|
-
name:
|
|
561
|
+
name: virtualModuleDir,
|
|
548
562
|
main: 'empty.js'
|
|
549
563
|
}));
|
|
550
564
|
}
|
|
@@ -563,9 +577,10 @@ var VirtualModule = /*#__PURE__*/function () {
|
|
|
563
577
|
return resolve(getNodeModulesDir(), this.getImportId());
|
|
564
578
|
};
|
|
565
579
|
_proto.getImportId = function getImportId() {
|
|
566
|
-
var
|
|
567
|
-
mfName =
|
|
568
|
-
|
|
580
|
+
var _getNormalizeModuleFe2 = getNormalizeModuleFederationOptions(),
|
|
581
|
+
mfName = _getNormalizeModuleFe2.name,
|
|
582
|
+
virtualModuleDir = _getNormalizeModuleFe2.virtualModuleDir;
|
|
583
|
+
return virtualModuleDir + "/" + packageNameEncode("" + mfName + this.tag + this.name + this.tag) + this.suffix;
|
|
569
584
|
};
|
|
570
585
|
_proto.writeSync = function writeSync(code, force) {
|
|
571
586
|
if (!force && this.inited) return;
|
|
@@ -1371,9 +1386,10 @@ function federation(mfUserOptions) {
|
|
|
1371
1386
|
strictRequires: 'auto'
|
|
1372
1387
|
}
|
|
1373
1388
|
});
|
|
1389
|
+
var virtualDir = options.virtualModuleDir || '__mf__virtual';
|
|
1374
1390
|
(_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1375
|
-
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(
|
|
1376
|
-
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(
|
|
1391
|
+
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(virtualDir);
|
|
1392
|
+
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(virtualDir);
|
|
1377
1393
|
(_config$optimizeDeps4 = _config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
|
|
1378
1394
|
}
|
|
1379
1395
|
}], Manifest());
|
package/lib/index.modern.js
CHANGED
|
@@ -306,10 +306,19 @@ function searchPackageVersion(sharedName) {
|
|
|
306
306
|
function normalizeShareItem(key, shareItem) {
|
|
307
307
|
let version;
|
|
308
308
|
try {
|
|
309
|
-
|
|
309
|
+
try {
|
|
310
|
+
version = require(path.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
311
|
+
} catch (e1) {
|
|
312
|
+
try {
|
|
313
|
+
const localPath = path.join(process.cwd(), 'node_modules', removePathFromNpmPackage(key), 'package.json');
|
|
314
|
+
version = require(localPath).version;
|
|
315
|
+
} catch (e2) {
|
|
316
|
+
version = searchPackageVersion(key);
|
|
317
|
+
if (!version) console.error(e1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
310
320
|
} catch (e) {
|
|
311
|
-
version
|
|
312
|
-
if (!version) console.error(e);
|
|
321
|
+
console.error(`Unexpected error resolving version for ${key}:`, e);
|
|
313
322
|
}
|
|
314
323
|
if (typeof shareItem === 'string') {
|
|
315
324
|
return {
|
|
@@ -378,6 +387,9 @@ function normalizeModuleFederationOptions(options) {
|
|
|
378
387
|
if (options.getPublicPath) {
|
|
379
388
|
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`);
|
|
380
389
|
}
|
|
390
|
+
if (options.virtualModuleDir && options.virtualModuleDir.includes('/')) {
|
|
391
|
+
throw new Error(`Invalid virtualModuleDir: "${options.virtualModuleDir}". ` + `The virtualModuleDir option cannot contain slashes (/). ` + `Please use a single directory name like '__mf__virtual__your_app_name'.`);
|
|
392
|
+
}
|
|
381
393
|
return config = {
|
|
382
394
|
exposes: normalizeExposes(options.exposes),
|
|
383
395
|
filename: options.filename || 'remoteEntry-[hash]',
|
|
@@ -395,7 +407,8 @@ function normalizeModuleFederationOptions(options) {
|
|
|
395
407
|
dts: options.dts,
|
|
396
408
|
getPublicPath: options.getPublicPath,
|
|
397
409
|
shareStrategy: options.shareStrategy || 'version-first',
|
|
398
|
-
ignoreOrigin: options.ignoreOrigin || false
|
|
410
|
+
ignoreOrigin: options.ignoreOrigin || false,
|
|
411
|
+
virtualModuleDir: options.virtualModuleDir || '__mf__virtual'
|
|
399
412
|
};
|
|
400
413
|
}
|
|
401
414
|
|
|
@@ -468,7 +481,6 @@ function getNodeModulesDir() {
|
|
|
468
481
|
}
|
|
469
482
|
return cachedNodeModulesDir;
|
|
470
483
|
}
|
|
471
|
-
const virtualPackageName = '__mf__virtual';
|
|
472
484
|
const patternMap = {};
|
|
473
485
|
const cacheMap = {};
|
|
474
486
|
/**
|
|
@@ -489,12 +501,15 @@ class VirtualModule {
|
|
|
489
501
|
*/
|
|
490
502
|
static ensureVirtualPackageExists() {
|
|
491
503
|
const nodeModulesDir = getNodeModulesDir();
|
|
492
|
-
const
|
|
504
|
+
const {
|
|
505
|
+
virtualModuleDir
|
|
506
|
+
} = getNormalizeModuleFederationOptions();
|
|
507
|
+
const virtualPackagePath = resolve(nodeModulesDir, virtualModuleDir);
|
|
493
508
|
if (!existsSync(virtualPackagePath)) {
|
|
494
509
|
mkdirSync(virtualPackagePath);
|
|
495
510
|
writeFileSync(resolve(virtualPackagePath, 'empty.js'), '');
|
|
496
511
|
writeFileSync(resolve(virtualPackagePath, 'package.json'), JSON.stringify({
|
|
497
|
-
name:
|
|
512
|
+
name: virtualModuleDir,
|
|
498
513
|
main: 'empty.js'
|
|
499
514
|
}));
|
|
500
515
|
}
|
|
@@ -522,9 +537,10 @@ class VirtualModule {
|
|
|
522
537
|
}
|
|
523
538
|
getImportId() {
|
|
524
539
|
const {
|
|
525
|
-
name: mfName
|
|
540
|
+
name: mfName,
|
|
541
|
+
virtualModuleDir
|
|
526
542
|
} = getNormalizeModuleFederationOptions();
|
|
527
|
-
return `${
|
|
543
|
+
return `${virtualModuleDir}/${packageNameEncode(`${mfName}${this.tag}${this.name}${this.tag}`)}${this.suffix}`;
|
|
528
544
|
}
|
|
529
545
|
writeSync(code, force) {
|
|
530
546
|
if (!force && this.inited) return;
|
|
@@ -1444,9 +1460,10 @@ function federation(mfUserOptions) {
|
|
|
1444
1460
|
strictRequires: 'auto'
|
|
1445
1461
|
}
|
|
1446
1462
|
});
|
|
1463
|
+
const virtualDir = options.virtualModuleDir || '__mf__virtual';
|
|
1447
1464
|
(_config$optimizeDeps = config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1448
|
-
(_config$optimizeDeps2 = config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(
|
|
1449
|
-
(_config$optimizeDeps3 = config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(
|
|
1465
|
+
(_config$optimizeDeps2 = config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(virtualDir);
|
|
1466
|
+
(_config$optimizeDeps3 = config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(virtualDir);
|
|
1450
1467
|
(_config$optimizeDeps4 = config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
|
|
1451
1468
|
}
|
|
1452
1469
|
}, ...Manifest()];
|
package/lib/index.umd.js
CHANGED
|
@@ -355,10 +355,19 @@
|
|
|
355
355
|
function normalizeShareItem(key, shareItem) {
|
|
356
356
|
var version;
|
|
357
357
|
try {
|
|
358
|
-
|
|
358
|
+
try {
|
|
359
|
+
version = require(path__namespace.join(removePathFromNpmPackage(key), 'package.json')).version;
|
|
360
|
+
} catch (e1) {
|
|
361
|
+
try {
|
|
362
|
+
var localPath = path__namespace.join(process.cwd(), 'node_modules', removePathFromNpmPackage(key), 'package.json');
|
|
363
|
+
version = require(localPath).version;
|
|
364
|
+
} catch (e2) {
|
|
365
|
+
version = searchPackageVersion(key);
|
|
366
|
+
if (!version) console.error(e1);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
359
369
|
} catch (e) {
|
|
360
|
-
version
|
|
361
|
-
if (!version) console.error(e);
|
|
370
|
+
console.error("Unexpected error resolving version for " + key + ":", e);
|
|
362
371
|
}
|
|
363
372
|
if (typeof shareItem === 'string') {
|
|
364
373
|
return {
|
|
@@ -430,6 +439,9 @@
|
|
|
430
439
|
if (options.getPublicPath) {
|
|
431
440
|
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");
|
|
432
441
|
}
|
|
442
|
+
if (options.virtualModuleDir && options.virtualModuleDir.includes('/')) {
|
|
443
|
+
throw new Error("Invalid virtualModuleDir: \"" + options.virtualModuleDir + "\". " + "The virtualModuleDir option cannot contain slashes (/). " + "Please use a single directory name like '__mf__virtual__your_app_name'.");
|
|
444
|
+
}
|
|
433
445
|
return config = {
|
|
434
446
|
exposes: normalizeExposes(options.exposes),
|
|
435
447
|
filename: options.filename || 'remoteEntry-[hash]',
|
|
@@ -447,7 +459,8 @@
|
|
|
447
459
|
dts: options.dts,
|
|
448
460
|
getPublicPath: options.getPublicPath,
|
|
449
461
|
shareStrategy: options.shareStrategy || 'version-first',
|
|
450
|
-
ignoreOrigin: options.ignoreOrigin || false
|
|
462
|
+
ignoreOrigin: options.ignoreOrigin || false,
|
|
463
|
+
virtualModuleDir: options.virtualModuleDir || '__mf__virtual'
|
|
451
464
|
};
|
|
452
465
|
}
|
|
453
466
|
|
|
@@ -522,7 +535,6 @@
|
|
|
522
535
|
}
|
|
523
536
|
return cachedNodeModulesDir;
|
|
524
537
|
}
|
|
525
|
-
var virtualPackageName = '__mf__virtual';
|
|
526
538
|
var patternMap = {};
|
|
527
539
|
var cacheMap = {};
|
|
528
540
|
/**
|
|
@@ -561,12 +573,14 @@
|
|
|
561
573
|
*/;
|
|
562
574
|
VirtualModule.ensureVirtualPackageExists = function ensureVirtualPackageExists() {
|
|
563
575
|
var nodeModulesDir = getNodeModulesDir();
|
|
564
|
-
var
|
|
576
|
+
var _getNormalizeModuleFe = getNormalizeModuleFederationOptions(),
|
|
577
|
+
virtualModuleDir = _getNormalizeModuleFe.virtualModuleDir;
|
|
578
|
+
var virtualPackagePath = path.resolve(nodeModulesDir, virtualModuleDir);
|
|
565
579
|
if (!fs.existsSync(virtualPackagePath)) {
|
|
566
580
|
fs.mkdirSync(virtualPackagePath);
|
|
567
581
|
fs.writeFileSync(path.resolve(virtualPackagePath, 'empty.js'), '');
|
|
568
582
|
fs.writeFileSync(path.resolve(virtualPackagePath, 'package.json'), JSON.stringify({
|
|
569
|
-
name:
|
|
583
|
+
name: virtualModuleDir,
|
|
570
584
|
main: 'empty.js'
|
|
571
585
|
}));
|
|
572
586
|
}
|
|
@@ -585,9 +599,10 @@
|
|
|
585
599
|
return path.resolve(getNodeModulesDir(), this.getImportId());
|
|
586
600
|
};
|
|
587
601
|
_proto.getImportId = function getImportId() {
|
|
588
|
-
var
|
|
589
|
-
mfName =
|
|
590
|
-
|
|
602
|
+
var _getNormalizeModuleFe2 = getNormalizeModuleFederationOptions(),
|
|
603
|
+
mfName = _getNormalizeModuleFe2.name,
|
|
604
|
+
virtualModuleDir = _getNormalizeModuleFe2.virtualModuleDir;
|
|
605
|
+
return virtualModuleDir + "/" + packageNameEncode("" + mfName + this.tag + this.name + this.tag) + this.suffix;
|
|
591
606
|
};
|
|
592
607
|
_proto.writeSync = function writeSync(code, force) {
|
|
593
608
|
if (!force && this.inited) return;
|
|
@@ -1393,9 +1408,10 @@
|
|
|
1393
1408
|
strictRequires: 'auto'
|
|
1394
1409
|
}
|
|
1395
1410
|
});
|
|
1411
|
+
var virtualDir = options.virtualModuleDir || '__mf__virtual';
|
|
1396
1412
|
(_config$optimizeDeps = _config.optimizeDeps) == null || (_config$optimizeDeps = _config$optimizeDeps.include) == null || _config$optimizeDeps.push('@module-federation/runtime');
|
|
1397
|
-
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(
|
|
1398
|
-
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(
|
|
1413
|
+
(_config$optimizeDeps2 = _config.optimizeDeps) == null || (_config$optimizeDeps2 = _config$optimizeDeps2.include) == null || _config$optimizeDeps2.push(virtualDir);
|
|
1414
|
+
(_config$optimizeDeps3 = _config.optimizeDeps) == null || (_config$optimizeDeps3 = _config$optimizeDeps3.needsInterop) == null || _config$optimizeDeps3.push(virtualDir);
|
|
1399
1415
|
(_config$optimizeDeps4 = _config.optimizeDeps) == null || (_config$optimizeDeps4 = _config$optimizeDeps4.needsInterop) == null || _config$optimizeDeps4.push(getLocalSharedImportMapPath());
|
|
1400
1416
|
}
|
|
1401
1417
|
}], Manifest());
|
|
@@ -52,6 +52,7 @@ export type ModuleFederationOptions = {
|
|
|
52
52
|
dts?: boolean | PluginDtsOptions;
|
|
53
53
|
shareStrategy?: ShareStrategy;
|
|
54
54
|
ignoreOrigin?: boolean;
|
|
55
|
+
virtualModuleDir?: string;
|
|
55
56
|
};
|
|
56
57
|
export interface NormalizedModuleFederationOptions {
|
|
57
58
|
exposes: Record<string, ExposesItem>;
|
|
@@ -70,6 +71,7 @@ export interface NormalizedModuleFederationOptions {
|
|
|
70
71
|
shareStrategy: ShareStrategy;
|
|
71
72
|
getPublicPath?: string;
|
|
72
73
|
ignoreOrigin?: boolean;
|
|
74
|
+
virtualModuleDir: string;
|
|
73
75
|
}
|
|
74
76
|
interface PluginDevOptions {
|
|
75
77
|
disableLiveReload?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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.8.0",
|
|
50
33
|
"@rollup/pluginutils": "^5.1.0",
|
|
@@ -65,5 +48,20 @@
|
|
|
65
48
|
"vite": "^5.4.3",
|
|
66
49
|
"vitest": "^2.1.1",
|
|
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
|
+
}
|