@module-federation/vite 1.0.0-alpha-2f53b4e → 1.0.0-alpha-c13dc95
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 +3 -3
- package/lib/index.cjs +7 -17
- package/lib/index.esm.js +7 -17
- package/lib/index.modern.js +7 -20
- package/lib/index.umd.js +7 -17
- package/lib/virtualModules/index.d.ts +1 -1
- package/lib/virtualModules/virtualRemoteEntry.d.ts +1 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,11 @@ This plugin makes Module Federation work together with [Vite](https://vitejs.dev
|
|
|
9
9
|
|
|
10
10
|
## Working implementations
|
|
11
11
|
|
|
12
|
-
### [
|
|
12
|
+
### [Vue](https://github.com/gioboa/vue-microfrontend-demo)
|
|
13
13
|
|
|
14
|
-
### [
|
|
14
|
+
### [React](https://github.com/gioboa/react-microfrontend-demo)<br>
|
|
15
15
|
|
|
16
|
-
### [
|
|
16
|
+
### [More examples here](https://github.com/module-federation/vite/tree/main/examples)<br>
|
|
17
17
|
|
|
18
18
|
## Getting started 🚀
|
|
19
19
|
|
package/lib/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ var addEntry = function addEntry(_ref) {
|
|
|
34
34
|
var entryName = _ref.entryName,
|
|
35
35
|
entryPath = _ref.entryPath,
|
|
36
36
|
fileName = _ref.fileName;
|
|
37
|
+
var devEntryPath = entryPath.startsWith("virtual:mf") ? "/@id/" + entryPath : entryPath;
|
|
37
38
|
var entryFiles = [];
|
|
38
39
|
var htmlFilePath;
|
|
39
40
|
return [{
|
|
@@ -43,7 +44,7 @@ var addEntry = function addEntry(_ref) {
|
|
|
43
44
|
var _server$httpServer;
|
|
44
45
|
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () {
|
|
45
46
|
var port = server.config.server.port;
|
|
46
|
-
fetch(path__namespace.join("http://localhost:" + port, "" +
|
|
47
|
+
fetch(path__namespace.join("http://localhost:" + port, "" + devEntryPath))["catch"](function (e) {});
|
|
47
48
|
});
|
|
48
49
|
server.middlewares.use(function (req, res, next) {
|
|
49
50
|
if (!fileName) {
|
|
@@ -51,13 +52,13 @@ var addEntry = function addEntry(_ref) {
|
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
if (req.url && req.url.startsWith(fileName.replace(/^\/?/, '/'))) {
|
|
54
|
-
req.url =
|
|
55
|
+
req.url = devEntryPath;
|
|
55
56
|
}
|
|
56
57
|
next();
|
|
57
58
|
});
|
|
58
59
|
},
|
|
59
60
|
transformIndexHtml: function transformIndexHtml(c) {
|
|
60
|
-
return c.replace('<head>', "<head><script type=\"module\" src=" + JSON.stringify(
|
|
61
|
+
return c.replace('<head>', "<head><script type=\"module\" src=" + JSON.stringify(devEntryPath.replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/\\\\?/g, '/')) + "></script>");
|
|
61
62
|
}
|
|
62
63
|
}, {
|
|
63
64
|
name: "add-entry",
|
|
@@ -480,7 +481,7 @@ function writeLoadShareModule(pkg, shareItem, command) {
|
|
|
480
481
|
loadShareCacheMap[pkg].writeSync("\n () => import(" + JSON.stringify(getPreBuildLibImportId(pkg)) + ").catch(() => {});\n // dev uses dynamic import to separate chunks\n " + (command !== "build" ? ";() => import(" + JSON.stringify(pkg) + ").catch(() => {});" : '') + "\n const {loadShare} = require(\"@module-federation/runtime\")\n const res = loadShare(" + JSON.stringify(pkg) + ", {\n customShareInfo: {shareConfig:{\n singleton: " + shareItem.shareConfig.singleton + ",\n strictVersion: " + shareItem.shareConfig.strictVersion + ",\n requiredVersion: " + JSON.stringify(shareItem.shareConfig.requiredVersion) + "\n }}})\n const exportModule = " + (command !== "build" ? "/*mf top-level-await placeholder replacement mf*/" : "await ") + "res.then(factory => factory())\n module.exports = exportModule\n ");
|
|
481
482
|
}
|
|
482
483
|
|
|
483
|
-
var REMOTE_ENTRY_ID = 'REMOTE_ENTRY_ID';
|
|
484
|
+
var REMOTE_ENTRY_ID = 'virtual:mf-REMOTE_ENTRY_ID';
|
|
484
485
|
function generateRemoteEntry(options) {
|
|
485
486
|
var pluginImportNames = options.runtimePlugins.map(function (p, i) {
|
|
486
487
|
return ["$runtimePlugin_" + i, "import $runtimePlugin_" + i + " from \"" + p + "\";"];
|
|
@@ -496,16 +497,6 @@ function generateRemoteEntry(options) {
|
|
|
496
497
|
return item[0] + "()";
|
|
497
498
|
}).join(', ') + "]\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
|
|
498
499
|
}
|
|
499
|
-
var wrapRemoteEntryModule = new VirtualModule("wrapRemoteEntry");
|
|
500
|
-
function writeWrapRemoteEntry() {
|
|
501
|
-
wrapRemoteEntryModule.writeSync("\n import {init, get} from \"" + REMOTE_ENTRY_ID + "\"\n export {init, get}\n ");
|
|
502
|
-
}
|
|
503
|
-
function getWrapRemoteEntryImportId() {
|
|
504
|
-
return wrapRemoteEntryModule.getImportId();
|
|
505
|
-
}
|
|
506
|
-
function getWrapRemoteEntryPath() {
|
|
507
|
-
return wrapRemoteEntryModule.getPath();
|
|
508
|
-
}
|
|
509
500
|
/**
|
|
510
501
|
* Inject entry file, automatically init when used as host,
|
|
511
502
|
* and will not inject remoteEntry
|
|
@@ -536,7 +527,6 @@ function generateRemotes(id, command) {
|
|
|
536
527
|
|
|
537
528
|
function initVirtualModules() {
|
|
538
529
|
writeLocalSharedImportMap();
|
|
539
|
-
writeWrapRemoteEntry();
|
|
540
530
|
writeHostAutoInit();
|
|
541
531
|
writeRemote();
|
|
542
532
|
}
|
|
@@ -892,13 +882,13 @@ function federation(mfUserOptions) {
|
|
|
892
882
|
if (!name) throw new Error("name is required");
|
|
893
883
|
return [aliasToArrayPlugin, normalizeOptimizeDepsPlugin].concat(addEntry({
|
|
894
884
|
entryName: 'remoteEntry',
|
|
895
|
-
entryPath:
|
|
885
|
+
entryPath: REMOTE_ENTRY_ID,
|
|
896
886
|
fileName: filename
|
|
897
887
|
}), addEntry({
|
|
898
888
|
entryName: 'hostInit',
|
|
899
889
|
entryPath: getHostAutoInitPath()
|
|
900
890
|
}), [pluginProxyRemoteEntry(), pluginProxyRemotes(options)], pluginModuleParseEnd(function (id) {
|
|
901
|
-
return id.includes(getHostAutoInitImportId()) || id.includes(
|
|
891
|
+
return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
|
|
902
892
|
}), proxySharedModule({
|
|
903
893
|
shared: shared
|
|
904
894
|
}), [{
|
package/lib/index.esm.js
CHANGED
|
@@ -11,6 +11,7 @@ var addEntry = function addEntry(_ref) {
|
|
|
11
11
|
var entryName = _ref.entryName,
|
|
12
12
|
entryPath = _ref.entryPath,
|
|
13
13
|
fileName = _ref.fileName;
|
|
14
|
+
var devEntryPath = entryPath.startsWith("virtual:mf") ? "/@id/" + entryPath : entryPath;
|
|
14
15
|
var entryFiles = [];
|
|
15
16
|
var htmlFilePath;
|
|
16
17
|
return [{
|
|
@@ -20,7 +21,7 @@ var addEntry = function addEntry(_ref) {
|
|
|
20
21
|
var _server$httpServer;
|
|
21
22
|
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () {
|
|
22
23
|
var port = server.config.server.port;
|
|
23
|
-
fetch(path.join("http://localhost:" + port, "" +
|
|
24
|
+
fetch(path.join("http://localhost:" + port, "" + devEntryPath))["catch"](function (e) {});
|
|
24
25
|
});
|
|
25
26
|
server.middlewares.use(function (req, res, next) {
|
|
26
27
|
if (!fileName) {
|
|
@@ -28,13 +29,13 @@ var addEntry = function addEntry(_ref) {
|
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
if (req.url && req.url.startsWith(fileName.replace(/^\/?/, '/'))) {
|
|
31
|
-
req.url =
|
|
32
|
+
req.url = devEntryPath;
|
|
32
33
|
}
|
|
33
34
|
next();
|
|
34
35
|
});
|
|
35
36
|
},
|
|
36
37
|
transformIndexHtml: function transformIndexHtml(c) {
|
|
37
|
-
return c.replace('<head>', "<head><script type=\"module\" src=" + JSON.stringify(
|
|
38
|
+
return c.replace('<head>', "<head><script type=\"module\" src=" + JSON.stringify(devEntryPath.replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/\\\\?/g, '/')) + "></script>");
|
|
38
39
|
}
|
|
39
40
|
}, {
|
|
40
41
|
name: "add-entry",
|
|
@@ -457,7 +458,7 @@ function writeLoadShareModule(pkg, shareItem, command) {
|
|
|
457
458
|
loadShareCacheMap[pkg].writeSync("\n () => import(" + JSON.stringify(getPreBuildLibImportId(pkg)) + ").catch(() => {});\n // dev uses dynamic import to separate chunks\n " + (command !== "build" ? ";() => import(" + JSON.stringify(pkg) + ").catch(() => {});" : '') + "\n const {loadShare} = require(\"@module-federation/runtime\")\n const res = loadShare(" + JSON.stringify(pkg) + ", {\n customShareInfo: {shareConfig:{\n singleton: " + shareItem.shareConfig.singleton + ",\n strictVersion: " + shareItem.shareConfig.strictVersion + ",\n requiredVersion: " + JSON.stringify(shareItem.shareConfig.requiredVersion) + "\n }}})\n const exportModule = " + (command !== "build" ? "/*mf top-level-await placeholder replacement mf*/" : "await ") + "res.then(factory => factory())\n module.exports = exportModule\n ");
|
|
458
459
|
}
|
|
459
460
|
|
|
460
|
-
var REMOTE_ENTRY_ID = 'REMOTE_ENTRY_ID';
|
|
461
|
+
var REMOTE_ENTRY_ID = 'virtual:mf-REMOTE_ENTRY_ID';
|
|
461
462
|
function generateRemoteEntry(options) {
|
|
462
463
|
var pluginImportNames = options.runtimePlugins.map(function (p, i) {
|
|
463
464
|
return ["$runtimePlugin_" + i, "import $runtimePlugin_" + i + " from \"" + p + "\";"];
|
|
@@ -473,16 +474,6 @@ function generateRemoteEntry(options) {
|
|
|
473
474
|
return item[0] + "()";
|
|
474
475
|
}).join(', ') + "]\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
|
|
475
476
|
}
|
|
476
|
-
var wrapRemoteEntryModule = new VirtualModule("wrapRemoteEntry");
|
|
477
|
-
function writeWrapRemoteEntry() {
|
|
478
|
-
wrapRemoteEntryModule.writeSync("\n import {init, get} from \"" + REMOTE_ENTRY_ID + "\"\n export {init, get}\n ");
|
|
479
|
-
}
|
|
480
|
-
function getWrapRemoteEntryImportId() {
|
|
481
|
-
return wrapRemoteEntryModule.getImportId();
|
|
482
|
-
}
|
|
483
|
-
function getWrapRemoteEntryPath() {
|
|
484
|
-
return wrapRemoteEntryModule.getPath();
|
|
485
|
-
}
|
|
486
477
|
/**
|
|
487
478
|
* Inject entry file, automatically init when used as host,
|
|
488
479
|
* and will not inject remoteEntry
|
|
@@ -513,7 +504,6 @@ function generateRemotes(id, command) {
|
|
|
513
504
|
|
|
514
505
|
function initVirtualModules() {
|
|
515
506
|
writeLocalSharedImportMap();
|
|
516
|
-
writeWrapRemoteEntry();
|
|
517
507
|
writeHostAutoInit();
|
|
518
508
|
writeRemote();
|
|
519
509
|
}
|
|
@@ -869,13 +859,13 @@ function federation(mfUserOptions) {
|
|
|
869
859
|
if (!name) throw new Error("name is required");
|
|
870
860
|
return [aliasToArrayPlugin, normalizeOptimizeDepsPlugin].concat(addEntry({
|
|
871
861
|
entryName: 'remoteEntry',
|
|
872
|
-
entryPath:
|
|
862
|
+
entryPath: REMOTE_ENTRY_ID,
|
|
873
863
|
fileName: filename
|
|
874
864
|
}), addEntry({
|
|
875
865
|
entryName: 'hostInit',
|
|
876
866
|
entryPath: getHostAutoInitPath()
|
|
877
867
|
}), [pluginProxyRemoteEntry(), pluginProxyRemotes(options)], pluginModuleParseEnd(function (id) {
|
|
878
|
-
return id.includes(getHostAutoInitImportId()) || id.includes(
|
|
868
|
+
return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
|
|
879
869
|
}), proxySharedModule({
|
|
880
870
|
shared: shared
|
|
881
871
|
}), [{
|
package/lib/index.modern.js
CHANGED
|
@@ -12,6 +12,7 @@ const addEntry = ({
|
|
|
12
12
|
entryPath,
|
|
13
13
|
fileName
|
|
14
14
|
}) => {
|
|
15
|
+
const devEntryPath = entryPath.startsWith("virtual:mf") ? "/@id/" + entryPath : entryPath;
|
|
15
16
|
let entryFiles = [];
|
|
16
17
|
let htmlFilePath;
|
|
17
18
|
return [{
|
|
@@ -23,7 +24,7 @@ const addEntry = ({
|
|
|
23
24
|
const {
|
|
24
25
|
port
|
|
25
26
|
} = server.config.server;
|
|
26
|
-
fetch(path.join(`http://localhost:${port}`, `${
|
|
27
|
+
fetch(path.join(`http://localhost:${port}`, `${devEntryPath}`)).catch(e => {});
|
|
27
28
|
});
|
|
28
29
|
server.middlewares.use((req, res, next) => {
|
|
29
30
|
if (!fileName) {
|
|
@@ -31,13 +32,13 @@ const addEntry = ({
|
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
if (req.url && req.url.startsWith(fileName.replace(/^\/?/, '/'))) {
|
|
34
|
-
req.url =
|
|
35
|
+
req.url = devEntryPath;
|
|
35
36
|
}
|
|
36
37
|
next();
|
|
37
38
|
});
|
|
38
39
|
},
|
|
39
40
|
transformIndexHtml(c) {
|
|
40
|
-
return c.replace('<head>', `<head><script type="module" src=${JSON.stringify(
|
|
41
|
+
return c.replace('<head>', `<head><script type="module" src=${JSON.stringify(devEntryPath.replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/\\\\?/g, '/'))}></script>`);
|
|
41
42
|
}
|
|
42
43
|
}, {
|
|
43
44
|
name: "add-entry",
|
|
@@ -484,7 +485,7 @@ function writeLoadShareModule(pkg, shareItem, command) {
|
|
|
484
485
|
`);
|
|
485
486
|
}
|
|
486
487
|
|
|
487
|
-
const REMOTE_ENTRY_ID = 'REMOTE_ENTRY_ID';
|
|
488
|
+
const REMOTE_ENTRY_ID = 'virtual:mf-REMOTE_ENTRY_ID';
|
|
488
489
|
function generateRemoteEntry(options) {
|
|
489
490
|
const pluginImportNames = options.runtimePlugins.map((p, i) => [`$runtimePlugin_${i}`, `import $runtimePlugin_${i} from "${p}";`]);
|
|
490
491
|
return `
|
|
@@ -541,19 +542,6 @@ function generateRemoteEntry(options) {
|
|
|
541
542
|
}
|
|
542
543
|
`;
|
|
543
544
|
}
|
|
544
|
-
const wrapRemoteEntryModule = new VirtualModule("wrapRemoteEntry");
|
|
545
|
-
function writeWrapRemoteEntry() {
|
|
546
|
-
wrapRemoteEntryModule.writeSync(`
|
|
547
|
-
import {init, get} from "${REMOTE_ENTRY_ID}"
|
|
548
|
-
export {init, get}
|
|
549
|
-
`);
|
|
550
|
-
}
|
|
551
|
-
function getWrapRemoteEntryImportId() {
|
|
552
|
-
return wrapRemoteEntryModule.getImportId();
|
|
553
|
-
}
|
|
554
|
-
function getWrapRemoteEntryPath() {
|
|
555
|
-
return wrapRemoteEntryModule.getPath();
|
|
556
|
-
}
|
|
557
545
|
/**
|
|
558
546
|
* Inject entry file, automatically init when used as host,
|
|
559
547
|
* and will not inject remoteEntry
|
|
@@ -597,7 +585,6 @@ function generateRemotes(id, command) {
|
|
|
597
585
|
|
|
598
586
|
function initVirtualModules() {
|
|
599
587
|
writeLocalSharedImportMap();
|
|
600
|
-
writeWrapRemoteEntry();
|
|
601
588
|
writeHostAutoInit();
|
|
602
589
|
writeRemote();
|
|
603
590
|
}
|
|
@@ -942,13 +929,13 @@ function federation(mfUserOptions) {
|
|
|
942
929
|
if (!name) throw new Error("name is required");
|
|
943
930
|
return [aliasToArrayPlugin, normalizeOptimizeDepsPlugin, ...addEntry({
|
|
944
931
|
entryName: 'remoteEntry',
|
|
945
|
-
entryPath:
|
|
932
|
+
entryPath: REMOTE_ENTRY_ID,
|
|
946
933
|
fileName: filename
|
|
947
934
|
}), ...addEntry({
|
|
948
935
|
entryName: 'hostInit',
|
|
949
936
|
entryPath: getHostAutoInitPath()
|
|
950
937
|
}), pluginProxyRemoteEntry(), pluginProxyRemotes(options), ...pluginModuleParseEnd(id => {
|
|
951
|
-
return id.includes(getHostAutoInitImportId()) || id.includes(
|
|
938
|
+
return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
|
|
952
939
|
}), ...proxySharedModule({
|
|
953
940
|
shared
|
|
954
941
|
}), {
|
package/lib/index.umd.js
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
var entryName = _ref.entryName,
|
|
33
33
|
entryPath = _ref.entryPath,
|
|
34
34
|
fileName = _ref.fileName;
|
|
35
|
+
var devEntryPath = entryPath.startsWith("virtual:mf") ? "/@id/" + entryPath : entryPath;
|
|
35
36
|
var entryFiles = [];
|
|
36
37
|
var htmlFilePath;
|
|
37
38
|
return [{
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
var _server$httpServer;
|
|
42
43
|
(_server$httpServer = server.httpServer) == null || _server$httpServer.once == null || _server$httpServer.once('listening', function () {
|
|
43
44
|
var port = server.config.server.port;
|
|
44
|
-
fetch(path__namespace.join("http://localhost:" + port, "" +
|
|
45
|
+
fetch(path__namespace.join("http://localhost:" + port, "" + devEntryPath))["catch"](function (e) {});
|
|
45
46
|
});
|
|
46
47
|
server.middlewares.use(function (req, res, next) {
|
|
47
48
|
if (!fileName) {
|
|
@@ -49,13 +50,13 @@
|
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
if (req.url && req.url.startsWith(fileName.replace(/^\/?/, '/'))) {
|
|
52
|
-
req.url =
|
|
53
|
+
req.url = devEntryPath;
|
|
53
54
|
}
|
|
54
55
|
next();
|
|
55
56
|
});
|
|
56
57
|
},
|
|
57
58
|
transformIndexHtml: function transformIndexHtml(c) {
|
|
58
|
-
return c.replace('<head>', "<head><script type=\"module\" src=" + JSON.stringify(
|
|
59
|
+
return c.replace('<head>', "<head><script type=\"module\" src=" + JSON.stringify(devEntryPath.replace(/.+?\:([/\\])[/\\]?/, '$1').replace(/\\\\?/g, '/')) + "></script>");
|
|
59
60
|
}
|
|
60
61
|
}, {
|
|
61
62
|
name: "add-entry",
|
|
@@ -478,7 +479,7 @@
|
|
|
478
479
|
loadShareCacheMap[pkg].writeSync("\n () => import(" + JSON.stringify(getPreBuildLibImportId(pkg)) + ").catch(() => {});\n // dev uses dynamic import to separate chunks\n " + (command !== "build" ? ";() => import(" + JSON.stringify(pkg) + ").catch(() => {});" : '') + "\n const {loadShare} = require(\"@module-federation/runtime\")\n const res = loadShare(" + JSON.stringify(pkg) + ", {\n customShareInfo: {shareConfig:{\n singleton: " + shareItem.shareConfig.singleton + ",\n strictVersion: " + shareItem.shareConfig.strictVersion + ",\n requiredVersion: " + JSON.stringify(shareItem.shareConfig.requiredVersion) + "\n }}})\n const exportModule = " + (command !== "build" ? "/*mf top-level-await placeholder replacement mf*/" : "await ") + "res.then(factory => factory())\n module.exports = exportModule\n ");
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
var REMOTE_ENTRY_ID = 'REMOTE_ENTRY_ID';
|
|
482
|
+
var REMOTE_ENTRY_ID = 'virtual:mf-REMOTE_ENTRY_ID';
|
|
482
483
|
function generateRemoteEntry(options) {
|
|
483
484
|
var pluginImportNames = options.runtimePlugins.map(function (p, i) {
|
|
484
485
|
return ["$runtimePlugin_" + i, "import $runtimePlugin_" + i + " from \"" + p + "\";"];
|
|
@@ -494,16 +495,6 @@
|
|
|
494
495
|
return item[0] + "()";
|
|
495
496
|
}).join(', ') + "]\n });\n initRes.initShareScopeMap('" + options.shareScope + "', shared);\n return initRes\n }\n\n function getExposes(moduleName) {\n if (!(moduleName in exposesMap)) throw new Error(`Module ${moduleName} does not exist in container.`)\n return (exposesMap[moduleName])().then(res => () => res)\n }\n export {\n init,\n getExposes as get\n }\n ";
|
|
496
497
|
}
|
|
497
|
-
var wrapRemoteEntryModule = new VirtualModule("wrapRemoteEntry");
|
|
498
|
-
function writeWrapRemoteEntry() {
|
|
499
|
-
wrapRemoteEntryModule.writeSync("\n import {init, get} from \"" + REMOTE_ENTRY_ID + "\"\n export {init, get}\n ");
|
|
500
|
-
}
|
|
501
|
-
function getWrapRemoteEntryImportId() {
|
|
502
|
-
return wrapRemoteEntryModule.getImportId();
|
|
503
|
-
}
|
|
504
|
-
function getWrapRemoteEntryPath() {
|
|
505
|
-
return wrapRemoteEntryModule.getPath();
|
|
506
|
-
}
|
|
507
498
|
/**
|
|
508
499
|
* Inject entry file, automatically init when used as host,
|
|
509
500
|
* and will not inject remoteEntry
|
|
@@ -534,7 +525,6 @@
|
|
|
534
525
|
|
|
535
526
|
function initVirtualModules() {
|
|
536
527
|
writeLocalSharedImportMap();
|
|
537
|
-
writeWrapRemoteEntry();
|
|
538
528
|
writeHostAutoInit();
|
|
539
529
|
writeRemote();
|
|
540
530
|
}
|
|
@@ -890,13 +880,13 @@
|
|
|
890
880
|
if (!name) throw new Error("name is required");
|
|
891
881
|
return [aliasToArrayPlugin, normalizeOptimizeDepsPlugin].concat(addEntry({
|
|
892
882
|
entryName: 'remoteEntry',
|
|
893
|
-
entryPath:
|
|
883
|
+
entryPath: REMOTE_ENTRY_ID,
|
|
894
884
|
fileName: filename
|
|
895
885
|
}), addEntry({
|
|
896
886
|
entryName: 'hostInit',
|
|
897
887
|
entryPath: getHostAutoInitPath()
|
|
898
888
|
}), [pluginProxyRemoteEntry(), pluginProxyRemotes(options)], pluginModuleParseEnd(function (id) {
|
|
899
|
-
return id.includes(getHostAutoInitImportId()) || id.includes(
|
|
889
|
+
return id.includes(getHostAutoInitImportId()) || id.includes(REMOTE_ENTRY_ID) || id.includes(getLocalSharedImportMapPath());
|
|
900
890
|
}), proxySharedModule({
|
|
901
891
|
shared: shared
|
|
902
892
|
}), [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { generateRemoteEntry, getHostAutoInitImportId, getHostAutoInitPath,
|
|
1
|
+
export { generateRemoteEntry, getHostAutoInitImportId, getHostAutoInitPath, REMOTE_ENTRY_ID } from "./virtualRemoteEntry";
|
|
2
2
|
export { generateRemotes, remoteVirtualModule } from "./virtualRemotes";
|
|
3
3
|
export { addShare, generateLocalSharedImportMap, getLoadShareModulePath, getLocalSharedImportMapPath, getPreBuildLibImportId, LOAD_SHARE_TAG, localSharedImportMapModule, PREBUILD_TAG, writeLoadShareModule, writeLocalSharedImportMap, writePreBuildLibPath } from "./virtualShared_preBuild";
|
|
4
4
|
export declare function initVirtualModules(): void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { NormalizedModuleFederationOptions } from '../utils/normalizeModuleFederationOptions';
|
|
2
|
-
export declare const REMOTE_ENTRY_ID = "REMOTE_ENTRY_ID";
|
|
2
|
+
export declare const REMOTE_ENTRY_ID = "virtual:mf-REMOTE_ENTRY_ID";
|
|
3
3
|
export declare function generateRemoteEntry(options: NormalizedModuleFederationOptions): string;
|
|
4
|
-
export declare function writeWrapRemoteEntry(): void;
|
|
5
|
-
export declare function getWrapRemoteEntryImportId(): string;
|
|
6
|
-
export declare function getWrapRemoteEntryPath(): string;
|
|
7
4
|
export declare function writeHostAutoInit(): void;
|
|
8
5
|
export declare function getHostAutoInitImportId(): string;
|
|
9
6
|
export declare function getHostAutoInitPath(): string;
|