@module-federation/node 2.7.32 → 2.7.34
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/dist/_virtual/_rolldown/runtime.js +31 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/plugins/ChunkCorrelationPlugin.js +308 -0
- package/dist/plugins/ChunkCorrelationPlugin.js.map +1 -0
- package/dist/plugins/ChunkCorrelationPlugin.mjs +305 -0
- package/dist/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
- package/dist/src/filesystem/stratagies.d.mts +21 -0
- package/dist/src/filesystem/stratagies.d.ts +10 -7
- package/dist/src/filesystem/stratagies.js +97 -116
- package/dist/src/filesystem/stratagies.js.map +1 -1
- package/dist/src/filesystem/stratagies.mjs +103 -0
- package/dist/src/filesystem/stratagies.mjs.map +1 -0
- package/dist/src/index.d.mts +8 -0
- package/dist/src/index.d.ts +8 -7
- package/dist/src/index.js +16 -22
- package/dist/src/index.mjs +9 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.d.mts +12 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.d.ts +9 -7
- package/dist/src/plugins/AutomaticPublicPathPlugin.js +26 -35
- package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -1
- package/dist/src/plugins/AutomaticPublicPathPlugin.mjs +28 -0
- package/dist/src/plugins/AutomaticPublicPathPlugin.mjs.map +1 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.d.mts +5 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.d.ts +4 -61
- package/dist/src/plugins/ChunkCorrelationPlugin.js +8 -440
- package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -1
- package/dist/src/plugins/ChunkCorrelationPlugin.mjs +8 -0
- package/dist/src/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.mts +21 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.ts +16 -13
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.js +68 -118
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs +70 -0
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs.map +1 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +46 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +39 -34
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +110 -126
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -1
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs +111 -0
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.d.mts +17 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +14 -10
- package/dist/src/plugins/EntryChunkTrackerPlugin.js +30 -32
- package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -1
- package/dist/src/plugins/EntryChunkTrackerPlugin.mjs +38 -0
- package/dist/src/plugins/EntryChunkTrackerPlugin.mjs.map +1 -0
- package/dist/src/plugins/NodeFederationPlugin.d.mts +54 -0
- package/dist/src/plugins/NodeFederationPlugin.d.ts +33 -26
- package/dist/src/plugins/NodeFederationPlugin.js +72 -84
- package/dist/src/plugins/NodeFederationPlugin.js.map +1 -1
- package/dist/src/plugins/NodeFederationPlugin.mjs +73 -0
- package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.d.mts +15 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +12 -8
- package/dist/src/plugins/RemotePublicPathRuntimeModule.js +34 -35
- package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -1
- package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs +132 -0
- package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/StreamingTargetPlugin.d.mts +32 -0
- package/dist/src/plugins/StreamingTargetPlugin.d.ts +19 -16
- package/dist/src/plugins/StreamingTargetPlugin.js +43 -56
- package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -1
- package/dist/src/plugins/StreamingTargetPlugin.mjs +46 -0
- package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -0
- package/dist/src/plugins/UniversalFederationPlugin.d.mts +49 -0
- package/dist/src/plugins/UniversalFederationPlugin.d.ts +26 -23
- package/dist/src/plugins/UniversalFederationPlugin.js +62 -81
- package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -1
- package/dist/src/plugins/UniversalFederationPlugin.mjs +65 -0
- package/dist/src/plugins/UniversalFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.mts +9 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.ts +6 -3
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js +17 -17
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js.map +1 -1
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs +25 -0
- package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs.map +1 -0
- package/dist/src/plugins/webpackChunkUtilities.d.mts +55 -0
- package/dist/src/plugins/webpackChunkUtilities.d.ts +14 -9
- package/dist/src/plugins/webpackChunkUtilities.js +195 -257
- package/dist/src/plugins/webpackChunkUtilities.js.map +1 -1
- package/dist/src/plugins/webpackChunkUtilities.mjs +234 -0
- package/dist/src/plugins/webpackChunkUtilities.mjs.map +1 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.d.mts +7 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.d.ts +5 -2
- package/dist/src/recordDynamicRemoteEntryHashPlugin.js +24 -61
- package/dist/src/recordDynamicRemoteEntryHashPlugin.js.map +1 -1
- package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs +26 -0
- package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs.map +1 -0
- package/dist/src/runtimePlugin.d.mts +27 -0
- package/dist/src/runtimePlugin.d.ts +24 -19
- package/dist/src/runtimePlugin.js +157 -252
- package/dist/src/runtimePlugin.js.map +1 -1
- package/dist/src/runtimePlugin.mjs +169 -0
- package/dist/src/runtimePlugin.mjs.map +1 -0
- package/dist/src/types/index.d.mts +8 -0
- package/dist/src/types/index.d.ts +8 -3
- package/dist/src/types/index.js +1 -3
- package/dist/src/types/index.mjs +1 -0
- package/dist/src/utils/flush-chunks.d.mts +15 -0
- package/dist/src/utils/flush-chunks.d.ts +7 -3
- package/dist/src/utils/flush-chunks.js +90 -161
- package/dist/src/utils/flush-chunks.js.map +1 -1
- package/dist/src/utils/flush-chunks.mjs +102 -0
- package/dist/src/utils/flush-chunks.mjs.map +1 -0
- package/dist/src/utils/hot-reload.d.mts +16 -0
- package/dist/src/utils/hot-reload.d.ts +14 -10
- package/dist/src/utils/hot-reload.js +178 -264
- package/dist/src/utils/hot-reload.js.map +1 -1
- package/dist/src/utils/hot-reload.mjs +195 -0
- package/dist/src/utils/hot-reload.mjs.map +1 -0
- package/dist/src/utils/index.d.mts +3 -0
- package/dist/src/utils/index.d.ts +3 -2
- package/dist/src/utils/index.js +15 -19
- package/dist/src/utils/index.mjs +4 -0
- package/package.json +65 -15
- package/dist/jest.config.d.ts +0 -11
- package/dist/jest.config.js +0 -19
- package/dist/jest.config.js.map +0 -1
- package/dist/package.json +0 -82
- package/dist/src/index.js.map +0 -1
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/utils/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stratagies.js","
|
|
1
|
+
{"version":3,"file":"stratagies.js","names":[],"sources":["../../../src/filesystem/stratagies.ts"],"sourcesContent":["//@ts-nocheck\nexport async function fileSystemRunInContextStrategy(\n chunkId: string,\n rootOutputDir: string,\n remotes: Remotes,\n callback: CallbackFunction,\n) {\n const fs = require('fs');\n const path = require('path');\n const vm = require('vm');\n const filename = path.join(\n __dirname,\n rootOutputDir + __webpack_require__.u(chunkId),\n );\n if (fs.existsSync(filename)) {\n fs.readFile(filename, 'utf-8', (err: Error, content: string) => {\n if (err) {\n callback(err, null);\n return;\n }\n const chunk = {};\n try {\n vm.runInThisContext(\n '(function(exports, require, __dirname, __filename) {' +\n content +\n '\\n})',\n filename,\n )(chunk, require, path.dirname(filename), filename);\n callback(null, chunk);\n } catch (e) {\n console.log(\"'runInThisContext threw'\", e);\n callback(e as Error, null);\n }\n });\n } else {\n const err = new Error(`File ${filename} does not exist`);\n callback(err, null);\n }\n}\n\n// HttpEvalStrategy\nexport async function httpEvalStrategy(\n chunkName: string,\n remoteName: string,\n remotes: Remotes,\n callback: CallbackFunction,\n) {\n let url;\n try {\n url = new URL(chunkName, __webpack_require__.p);\n } catch (e) {\n console.error(\n 'module-federation: failed to construct absolute chunk path of',\n remoteName,\n 'for',\n chunkName,\n // e,\n );\n url = new URL(remotes[remoteName]);\n const getBasenameFromUrl = (url) => {\n const urlParts = url.split('/');\n return urlParts[urlParts.length - 1];\n };\n const fileToReplace = getBasenameFromUrl(url.pathname);\n url.pathname = url.pathname.replace(fileToReplace, chunkName);\n }\n\n const data = await fetch(url).then((res) => res.text());\n const chunk = {};\n try {\n const urlDirname = url.pathname.split('/').slice(0, -1).join('/');\n\n eval(\n '(function(exports, require, __dirname, __filename) {' + data + '\\n})',\n )(chunk, require, urlDirname, chunkName);\n callback(null, chunk);\n } catch (e: any) {\n callback(e, null);\n }\n}\n// Define the type for the remote servers object\ninterface Remotes {\n [key: string]: {\n entry: string;\n };\n}\n\n// Define the type for the callback function\ntype CallbackFunction = (error: Error | null, chunk?: any) => void;\n\n/**\n * HttpVmStrategy\n * This function is used to execute a chunk of code in a VM using HTTP or HTTPS based on the protocol.\n * @param {string} chunkName - The name of the chunk to be executed.\n * @param {string} remoteName - The name of the remote server.\n * @param {Remotes} remotes - An object containing the remote servers.\n * @param {CallbackFunction} callback - A callback function to be executed after the chunk is executed.\n */\nexport async function httpVmStrategy(\n chunkName: string,\n remoteName: string,\n remotes: Remotes,\n callback: CallbackFunction,\n): Promise<void> {\n const http = require('http') as typeof import('http');\n const https = require('https') as typeof import('https');\n const vm = require('vm') as typeof import('vm');\n const path = require('path') as typeof import('path');\n let url: URL;\n const globalThisVal = new Function('return globalThis')();\n\n try {\n url = new URL(chunkName, __webpack_require__.p);\n } catch (e) {\n console.error(\n 'module-federation: failed to construct absolute chunk path of',\n remoteName,\n 'for',\n chunkName,\n // e,\n );\n // search all instances to see if any have the remote\n const container = globalThisVal['__FEDERATION__']['__INSTANCES__'].find(\n (instance: any) => {\n if (!instance) return;\n if (!instance.moduleCache.has(remoteName)) return;\n const container = instance.moduleCache.get(remoteName);\n if (!container.remoteInfo) return;\n return container.remoteInfo.entry;\n },\n );\n\n if (!container) {\n throw new Error('Container not found');\n }\n\n url = new URL(container.moduleCache.get(remoteName).remoteInfo.entry);\n const fileToReplace = path.basename(url.pathname);\n url.pathname = url.pathname.replace(fileToReplace, chunkName);\n }\n const protocol = url.protocol === 'https:' ? https : http;\n const req = protocol.get(url.href, (res: import('http').IncomingMessage) => {\n let data = '';\n res.on('data', (chunk: Buffer) => {\n data += chunk.toString();\n });\n res.on('end', () => {\n const chunk = {};\n const urlDirname = url.pathname.split('/').slice(0, -1).join('/');\n try {\n vm.runInThisContext(\n `(function(exports, require, __dirname, __filename) {${data}\\n})`,\n chunkName,\n )(chunk, require, urlDirname, chunkName);\n callback(null, chunk);\n } catch (err) {\n callback(err, null);\n }\n });\n res.on('error', (err) => {\n callback(err, null);\n });\n });\n req.on('error', (err) => callback(err, null));\n}\n"],"mappings":";;;AACA,eAAsB,+BACpB,SACA,eACA,SACA,UACA;CACA,MAAM,KAAK,QAAQ,KAAK;CACxB,MAAM,OAAO,QAAQ,OAAO;CAC5B,MAAM,KAAK,QAAQ,KAAK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GACF,CACE,GAAG,UAAU,QAAQ,SAAS,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __require } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/filesystem/stratagies.ts
|
|
4
|
+
async function fileSystemRunInContextStrategy(chunkId, rootOutputDir, remotes, callback) {
|
|
5
|
+
const fs = __require("fs");
|
|
6
|
+
const path = __require("path");
|
|
7
|
+
const vm = __require("vm");
|
|
8
|
+
const filename = path.join(__dirname, rootOutputDir + __webpack_require__.u(chunkId));
|
|
9
|
+
if (fs.existsSync(filename)) fs.readFile(filename, "utf-8", (err, content) => {
|
|
10
|
+
if (err) {
|
|
11
|
+
callback(err, null);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const chunk = {};
|
|
15
|
+
try {
|
|
16
|
+
vm.runInThisContext("(function(exports, require, __dirname, __filename) {" + content + "\n})", filename)(chunk, __require, path.dirname(filename), filename);
|
|
17
|
+
callback(null, chunk);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.log("'runInThisContext threw'", e);
|
|
20
|
+
callback(e, null);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
else callback(/* @__PURE__ */ new Error(`File ${filename} does not exist`), null);
|
|
24
|
+
}
|
|
25
|
+
async function httpEvalStrategy(chunkName, remoteName, remotes, callback) {
|
|
26
|
+
let url;
|
|
27
|
+
try {
|
|
28
|
+
url = new URL(chunkName, __webpack_require__.p);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error("module-federation: failed to construct absolute chunk path of", remoteName, "for", chunkName);
|
|
31
|
+
url = new URL(remotes[remoteName]);
|
|
32
|
+
const getBasenameFromUrl = (url) => {
|
|
33
|
+
const urlParts = url.split("/");
|
|
34
|
+
return urlParts[urlParts.length - 1];
|
|
35
|
+
};
|
|
36
|
+
const fileToReplace = getBasenameFromUrl(url.pathname);
|
|
37
|
+
url.pathname = url.pathname.replace(fileToReplace, chunkName);
|
|
38
|
+
}
|
|
39
|
+
const data = await fetch(url).then((res) => res.text());
|
|
40
|
+
const chunk = {};
|
|
41
|
+
try {
|
|
42
|
+
const urlDirname = url.pathname.split("/").slice(0, -1).join("/");
|
|
43
|
+
eval("(function(exports, require, __dirname, __filename) {" + data + "\n})")(chunk, __require, urlDirname, chunkName);
|
|
44
|
+
callback(null, chunk);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
callback(e, null);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* HttpVmStrategy
|
|
51
|
+
* This function is used to execute a chunk of code in a VM using HTTP or HTTPS based on the protocol.
|
|
52
|
+
* @param {string} chunkName - The name of the chunk to be executed.
|
|
53
|
+
* @param {string} remoteName - The name of the remote server.
|
|
54
|
+
* @param {Remotes} remotes - An object containing the remote servers.
|
|
55
|
+
* @param {CallbackFunction} callback - A callback function to be executed after the chunk is executed.
|
|
56
|
+
*/
|
|
57
|
+
async function httpVmStrategy(chunkName, remoteName, remotes, callback) {
|
|
58
|
+
const http = __require("http");
|
|
59
|
+
const https = __require("https");
|
|
60
|
+
const vm = __require("vm");
|
|
61
|
+
const path = __require("path");
|
|
62
|
+
let url;
|
|
63
|
+
const globalThisVal = new Function("return globalThis")();
|
|
64
|
+
try {
|
|
65
|
+
url = new URL(chunkName, __webpack_require__.p);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error("module-federation: failed to construct absolute chunk path of", remoteName, "for", chunkName);
|
|
68
|
+
const container = globalThisVal["__FEDERATION__"]["__INSTANCES__"].find((instance) => {
|
|
69
|
+
if (!instance) return;
|
|
70
|
+
if (!instance.moduleCache.has(remoteName)) return;
|
|
71
|
+
const container = instance.moduleCache.get(remoteName);
|
|
72
|
+
if (!container.remoteInfo) return;
|
|
73
|
+
return container.remoteInfo.entry;
|
|
74
|
+
});
|
|
75
|
+
if (!container) throw new Error("Container not found");
|
|
76
|
+
url = new URL(container.moduleCache.get(remoteName).remoteInfo.entry);
|
|
77
|
+
const fileToReplace = path.basename(url.pathname);
|
|
78
|
+
url.pathname = url.pathname.replace(fileToReplace, chunkName);
|
|
79
|
+
}
|
|
80
|
+
(url.protocol === "https:" ? https : http).get(url.href, (res) => {
|
|
81
|
+
let data = "";
|
|
82
|
+
res.on("data", (chunk) => {
|
|
83
|
+
data += chunk.toString();
|
|
84
|
+
});
|
|
85
|
+
res.on("end", () => {
|
|
86
|
+
const chunk = {};
|
|
87
|
+
const urlDirname = url.pathname.split("/").slice(0, -1).join("/");
|
|
88
|
+
try {
|
|
89
|
+
vm.runInThisContext(`(function(exports, require, __dirname, __filename) {${data}\n})`, chunkName)(chunk, __require, urlDirname, chunkName);
|
|
90
|
+
callback(null, chunk);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
callback(err, null);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
res.on("error", (err) => {
|
|
96
|
+
callback(err, null);
|
|
97
|
+
});
|
|
98
|
+
}).on("error", (err) => callback(err, null));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { fileSystemRunInContextStrategy, httpEvalStrategy, httpVmStrategy };
|
|
103
|
+
//# sourceMappingURL=stratagies.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stratagies.mjs","names":[],"sources":["../../../src/filesystem/stratagies.ts"],"sourcesContent":["//@ts-nocheck\nexport async function fileSystemRunInContextStrategy(\n chunkId: string,\n rootOutputDir: string,\n remotes: Remotes,\n callback: CallbackFunction,\n) {\n const fs = require('fs');\n const path = require('path');\n const vm = require('vm');\n const filename = path.join(\n __dirname,\n rootOutputDir + __webpack_require__.u(chunkId),\n );\n if (fs.existsSync(filename)) {\n fs.readFile(filename, 'utf-8', (err: Error, content: string) => {\n if (err) {\n callback(err, null);\n return;\n }\n const chunk = {};\n try {\n vm.runInThisContext(\n '(function(exports, require, __dirname, __filename) {' +\n content +\n '\\n})',\n filename,\n )(chunk, require, path.dirname(filename), filename);\n callback(null, chunk);\n } catch (e) {\n console.log(\"'runInThisContext threw'\", e);\n callback(e as Error, null);\n }\n });\n } else {\n const err = new Error(`File ${filename} does not exist`);\n callback(err, null);\n }\n}\n\n// HttpEvalStrategy\nexport async function httpEvalStrategy(\n chunkName: string,\n remoteName: string,\n remotes: Remotes,\n callback: CallbackFunction,\n) {\n let url;\n try {\n url = new URL(chunkName, __webpack_require__.p);\n } catch (e) {\n console.error(\n 'module-federation: failed to construct absolute chunk path of',\n remoteName,\n 'for',\n chunkName,\n // e,\n );\n url = new URL(remotes[remoteName]);\n const getBasenameFromUrl = (url) => {\n const urlParts = url.split('/');\n return urlParts[urlParts.length - 1];\n };\n const fileToReplace = getBasenameFromUrl(url.pathname);\n url.pathname = url.pathname.replace(fileToReplace, chunkName);\n }\n\n const data = await fetch(url).then((res) => res.text());\n const chunk = {};\n try {\n const urlDirname = url.pathname.split('/').slice(0, -1).join('/');\n\n eval(\n '(function(exports, require, __dirname, __filename) {' + data + '\\n})',\n )(chunk, require, urlDirname, chunkName);\n callback(null, chunk);\n } catch (e: any) {\n callback(e, null);\n }\n}\n// Define the type for the remote servers object\ninterface Remotes {\n [key: string]: {\n entry: string;\n };\n}\n\n// Define the type for the callback function\ntype CallbackFunction = (error: Error | null, chunk?: any) => void;\n\n/**\n * HttpVmStrategy\n * This function is used to execute a chunk of code in a VM using HTTP or HTTPS based on the protocol.\n * @param {string} chunkName - The name of the chunk to be executed.\n * @param {string} remoteName - The name of the remote server.\n * @param {Remotes} remotes - An object containing the remote servers.\n * @param {CallbackFunction} callback - A callback function to be executed after the chunk is executed.\n */\nexport async function httpVmStrategy(\n chunkName: string,\n remoteName: string,\n remotes: Remotes,\n callback: CallbackFunction,\n): Promise<void> {\n const http = require('http') as typeof import('http');\n const https = require('https') as typeof import('https');\n const vm = require('vm') as typeof import('vm');\n const path = require('path') as typeof import('path');\n let url: URL;\n const globalThisVal = new Function('return globalThis')();\n\n try {\n url = new URL(chunkName, __webpack_require__.p);\n } catch (e) {\n console.error(\n 'module-federation: failed to construct absolute chunk path of',\n remoteName,\n 'for',\n chunkName,\n // e,\n );\n // search all instances to see if any have the remote\n const container = globalThisVal['__FEDERATION__']['__INSTANCES__'].find(\n (instance: any) => {\n if (!instance) return;\n if (!instance.moduleCache.has(remoteName)) return;\n const container = instance.moduleCache.get(remoteName);\n if (!container.remoteInfo) return;\n return container.remoteInfo.entry;\n },\n );\n\n if (!container) {\n throw new Error('Container not found');\n }\n\n url = new URL(container.moduleCache.get(remoteName).remoteInfo.entry);\n const fileToReplace = path.basename(url.pathname);\n url.pathname = url.pathname.replace(fileToReplace, chunkName);\n }\n const protocol = url.protocol === 'https:' ? https : http;\n const req = protocol.get(url.href, (res: import('http').IncomingMessage) => {\n let data = '';\n res.on('data', (chunk: Buffer) => {\n data += chunk.toString();\n });\n res.on('end', () => {\n const chunk = {};\n const urlDirname = url.pathname.split('/').slice(0, -1).join('/');\n try {\n vm.runInThisContext(\n `(function(exports, require, __dirname, __filename) {${data}\\n})`,\n chunkName,\n )(chunk, require, urlDirname, chunkName);\n callback(null, chunk);\n } catch (err) {\n callback(err, null);\n }\n });\n res.on('error', (err) => {\n callback(err, null);\n });\n });\n req.on('error', (err) => callback(err, null));\n}\n"],"mappings":";;;AACA,eAAsB,+BACpB,SACA,eACA,SACA,UACA;CACA,MAAM,eAAa,KAAK;CACxB,MAAM,iBAAe,OAAO;CAC5B,MAAM,eAAa,KAAK;CACxB,MAAM,WAAW,KAAK,KACpB,WACA,gBAAgB,oBAAoB,EAAE,QAAQ,CAC/C;AACD,KAAI,GAAG,WAAW,SAAS,CACzB,IAAG,SAAS,UAAU,UAAU,KAAY,YAAoB;AAC9D,MAAI,KAAK;AACP,YAAS,KAAK,KAAK;AACnB;;EAEF,MAAM,QAAQ,EAAE;AAChB,MAAI;AACF,MAAG,iBACD,yDACE,UACA,QACF,SACD,CAAC,kBAAgB,KAAK,QAAQ,SAAS,EAAE,SAAS;AACnD,YAAS,MA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C,SAAU;AACf,OAAI,CAAC,SAAS,YAAY,IAAI,WAAW,CAAE;GAC3C,MAAM,YAAY,SAAS,YAAY,IAAI,WAAW;AACtD,OAAI,CAAC,UAAU,WAAY;AAC3B,UAAO,UAAU,WAAW;IAE/B;AAED,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,sBAAsB;AAGxC,QAAM,IAAI,IAAI,UAAU,YAAY,IAAI,WAAW,CAAC,WAAW,MAAM;EACrE,MAAM,gBAAgB,KAAK,SAAS,IAAI,SAAS;AACjD,MAAI,WAAW,IAAI,SAAS,QAAQ,eAAe,UAAU;;AAyB/D,EAvBiB,IAAI,aAAa,WAAW,QAAQ,MAChC,IAAI,IAAI,OAAO,QAAwC;EAC1E,IAAI,OAAO;AACX,MAAI,GAAG,SAAS,UAAkB;AAChC,WAAQ,MAAM,UAAU;IACxB;AACF,MAAI,GAAG,aAAa;GAClB,MAAM,QAAQ,EAAE;GAChB,MAAM,aAAa,IAAI,SAAS,MAAM,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,IAAI;AACjE,OAAI;AACF,OAAG,iBACD,uDAAuD,KAAK,OAC5D,UACD,CAAC,kBAAgB,YAAY,UAAU;AACxC,aAAS,MAAM,MAAM;YACd,KAAK;AACZ,aAAS,KAAK,KAAK;;IAErB;AACF,MAAI,GAAG,UAAU,QAAQ;AACvB,YAAS,KAAK,KAAK;IACnB;GACF,CACE,GAAG,UAAU,QAAQ,SAAS,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import StreamingTargetPlugin from "./plugins/StreamingTargetPlugin.mjs";
|
|
2
|
+
import NodeFederationPlugin from "./plugins/NodeFederationPlugin.mjs";
|
|
3
|
+
import UniversalFederationPlugin from "./plugins/UniversalFederationPlugin.mjs";
|
|
4
|
+
import ChunkCorrelationPlugin from "./plugins/ChunkCorrelationPlugin.mjs";
|
|
5
|
+
import AutoPublicPathRuntimeModule from "./plugins/RemotePublicPathRuntimeModule.mjs";
|
|
6
|
+
import EntryChunkTrackerPlugin from "./plugins/EntryChunkTrackerPlugin.mjs";
|
|
7
|
+
import UniverseEntryChunkTrackerPlugin from "./plugins/UniverseEntryChunkTrackerPlugin.mjs";
|
|
8
|
+
export { ChunkCorrelationPlugin, EntryChunkTrackerPlugin, NodeFederationPlugin, AutoPublicPathRuntimeModule as RemotePublicPathPlugin, StreamingTargetPlugin, UniversalFederationPlugin, UniverseEntryChunkTrackerPlugin };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import StreamingTargetPlugin from "./plugins/StreamingTargetPlugin.js";
|
|
2
|
+
import NodeFederationPlugin from "./plugins/NodeFederationPlugin.js";
|
|
3
|
+
import UniversalFederationPlugin from "./plugins/UniversalFederationPlugin.js";
|
|
4
|
+
import ChunkCorrelationPlugin from "./plugins/ChunkCorrelationPlugin.js";
|
|
5
|
+
import AutoPublicPathRuntimeModule from "./plugins/RemotePublicPathRuntimeModule.js";
|
|
6
|
+
import EntryChunkTrackerPlugin from "./plugins/EntryChunkTrackerPlugin.js";
|
|
7
|
+
import UniverseEntryChunkTrackerPlugin from "./plugins/UniverseEntryChunkTrackerPlugin.js";
|
|
8
|
+
export { ChunkCorrelationPlugin, EntryChunkTrackerPlugin, NodeFederationPlugin, AutoPublicPathRuntimeModule as RemotePublicPathPlugin, StreamingTargetPlugin, UniversalFederationPlugin, UniverseEntryChunkTrackerPlugin };
|
package/dist/src/index.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Object.defineProperty(exports, "RemotePublicPathPlugin", { enumerable: true, get: function () { return __importDefault(RemotePublicPathRuntimeModule_1).default; } });
|
|
18
|
-
var EntryChunkTrackerPlugin_1 = require("./plugins/EntryChunkTrackerPlugin");
|
|
19
|
-
Object.defineProperty(exports, "EntryChunkTrackerPlugin", { enumerable: true, get: function () { return __importDefault(EntryChunkTrackerPlugin_1).default; } });
|
|
20
|
-
var UniverseEntryChunkTrackerPlugin_1 = require("./plugins/UniverseEntryChunkTrackerPlugin");
|
|
21
|
-
Object.defineProperty(exports, "UniverseEntryChunkTrackerPlugin", { enumerable: true, get: function () { return __importDefault(UniverseEntryChunkTrackerPlugin_1).default; } });
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_src_plugins_RemotePublicPathRuntimeModule = require('./plugins/RemotePublicPathRuntimeModule.js');
|
|
3
|
+
const require_src_plugins_StreamingTargetPlugin = require('./plugins/StreamingTargetPlugin.js');
|
|
4
|
+
const require_src_plugins_EntryChunkTrackerPlugin = require('./plugins/EntryChunkTrackerPlugin.js');
|
|
5
|
+
const require_src_plugins_NodeFederationPlugin = require('./plugins/NodeFederationPlugin.js');
|
|
6
|
+
const require_src_plugins_UniversalFederationPlugin = require('./plugins/UniversalFederationPlugin.js');
|
|
7
|
+
const require_src_plugins_ChunkCorrelationPlugin = require('./plugins/ChunkCorrelationPlugin.js');
|
|
8
|
+
const require_src_plugins_UniverseEntryChunkTrackerPlugin = require('./plugins/UniverseEntryChunkTrackerPlugin.js');
|
|
9
|
+
|
|
10
|
+
exports.ChunkCorrelationPlugin = require_src_plugins_ChunkCorrelationPlugin.default;
|
|
11
|
+
exports.EntryChunkTrackerPlugin = require_src_plugins_EntryChunkTrackerPlugin.default;
|
|
12
|
+
exports.NodeFederationPlugin = require_src_plugins_NodeFederationPlugin.default;
|
|
13
|
+
exports.RemotePublicPathPlugin = require_src_plugins_RemotePublicPathRuntimeModule.default;
|
|
14
|
+
exports.StreamingTargetPlugin = require_src_plugins_StreamingTargetPlugin.default;
|
|
15
|
+
exports.UniversalFederationPlugin = require_src_plugins_UniversalFederationPlugin.default;
|
|
16
|
+
exports.UniverseEntryChunkTrackerPlugin = require_src_plugins_UniverseEntryChunkTrackerPlugin.default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AutoPublicPathRuntimeModule from "./plugins/RemotePublicPathRuntimeModule.mjs";
|
|
2
|
+
import StreamingTargetPlugin from "./plugins/StreamingTargetPlugin.mjs";
|
|
3
|
+
import EntryChunkTrackerPlugin from "./plugins/EntryChunkTrackerPlugin.mjs";
|
|
4
|
+
import NodeFederationPlugin from "./plugins/NodeFederationPlugin.mjs";
|
|
5
|
+
import UniversalFederationPlugin from "./plugins/UniversalFederationPlugin.mjs";
|
|
6
|
+
import ChunkCorrelationPlugin from "./plugins/ChunkCorrelationPlugin.mjs";
|
|
7
|
+
import UniverseEntryChunkTrackerPlugin from "./plugins/UniverseEntryChunkTrackerPlugin.mjs";
|
|
8
|
+
|
|
9
|
+
export { ChunkCorrelationPlugin, EntryChunkTrackerPlugin, NodeFederationPlugin, AutoPublicPathRuntimeModule as RemotePublicPathPlugin, StreamingTargetPlugin, UniversalFederationPlugin, UniverseEntryChunkTrackerPlugin };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Compiler } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/AutomaticPublicPathPlugin.d.ts
|
|
4
|
+
interface PluginOptions {}
|
|
5
|
+
declare class RemotePublicPathPlugin {
|
|
6
|
+
private options?;
|
|
7
|
+
constructor(options?: PluginOptions);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { RemotePublicPathPlugin as default };
|
|
12
|
+
//# sourceMappingURL=AutomaticPublicPathPlugin.d.mts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Compiler } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/AutomaticPublicPathPlugin.d.ts
|
|
4
|
+
interface PluginOptions {}
|
|
4
5
|
declare class RemotePublicPathPlugin {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
private options?;
|
|
7
|
+
constructor(options?: PluginOptions);
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
+
export = RemotePublicPathPlugin;
|
|
11
|
+
//# sourceMappingURL=AutomaticPublicPathPlugin.d.ts.map
|
|
@@ -1,38 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_src_plugins_RemotePublicPathRuntimeModule = require('./RemotePublicPathRuntimeModule.js');
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/AutomaticPublicPathPlugin.ts
|
|
5
|
+
var RemotePublicPathPlugin = class {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
apply(compiler) {
|
|
10
|
+
const { RuntimeGlobals } = compiler.webpack;
|
|
11
|
+
compiler.hooks.thisCompilation.tap("RemotePublicPathPlugin", (compilation) => {
|
|
12
|
+
compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.publicPath).tap("RuntimePlugin", (chunk, set) => {
|
|
13
|
+
const { outputOptions } = compilation;
|
|
14
|
+
const { publicPath: globalPublicPath, scriptType } = outputOptions;
|
|
15
|
+
const entryOptions = chunk.getEntryOptions();
|
|
16
|
+
const publicPath = entryOptions && entryOptions.publicPath !== void 0 ? entryOptions.publicPath : globalPublicPath;
|
|
17
|
+
const module = new require_src_plugins_RemotePublicPathRuntimeModule.default(this.options);
|
|
18
|
+
if (publicPath === "auto" && scriptType !== "module") set.add(RuntimeGlobals.global);
|
|
19
|
+
else if (typeof publicPath !== "string" || /\[(full)?hash\]/.test(publicPath)) module.fullHash = true;
|
|
20
|
+
compilation.addRuntimeModule(chunk, module);
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
4
25
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class RemotePublicPathPlugin {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.options = options;
|
|
10
|
-
}
|
|
11
|
-
apply(compiler) {
|
|
12
|
-
const { RuntimeGlobals } = compiler.webpack;
|
|
13
|
-
compiler.hooks.thisCompilation.tap('RemotePublicPathPlugin', (compilation) => {
|
|
14
|
-
compilation.hooks.runtimeRequirementInTree
|
|
15
|
-
.for(RuntimeGlobals.publicPath)
|
|
16
|
-
.tap('RuntimePlugin', (chunk, set) => {
|
|
17
|
-
const { outputOptions } = compilation;
|
|
18
|
-
const { publicPath: globalPublicPath, scriptType } = outputOptions;
|
|
19
|
-
const entryOptions = chunk.getEntryOptions();
|
|
20
|
-
const publicPath = entryOptions && entryOptions.publicPath !== undefined
|
|
21
|
-
? entryOptions.publicPath
|
|
22
|
-
: globalPublicPath;
|
|
23
|
-
const module = new RemotePublicPathRuntimeModule_1.default(this.options);
|
|
24
|
-
if (publicPath === 'auto' && scriptType !== 'module') {
|
|
25
|
-
set.add(RuntimeGlobals.global);
|
|
26
|
-
}
|
|
27
|
-
else if (typeof publicPath !== 'string' ||
|
|
28
|
-
/\[(full)?hash\]/.test(publicPath)) {
|
|
29
|
-
module.fullHash = true;
|
|
30
|
-
}
|
|
31
|
-
compilation.addRuntimeModule(chunk, module);
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
37
28
|
exports.default = RemotePublicPathPlugin;
|
|
38
29
|
//# sourceMappingURL=AutomaticPublicPathPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutomaticPublicPathPlugin.js","
|
|
1
|
+
{"version":3,"file":"AutomaticPublicPathPlugin.js","names":["RemotePublicPathRuntimeModule"],"sources":["../../../src/plugins/AutomaticPublicPathPlugin.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\n\nimport RemotePublicPathRuntimeModule from './RemotePublicPathRuntimeModule';\n\ninterface PluginOptions {}\n\nclass RemotePublicPathPlugin {\n private options?: PluginOptions;\n\n constructor(options?: PluginOptions) {\n this.options = options;\n }\n\n apply(compiler: Compiler) {\n const { RuntimeGlobals } = compiler.webpack;\n compiler.hooks.thisCompilation.tap(\n 'RemotePublicPathPlugin',\n (compilation) => {\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.publicPath)\n .tap('RuntimePlugin', (chunk, set) => {\n const { outputOptions } = compilation;\n const { publicPath: globalPublicPath, scriptType } = outputOptions;\n const entryOptions = chunk.getEntryOptions();\n const publicPath =\n entryOptions && entryOptions.publicPath !== undefined\n ? entryOptions.publicPath\n : globalPublicPath;\n\n const module = new RemotePublicPathRuntimeModule(this.options);\n if (publicPath === 'auto' && scriptType !== 'module') {\n set.add(RuntimeGlobals.global);\n } else if (\n typeof publicPath !== 'string' ||\n /\\[(full)?hash\\]/.test(publicPath)\n ) {\n module.fullHash = true;\n }\n\n compilation.addRuntimeModule(chunk, module);\n return true;\n });\n },\n );\n }\n}\n\nexport default RemotePublicPathPlugin;\n"],"mappings":";;;;AAMA,IAAM,yBAAN,MAA6B;CAG3B,YAAY,SAAyB;AACnC,OAAK,UAAU;;CAGjB,MAAM,UAAoB;EACxB,MAAM,EAAE,mBAAmB,SAAS;AACpC,WAAS,MAAM,gBAAgB,IAC7B,2BACC,gBAAgB;AACf,eAAY,MAAM,yBACf,IAAI,eAAe,WAAW,CAC9B,IAAI,kBAAkB,OAAO,QAAQ;IACpC,MAAM,EAAE,kBAAkB;IAC1B,MAAM,EAAE,YAAY,kBAAkB,eAAe;IACrD,MAAM,eAAe,MAAM,iBAAiB;IAC5C,MAAM,aACJ,gBAAgB,aAAa,eAAe,SACxC,aAAa,aACb;IAEN,MAAM,SAAS,IAAIA,0DAA8B,KAAK,QAAQ;AAC9D,QAAI,eAAe,UAAU,eAAe,SAC1C,KAAI,IAAI,eAAe,OAAO;aAE9B,OAAO,eAAe,YACtB,kBAAkB,KAAK,WAAW,CAElC,QAAO,WAAW;AAGpB,gBAAY,iBAAiB,OAAO,OAAO;AAC3C,WAAO;KACP;IAEP"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import AutoPublicPathRuntimeModule from "./RemotePublicPathRuntimeModule.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/AutomaticPublicPathPlugin.ts
|
|
4
|
+
var RemotePublicPathPlugin = class {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
const { RuntimeGlobals } = compiler.webpack;
|
|
10
|
+
compiler.hooks.thisCompilation.tap("RemotePublicPathPlugin", (compilation) => {
|
|
11
|
+
compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.publicPath).tap("RuntimePlugin", (chunk, set) => {
|
|
12
|
+
const { outputOptions } = compilation;
|
|
13
|
+
const { publicPath: globalPublicPath, scriptType } = outputOptions;
|
|
14
|
+
const entryOptions = chunk.getEntryOptions();
|
|
15
|
+
const publicPath = entryOptions && entryOptions.publicPath !== void 0 ? entryOptions.publicPath : globalPublicPath;
|
|
16
|
+
const module = new AutoPublicPathRuntimeModule(this.options);
|
|
17
|
+
if (publicPath === "auto" && scriptType !== "module") set.add(RuntimeGlobals.global);
|
|
18
|
+
else if (typeof publicPath !== "string" || /\[(full)?hash\]/.test(publicPath)) module.fullHash = true;
|
|
19
|
+
compilation.addRuntimeModule(chunk, module);
|
|
20
|
+
return true;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RemotePublicPathPlugin as default };
|
|
28
|
+
//# sourceMappingURL=AutomaticPublicPathPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutomaticPublicPathPlugin.mjs","names":["RemotePublicPathRuntimeModule"],"sources":["../../../src/plugins/AutomaticPublicPathPlugin.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\n\nimport RemotePublicPathRuntimeModule from './RemotePublicPathRuntimeModule';\n\ninterface PluginOptions {}\n\nclass RemotePublicPathPlugin {\n private options?: PluginOptions;\n\n constructor(options?: PluginOptions) {\n this.options = options;\n }\n\n apply(compiler: Compiler) {\n const { RuntimeGlobals } = compiler.webpack;\n compiler.hooks.thisCompilation.tap(\n 'RemotePublicPathPlugin',\n (compilation) => {\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.publicPath)\n .tap('RuntimePlugin', (chunk, set) => {\n const { outputOptions } = compilation;\n const { publicPath: globalPublicPath, scriptType } = outputOptions;\n const entryOptions = chunk.getEntryOptions();\n const publicPath =\n entryOptions && entryOptions.publicPath !== undefined\n ? entryOptions.publicPath\n : globalPublicPath;\n\n const module = new RemotePublicPathRuntimeModule(this.options);\n if (publicPath === 'auto' && scriptType !== 'module') {\n set.add(RuntimeGlobals.global);\n } else if (\n typeof publicPath !== 'string' ||\n /\\[(full)?hash\\]/.test(publicPath)\n ) {\n module.fullHash = true;\n }\n\n compilation.addRuntimeModule(chunk, module);\n return true;\n });\n },\n );\n }\n}\n\nexport default RemotePublicPathPlugin;\n"],"mappings":";;;AAMA,IAAM,yBAAN,MAA6B;CAG3B,YAAY,SAAyB;AACnC,OAAK,UAAU;;CAGjB,MAAM,UAAoB;EACxB,MAAM,EAAE,mBAAmB,SAAS;AACpC,WAAS,MAAM,gBAAgB,IAC7B,2BACC,gBAAgB;AACf,eAAY,MAAM,yBACf,IAAI,eAAe,WAAW,CAC9B,IAAI,kBAAkB,OAAO,QAAQ;IACpC,MAAM,EAAE,kBAAkB;IAC1B,MAAM,EAAE,YAAY,kBAAkB,eAAe;IACrD,MAAM,eAAe,MAAM,iBAAiB;IAC5C,MAAM,aACJ,gBAAgB,aAAa,eAAe,SACxC,aAAa,aACb;IAEN,MAAM,SAAS,IAAIA,4BAA8B,KAAK,QAAQ;AAC9D,QAAI,eAAe,UAAU,eAAe,SAC1C,KAAI,IAAI,eAAe,OAAO;aAE9B,OAAO,eAAe,YACtB,kBAAkB,KAAK,WAAW,CAElC,QAAO,WAAW;AAGpB,gBAAY,iBAAiB,OAAO,OAAO;AAC3C,WAAO;KACP;IAEP"}
|
|
@@ -1,61 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Writes relevant federation stats to a file for further consumption.
|
|
8
|
-
*/
|
|
9
|
-
declare class FederationStatsPlugin {
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {FederationStatsPluginOptions} options
|
|
13
|
-
*/
|
|
14
|
-
constructor(options: FederationStatsPluginOptions);
|
|
15
|
-
_options: FederationStatsPluginOptions;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {import("webpack").Compiler} compiler
|
|
19
|
-
*/
|
|
20
|
-
apply(compiler: import("webpack").Compiler): void;
|
|
21
|
-
}
|
|
22
|
-
declare namespace FederationStatsPlugin {
|
|
23
|
-
export { WebpackStats, WebpackStatsChunk, WebpackStatsModule, SharedDependency, SharedModule, Exposed, FederatedContainer, FederatedStats, FederationStatsPluginOptions };
|
|
24
|
-
}
|
|
25
|
-
type WebpackStats = any;
|
|
26
|
-
type WebpackStatsChunk = any;
|
|
27
|
-
type WebpackStatsModule = any;
|
|
28
|
-
type SharedDependency = {
|
|
29
|
-
shareScope: string;
|
|
30
|
-
shareKey: string;
|
|
31
|
-
requiredVersion: string;
|
|
32
|
-
strictVersion: boolean;
|
|
33
|
-
singleton: boolean;
|
|
34
|
-
eager: boolean;
|
|
35
|
-
};
|
|
36
|
-
type SharedModule = {
|
|
37
|
-
chunks: string[];
|
|
38
|
-
provides: SharedDependency[];
|
|
39
|
-
};
|
|
40
|
-
type Exposed = {
|
|
41
|
-
chunks: string[];
|
|
42
|
-
sharedModules: SharedModule[];
|
|
43
|
-
};
|
|
44
|
-
type FederatedContainer = {
|
|
45
|
-
remote: string;
|
|
46
|
-
entry: string;
|
|
47
|
-
sharedModules: SharedModule[];
|
|
48
|
-
exposes: {
|
|
49
|
-
[key: string]: Exposed;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
type FederatedStats = {
|
|
53
|
-
sharedModules: SharedModule[];
|
|
54
|
-
federatedModules: FederatedContainer[];
|
|
55
|
-
};
|
|
56
|
-
type FederationStatsPluginOptions = {
|
|
57
|
-
/**
|
|
58
|
-
* The filename or an array of filenames in the `output.path` directory to write stats to.
|
|
59
|
-
*/
|
|
60
|
-
filename: string | string[];
|
|
61
|
-
};
|
|
1
|
+
//#region src/plugins/ChunkCorrelationPlugin.d.ts
|
|
2
|
+
declare const ChunkCorrelationPlugin: any;
|
|
3
|
+
export = ChunkCorrelationPlugin;
|
|
4
|
+
//# sourceMappingURL=ChunkCorrelationPlugin.d.ts.map
|