@bleedingdev/mf-webpack-bundler-runtime 2.9.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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  5. package/dist/attachShareScopeMap.cjs +11 -0
  6. package/dist/attachShareScopeMap.cjs.map +1 -0
  7. package/dist/attachShareScopeMap.d.ts +7 -0
  8. package/dist/attachShareScopeMap.js +10 -0
  9. package/dist/attachShareScopeMap.js.map +1 -0
  10. package/dist/bundler.cjs +18 -0
  11. package/dist/bundler.d.ts +4 -0
  12. package/dist/bundler.js +4 -0
  13. package/dist/constant.cjs +8 -0
  14. package/dist/constant.cjs.map +1 -0
  15. package/dist/constant.d.ts +5 -0
  16. package/dist/constant.js +6 -0
  17. package/dist/constant.js.map +1 -0
  18. package/dist/consumes.cjs +68 -0
  19. package/dist/consumes.cjs.map +1 -0
  20. package/dist/consumes.js +68 -0
  21. package/dist/consumes.js.map +1 -0
  22. package/dist/error-codes/dist/error-codes.cjs +7 -0
  23. package/dist/error-codes/dist/error-codes.cjs.map +1 -0
  24. package/dist/error-codes/dist/error-codes.js +6 -0
  25. package/dist/error-codes/dist/error-codes.js.map +1 -0
  26. package/dist/error-codes/dist/getShortErrorMsg.cjs +16 -0
  27. package/dist/error-codes/dist/getShortErrorMsg.cjs.map +1 -0
  28. package/dist/error-codes/dist/getShortErrorMsg.js +15 -0
  29. package/dist/error-codes/dist/getShortErrorMsg.js.map +1 -0
  30. package/dist/getSharedFallbackGetter.cjs +27 -0
  31. package/dist/getSharedFallbackGetter.cjs.map +1 -0
  32. package/dist/getSharedFallbackGetter.js +26 -0
  33. package/dist/getSharedFallbackGetter.js.map +1 -0
  34. package/dist/getUsedExports.cjs +11 -0
  35. package/dist/getUsedExports.cjs.map +1 -0
  36. package/dist/getUsedExports.js +10 -0
  37. package/dist/getUsedExports.js.map +1 -0
  38. package/dist/index.cjs +52 -0
  39. package/dist/index.cjs.map +1 -0
  40. package/dist/index.d.ts +24 -0
  41. package/dist/index.js +38 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/init.cjs +85 -0
  44. package/dist/init.cjs.map +1 -0
  45. package/dist/init.js +83 -0
  46. package/dist/init.js.map +1 -0
  47. package/dist/initContainerEntry.cjs +42 -0
  48. package/dist/initContainerEntry.cjs.map +1 -0
  49. package/dist/initContainerEntry.d.ts +7 -0
  50. package/dist/initContainerEntry.js +41 -0
  51. package/dist/initContainerEntry.js.map +1 -0
  52. package/dist/initializeSharing.cjs +61 -0
  53. package/dist/initializeSharing.cjs.map +1 -0
  54. package/dist/initializeSharing.d.ts +13 -0
  55. package/dist/initializeSharing.js +61 -0
  56. package/dist/initializeSharing.js.map +1 -0
  57. package/dist/installInitialConsumes.cjs +75 -0
  58. package/dist/installInitialConsumes.cjs.map +1 -0
  59. package/dist/installInitialConsumes.js +75 -0
  60. package/dist/installInitialConsumes.js.map +1 -0
  61. package/dist/remotes.cjs +74 -0
  62. package/dist/remotes.cjs.map +1 -0
  63. package/dist/remotes.js +73 -0
  64. package/dist/remotes.js.map +1 -0
  65. package/dist/sdk/dist/types/plugins/ModuleFederationPlugin.d.ts +11 -0
  66. package/dist/types.d.ts +201 -0
  67. package/dist/updateOptions.cjs +112 -0
  68. package/dist/updateOptions.cjs.map +1 -0
  69. package/dist/updateOptions.js +110 -0
  70. package/dist/updateOptions.js.map +1 -0
  71. package/package.json +78 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installInitialConsumes.cjs","names":["getUsedExports"],"sources":["../src/installInitialConsumes.ts"],"sourcesContent":["import { getUsedExports } from './getUsedExports';\nimport {\n HandleInitialConsumesOptions,\n InstallInitialConsumesOptions,\n} from './types';\nimport type { Shared } from '@module-federation/runtime/types';\nimport { updateConsumeOptions } from './updateOptions';\n\nfunction handleInitialConsumes(options: HandleInitialConsumesOptions) {\n const { moduleId, moduleToHandlerMapping, webpackRequire, asyncLoad } =\n options;\n\n const federationInstance = webpackRequire.federation.instance;\n if (!federationInstance) {\n throw new Error('Federation instance not found!');\n }\n const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];\n\n try {\n const usedExports = getUsedExports(webpackRequire, shareKey);\n\n const customShareInfo: Partial<Shared> = { ...shareInfo };\n if (usedExports) {\n customShareInfo.treeShaking = {\n usedExports,\n useIn: [federationInstance.options.name],\n };\n }\n if (asyncLoad) {\n return federationInstance.loadShare(shareKey, {\n customShareInfo,\n context: {\n trigger: 'build',\n moduleId,\n },\n });\n }\n return federationInstance.loadShareSync(shareKey, {\n customShareInfo,\n context: {\n trigger: 'build',\n moduleId,\n },\n });\n } catch (err) {\n console.error(\n 'loadShareSync failed! The function should not be called unless you set \"eager:true\". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.',\n );\n console.error('The original error message is as follows: ');\n throw err;\n }\n}\n\nexport function installInitialConsumes(options: InstallInitialConsumesOptions) {\n updateConsumeOptions(options);\n\n const {\n moduleToHandlerMapping,\n webpackRequire,\n installedModules,\n initialConsumes,\n asyncLoad,\n } = options;\n\n const factoryIdSets: Array<\n [string | number, () => Promise<false | (() => unknown)> | (() => unknown)]\n > = [];\n initialConsumes.forEach((id) => {\n const factoryGetter = () =>\n handleInitialConsumes({\n moduleId: id,\n moduleToHandlerMapping,\n webpackRequire,\n asyncLoad,\n }) as Promise<false | (() => unknown)>;\n factoryIdSets.push([id, factoryGetter]);\n });\n\n const setModule = (\n id: string | number,\n factoryGetter: () => () => unknown,\n ) => {\n webpackRequire.m[id] = (module) => {\n // Handle scenario when module is used synchronously\n installedModules[id] = 0;\n delete webpackRequire.c[id];\n\n const factory = factoryGetter();\n if (typeof factory !== 'function') {\n throw new Error(\n `Shared module is not available for eager consumption: ${id}`,\n );\n }\n const result = factory();\n // Add layer property from shareConfig if available\n const { shareInfo } = moduleToHandlerMapping[id];\n if (\n shareInfo?.shareConfig?.layer &&\n result &&\n typeof result === 'object'\n ) {\n try {\n // Only set layer if it's not already defined or if it's undefined\n if (\n !result.hasOwnProperty('layer') ||\n (result as any).layer === undefined\n ) {\n (result as any).layer = shareInfo.shareConfig.layer;\n }\n } catch (e) {\n // Ignore if layer property is read-only\n }\n }\n module.exports = result;\n };\n };\n\n if (asyncLoad) {\n return Promise.all(\n factoryIdSets.map(async ([id, factoryGetter]) => {\n const result = await factoryGetter();\n setModule(id, () => result as () => unknown);\n }),\n );\n }\n factoryIdSets.forEach(([id, factoryGetter]) => {\n setModule(id, factoryGetter as () => () => unknown);\n });\n}\n"],"mappings":";;;;AAQA,SAAS,sBAAsB,SAAuC;CACpE,MAAM,EAAE,UAAU,wBAAwB,gBAAgB,cACxD;CAEF,MAAM,qBAAqB,eAAe,WAAW;AACrD,KAAI,CAAC,mBACH,OAAM,IAAI,MAAM,iCAAiC;CAEnD,MAAM,EAAE,UAAU,cAAc,uBAAuB;AAEvD,KAAI;EACF,MAAM,cAAcA,sCAAe,gBAAgB,SAAS;EAE5D,MAAM,kBAAmC,EAAE,GAAG,WAAW;AACzD,MAAI,YACF,iBAAgB,cAAc;GAC5B;GACA,OAAO,CAAC,mBAAmB,QAAQ,KAAK;GACzC;AAEH,MAAI,UACF,QAAO,mBAAmB,UAAU,UAAU;GAC5C;GACA,SAAS;IACP,SAAS;IACT;IACD;GACF,CAAC;AAEJ,SAAO,mBAAmB,cAAc,UAAU;GAChD;GACA,SAAS;IACP,SAAS;IACT;IACD;GACF,CAAC;UACK,KAAK;AACZ,UAAQ,MACN,iMACD;AACD,UAAQ,MAAM,6CAA6C;AAC3D,QAAM;;;AAIV,SAAgB,uBAAuB,SAAwC;AAC7E,4CAAqB,QAAQ;CAE7B,MAAM,EACJ,wBACA,gBACA,kBACA,iBACA,cACE;CAEJ,MAAM,gBAEF,EAAE;AACN,iBAAgB,SAAS,OAAO;EAC9B,MAAM,sBACJ,sBAAsB;GACpB,UAAU;GACV;GACA;GACA;GACD,CAAC;AACJ,gBAAc,KAAK,CAAC,IAAI,cAAc,CAAC;GACvC;CAEF,MAAM,aACJ,IACA,kBACG;AACH,iBAAe,EAAE,OAAO,WAAW;AAEjC,oBAAiB,MAAM;AACvB,UAAO,eAAe,EAAE;GAExB,MAAM,UAAU,eAAe;AAC/B,OAAI,OAAO,YAAY,WACrB,OAAM,IAAI,MACR,yDAAyD,KAC1D;GAEH,MAAM,SAAS,SAAS;GAExB,MAAM,EAAE,cAAc,uBAAuB;AAC7C,OACE,WAAW,aAAa,SACxB,UACA,OAAO,WAAW,SAElB,KAAI;AAEF,QACE,CAAC,OAAO,eAAe,QAAQ,IAC9B,OAAe,UAAU,OAE1B,CAAC,OAAe,QAAQ,UAAU,YAAY;YAEzC,GAAG;AAId,UAAO,UAAU;;;AAIrB,KAAI,UACF,QAAO,QAAQ,IACb,cAAc,IAAI,OAAO,CAAC,IAAI,mBAAmB;EAC/C,MAAM,SAAS,MAAM,eAAe;AACpC,YAAU,UAAU,OAAwB;GAC5C,CACH;AAEH,eAAc,SAAS,CAAC,IAAI,mBAAmB;AAC7C,YAAU,IAAI,cAAqC;GACnD"}
@@ -0,0 +1,75 @@
1
+ import { updateConsumeOptions } from "./updateOptions.js";
2
+ import { getUsedExports } from "./getUsedExports.js";
3
+
4
+ //#region src/installInitialConsumes.ts
5
+ function handleInitialConsumes(options) {
6
+ const { moduleId, moduleToHandlerMapping, webpackRequire, asyncLoad } = options;
7
+ const federationInstance = webpackRequire.federation.instance;
8
+ if (!federationInstance) throw new Error("Federation instance not found!");
9
+ const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
10
+ try {
11
+ const usedExports = getUsedExports(webpackRequire, shareKey);
12
+ const customShareInfo = { ...shareInfo };
13
+ if (usedExports) customShareInfo.treeShaking = {
14
+ usedExports,
15
+ useIn: [federationInstance.options.name]
16
+ };
17
+ if (asyncLoad) return federationInstance.loadShare(shareKey, {
18
+ customShareInfo,
19
+ context: {
20
+ trigger: "build",
21
+ moduleId
22
+ }
23
+ });
24
+ return federationInstance.loadShareSync(shareKey, {
25
+ customShareInfo,
26
+ context: {
27
+ trigger: "build",
28
+ moduleId
29
+ }
30
+ });
31
+ } catch (err) {
32
+ console.error("loadShareSync failed! The function should not be called unless you set \"eager:true\". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.");
33
+ console.error("The original error message is as follows: ");
34
+ throw err;
35
+ }
36
+ }
37
+ function installInitialConsumes(options) {
38
+ updateConsumeOptions(options);
39
+ const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes, asyncLoad } = options;
40
+ const factoryIdSets = [];
41
+ initialConsumes.forEach((id) => {
42
+ const factoryGetter = () => handleInitialConsumes({
43
+ moduleId: id,
44
+ moduleToHandlerMapping,
45
+ webpackRequire,
46
+ asyncLoad
47
+ });
48
+ factoryIdSets.push([id, factoryGetter]);
49
+ });
50
+ const setModule = (id, factoryGetter) => {
51
+ webpackRequire.m[id] = (module) => {
52
+ installedModules[id] = 0;
53
+ delete webpackRequire.c[id];
54
+ const factory = factoryGetter();
55
+ if (typeof factory !== "function") throw new Error(`Shared module is not available for eager consumption: ${id}`);
56
+ const result = factory();
57
+ const { shareInfo } = moduleToHandlerMapping[id];
58
+ if (shareInfo?.shareConfig?.layer && result && typeof result === "object") try {
59
+ if (!result.hasOwnProperty("layer") || result.layer === void 0) result.layer = shareInfo.shareConfig.layer;
60
+ } catch (e) {}
61
+ module.exports = result;
62
+ };
63
+ };
64
+ if (asyncLoad) return Promise.all(factoryIdSets.map(async ([id, factoryGetter]) => {
65
+ const result = await factoryGetter();
66
+ setModule(id, () => result);
67
+ }));
68
+ factoryIdSets.forEach(([id, factoryGetter]) => {
69
+ setModule(id, factoryGetter);
70
+ });
71
+ }
72
+
73
+ //#endregion
74
+ export { installInitialConsumes };
75
+ //# sourceMappingURL=installInitialConsumes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installInitialConsumes.js","names":[],"sources":["../src/installInitialConsumes.ts"],"sourcesContent":["import { getUsedExports } from './getUsedExports';\nimport {\n HandleInitialConsumesOptions,\n InstallInitialConsumesOptions,\n} from './types';\nimport type { Shared } from '@module-federation/runtime/types';\nimport { updateConsumeOptions } from './updateOptions';\n\nfunction handleInitialConsumes(options: HandleInitialConsumesOptions) {\n const { moduleId, moduleToHandlerMapping, webpackRequire, asyncLoad } =\n options;\n\n const federationInstance = webpackRequire.federation.instance;\n if (!federationInstance) {\n throw new Error('Federation instance not found!');\n }\n const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];\n\n try {\n const usedExports = getUsedExports(webpackRequire, shareKey);\n\n const customShareInfo: Partial<Shared> = { ...shareInfo };\n if (usedExports) {\n customShareInfo.treeShaking = {\n usedExports,\n useIn: [federationInstance.options.name],\n };\n }\n if (asyncLoad) {\n return federationInstance.loadShare(shareKey, {\n customShareInfo,\n context: {\n trigger: 'build',\n moduleId,\n },\n });\n }\n return federationInstance.loadShareSync(shareKey, {\n customShareInfo,\n context: {\n trigger: 'build',\n moduleId,\n },\n });\n } catch (err) {\n console.error(\n 'loadShareSync failed! The function should not be called unless you set \"eager:true\". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.',\n );\n console.error('The original error message is as follows: ');\n throw err;\n }\n}\n\nexport function installInitialConsumes(options: InstallInitialConsumesOptions) {\n updateConsumeOptions(options);\n\n const {\n moduleToHandlerMapping,\n webpackRequire,\n installedModules,\n initialConsumes,\n asyncLoad,\n } = options;\n\n const factoryIdSets: Array<\n [string | number, () => Promise<false | (() => unknown)> | (() => unknown)]\n > = [];\n initialConsumes.forEach((id) => {\n const factoryGetter = () =>\n handleInitialConsumes({\n moduleId: id,\n moduleToHandlerMapping,\n webpackRequire,\n asyncLoad,\n }) as Promise<false | (() => unknown)>;\n factoryIdSets.push([id, factoryGetter]);\n });\n\n const setModule = (\n id: string | number,\n factoryGetter: () => () => unknown,\n ) => {\n webpackRequire.m[id] = (module) => {\n // Handle scenario when module is used synchronously\n installedModules[id] = 0;\n delete webpackRequire.c[id];\n\n const factory = factoryGetter();\n if (typeof factory !== 'function') {\n throw new Error(\n `Shared module is not available for eager consumption: ${id}`,\n );\n }\n const result = factory();\n // Add layer property from shareConfig if available\n const { shareInfo } = moduleToHandlerMapping[id];\n if (\n shareInfo?.shareConfig?.layer &&\n result &&\n typeof result === 'object'\n ) {\n try {\n // Only set layer if it's not already defined or if it's undefined\n if (\n !result.hasOwnProperty('layer') ||\n (result as any).layer === undefined\n ) {\n (result as any).layer = shareInfo.shareConfig.layer;\n }\n } catch (e) {\n // Ignore if layer property is read-only\n }\n }\n module.exports = result;\n };\n };\n\n if (asyncLoad) {\n return Promise.all(\n factoryIdSets.map(async ([id, factoryGetter]) => {\n const result = await factoryGetter();\n setModule(id, () => result as () => unknown);\n }),\n );\n }\n factoryIdSets.forEach(([id, factoryGetter]) => {\n setModule(id, factoryGetter as () => () => unknown);\n });\n}\n"],"mappings":";;;;AAQA,SAAS,sBAAsB,SAAuC;CACpE,MAAM,EAAE,UAAU,wBAAwB,gBAAgB,cACxD;CAEF,MAAM,qBAAqB,eAAe,WAAW;AACrD,KAAI,CAAC,mBACH,OAAM,IAAI,MAAM,iCAAiC;CAEnD,MAAM,EAAE,UAAU,cAAc,uBAAuB;AAEvD,KAAI;EACF,MAAM,cAAc,eAAe,gBAAgB,SAAS;EAE5D,MAAM,kBAAmC,EAAE,GAAG,WAAW;AACzD,MAAI,YACF,iBAAgB,cAAc;GAC5B;GACA,OAAO,CAAC,mBAAmB,QAAQ,KAAK;GACzC;AAEH,MAAI,UACF,QAAO,mBAAmB,UAAU,UAAU;GAC5C;GACA,SAAS;IACP,SAAS;IACT;IACD;GACF,CAAC;AAEJ,SAAO,mBAAmB,cAAc,UAAU;GAChD;GACA,SAAS;IACP,SAAS;IACT;IACD;GACF,CAAC;UACK,KAAK;AACZ,UAAQ,MACN,iMACD;AACD,UAAQ,MAAM,6CAA6C;AAC3D,QAAM;;;AAIV,SAAgB,uBAAuB,SAAwC;AAC7E,sBAAqB,QAAQ;CAE7B,MAAM,EACJ,wBACA,gBACA,kBACA,iBACA,cACE;CAEJ,MAAM,gBAEF,EAAE;AACN,iBAAgB,SAAS,OAAO;EAC9B,MAAM,sBACJ,sBAAsB;GACpB,UAAU;GACV;GACA;GACA;GACD,CAAC;AACJ,gBAAc,KAAK,CAAC,IAAI,cAAc,CAAC;GACvC;CAEF,MAAM,aACJ,IACA,kBACG;AACH,iBAAe,EAAE,OAAO,WAAW;AAEjC,oBAAiB,MAAM;AACvB,UAAO,eAAe,EAAE;GAExB,MAAM,UAAU,eAAe;AAC/B,OAAI,OAAO,YAAY,WACrB,OAAM,IAAI,MACR,yDAAyD,KAC1D;GAEH,MAAM,SAAS,SAAS;GAExB,MAAM,EAAE,cAAc,uBAAuB;AAC7C,OACE,WAAW,aAAa,SACxB,UACA,OAAO,WAAW,SAElB,KAAI;AAEF,QACE,CAAC,OAAO,eAAe,QAAQ,IAC9B,OAAe,UAAU,OAE1B,CAAC,OAAe,QAAQ,UAAU,YAAY;YAEzC,GAAG;AAId,UAAO,UAAU;;;AAIrB,KAAI,UACF,QAAO,QAAQ,IACb,cAAc,IAAI,OAAO,CAAC,IAAI,mBAAmB;EAC/C,MAAM,SAAS,MAAM,eAAe;AACpC,YAAU,UAAU,OAAwB;GAC5C,CACH;AAEH,eAAc,SAAS,CAAC,IAAI,mBAAmB;AAC7C,YAAU,IAAI,cAAqC;GACnD"}
@@ -0,0 +1,74 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ const require_attachShareScopeMap = require('./attachShareScopeMap.cjs');
3
+ const require_constant = require('./constant.cjs');
4
+ const require_updateOptions = require('./updateOptions.cjs');
5
+ let _module_federation_sdk = require("@module-federation/sdk");
6
+
7
+ //#region src/remotes.ts
8
+ function remotes(options) {
9
+ require_updateOptions.updateRemoteOptions(options);
10
+ const { chunkId, promises, webpackRequire, chunkMapping, idToExternalAndNameMapping, idToRemoteMap } = options;
11
+ require_attachShareScopeMap.attachShareScopeMap(webpackRequire);
12
+ if (webpackRequire.o(chunkMapping, chunkId)) chunkMapping[chunkId].forEach((id) => {
13
+ let getScope = webpackRequire.R;
14
+ if (!getScope) getScope = [];
15
+ const data = idToExternalAndNameMapping[id];
16
+ const remoteInfos = idToRemoteMap[id] || [];
17
+ if (getScope.indexOf(data) >= 0) return;
18
+ getScope.push(data);
19
+ if (data.p) return promises.push(data.p);
20
+ const onError = (error) => {
21
+ if (!error) error = /* @__PURE__ */ new Error("Container missing");
22
+ if (typeof error.message === "string") error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
23
+ webpackRequire.m[id] = () => {
24
+ throw error;
25
+ };
26
+ data.p = 0;
27
+ };
28
+ const handleFunction = (fn, arg1, arg2, d, next, first) => {
29
+ try {
30
+ const promise = fn(arg1, arg2);
31
+ if (promise && promise.then) {
32
+ const p = promise.then((result) => next(result, d), onError);
33
+ if (first) promises.push(data.p = p);
34
+ else return p;
35
+ } else return next(promise, d, first);
36
+ } catch (error) {
37
+ onError(error);
38
+ }
39
+ };
40
+ const onExternal = (external, _, first) => external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
41
+ var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
42
+ var onFactory = (factory) => {
43
+ data.p = 1;
44
+ webpackRequire.m[id] = (module) => {
45
+ module.exports = factory();
46
+ };
47
+ };
48
+ const onRemoteLoaded = () => {
49
+ try {
50
+ const remoteModuleName = (0, _module_federation_sdk.decodeName)(remoteInfos[0].name, _module_federation_sdk.ENCODE_NAME_PREFIX) + data[1].slice(1);
51
+ const instance = webpackRequire.federation.instance;
52
+ const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
53
+ loadFactory: false,
54
+ from: "build"
55
+ });
56
+ if (instance.options.shareStrategy === "version-first") {
57
+ const shareScopes = Array.isArray(data[0]) ? data[0] : [data[0]];
58
+ return Promise.all(shareScopes.map((shareScope) => instance.sharedHandler.initializeSharing(shareScope))).then(() => {
59
+ return loadRemote();
60
+ });
61
+ }
62
+ return loadRemote();
63
+ } catch (error) {
64
+ onError(error);
65
+ }
66
+ };
67
+ if (remoteInfos.length === 1 && require_constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name) handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
68
+ else handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
69
+ });
70
+ }
71
+
72
+ //#endregion
73
+ exports.remotes = remotes;
74
+ //# sourceMappingURL=remotes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remotes.cjs","names":["ENCODE_NAME_PREFIX","FEDERATION_SUPPORTED_TYPES"],"sources":["../src/remotes.ts"],"sourcesContent":["import { attachShareScopeMap } from './attachShareScopeMap';\nimport type { RemoteEntryExports } from './types';\nimport { RemotesOptions } from './types';\nimport { FEDERATION_SUPPORTED_TYPES } from './constant';\nimport { decodeName, ENCODE_NAME_PREFIX } from '@module-federation/sdk';\nimport { updateRemoteOptions } from './updateOptions';\n\nexport function remotes(options: RemotesOptions) {\n updateRemoteOptions(options);\n\n const {\n chunkId,\n promises,\n webpackRequire,\n chunkMapping,\n idToExternalAndNameMapping,\n idToRemoteMap,\n } = options;\n attachShareScopeMap(webpackRequire);\n\n if (webpackRequire.o(chunkMapping, chunkId)) {\n chunkMapping[chunkId].forEach((id) => {\n let getScope = webpackRequire.R;\n if (!getScope) {\n getScope = [];\n }\n const data = idToExternalAndNameMapping[id];\n const remoteInfos = idToRemoteMap[id] || [];\n // @ts-ignore seems not work\n if (getScope.indexOf(data) >= 0) {\n return;\n }\n // @ts-ignore seems not work\n getScope.push(data);\n if (data.p) {\n return promises.push(data.p as Promise<any>);\n }\n const onError = (error?: Error) => {\n if (!error) {\n error = new Error('Container missing');\n }\n if (typeof error.message === 'string') {\n error.message += `\\nwhile loading \"${data[1]}\" from ${data[2]}`;\n }\n webpackRequire.m[id] = () => {\n throw error;\n };\n data.p = 0;\n };\n const handleFunction = (\n fn: (...args: any[]) => any,\n arg1: any,\n arg2: any,\n d: any,\n next: (...args: any[]) => any,\n first: 1 | 0,\n ) => {\n try {\n const promise = fn(arg1, arg2);\n if (promise && promise.then) {\n const p = promise.then((result: any) => next(result, d), onError);\n if (first) {\n promises.push((data.p = p));\n } else {\n return p;\n }\n } else {\n return next(promise, d, first);\n }\n } catch (error) {\n onError(error as Error);\n }\n };\n const onExternal = (\n external: (...args: any[]) => any,\n _: any,\n first: 1 | 0,\n ) =>\n external\n ? handleFunction(\n webpackRequire.I,\n data[0],\n 0,\n external,\n onInitialized,\n first,\n )\n : onError();\n\n // eslint-disable-next-line no-var\n var onInitialized = (\n _: any,\n external: RemoteEntryExports,\n first: 1 | 0,\n ) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);\n // eslint-disable-next-line no-var\n var onFactory = (factory: () => any) => {\n data.p = 1;\n webpackRequire.m[id] = (module) => {\n module.exports = factory();\n };\n };\n const onRemoteLoaded = () => {\n try {\n const remoteName = decodeName(\n remoteInfos[0].name,\n ENCODE_NAME_PREFIX,\n );\n\n const remoteModuleName = remoteName + data[1].slice(1);\n const instance = webpackRequire.federation.instance!;\n const loadRemote = () =>\n webpackRequire.federation.instance!.loadRemote(remoteModuleName, {\n loadFactory: false,\n from: 'build',\n });\n\n if (instance.options.shareStrategy === 'version-first') {\n const shareScopes = Array.isArray(data[0]) ? data[0] : [data[0]];\n\n return Promise.all(\n shareScopes.map((shareScope) =>\n instance.sharedHandler.initializeSharing(shareScope),\n ),\n ).then(() => {\n return loadRemote();\n });\n }\n\n return loadRemote();\n } catch (error) {\n onError(error as Error);\n }\n };\n\n const useRuntimeLoad =\n remoteInfos.length === 1 &&\n FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) &&\n remoteInfos[0].name;\n\n if (useRuntimeLoad) {\n handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);\n } else {\n handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);\n }\n });\n }\n}\n"],"mappings":";;;;;;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OAAO,WAAW;AACjC,WAAO,UAAU,SAAS;;;EAG9B,MAAM,uBAAuB;AAC3B,OAAI;IAMF,MAAM,0DAJJ,YAAY,GAAG,MACfA,0CACD,GAEqC,KAAK,GAAG,MAAM,EAAE;IACtD,MAAM,WAAW,eAAe,WAAW;IAC3C,MAAM,mBACJ,eAAe,WAAW,SAAU,WAAW,kBAAkB;KAC/D,aAAa;KACb,MAAM;KACP,CAAC;AAEJ,QAAI,SAAS,QAAQ,kBAAkB,iBAAiB;KACtD,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,GAAG,KAAK,KAAK,CAAC,KAAK,GAAG;AAEhE,YAAO,QAAQ,IACb,YAAY,KAAK,eACf,SAAS,cAAc,kBAAkB,WAAW,CACrD,CACF,CAAC,WAAW;AACX,aAAO,YAAY;OACnB;;AAGJ,WAAO,YAAY;YACZ,OAAO;AACd,YAAQ,MAAe;;;AAS3B,MAJE,YAAY,WAAW,KACvBC,4CAA2B,SAAS,YAAY,GAAG,aAAa,IAChE,YAAY,GAAG,KAGf,gBAAe,gBAAgB,KAAK,IAAI,GAAG,GAAG,WAAW,EAAE;MAE3D,gBAAe,gBAAgB,KAAK,IAAI,GAAG,GAAG,YAAY,EAAE;GAE9D"}
@@ -0,0 +1,73 @@
1
+ import { attachShareScopeMap } from "./attachShareScopeMap.js";
2
+ import { FEDERATION_SUPPORTED_TYPES } from "./constant.js";
3
+ import { updateRemoteOptions } from "./updateOptions.js";
4
+ import { ENCODE_NAME_PREFIX, decodeName } from "@module-federation/sdk";
5
+
6
+ //#region src/remotes.ts
7
+ function remotes(options) {
8
+ updateRemoteOptions(options);
9
+ const { chunkId, promises, webpackRequire, chunkMapping, idToExternalAndNameMapping, idToRemoteMap } = options;
10
+ attachShareScopeMap(webpackRequire);
11
+ if (webpackRequire.o(chunkMapping, chunkId)) chunkMapping[chunkId].forEach((id) => {
12
+ let getScope = webpackRequire.R;
13
+ if (!getScope) getScope = [];
14
+ const data = idToExternalAndNameMapping[id];
15
+ const remoteInfos = idToRemoteMap[id] || [];
16
+ if (getScope.indexOf(data) >= 0) return;
17
+ getScope.push(data);
18
+ if (data.p) return promises.push(data.p);
19
+ const onError = (error) => {
20
+ if (!error) error = /* @__PURE__ */ new Error("Container missing");
21
+ if (typeof error.message === "string") error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
22
+ webpackRequire.m[id] = () => {
23
+ throw error;
24
+ };
25
+ data.p = 0;
26
+ };
27
+ const handleFunction = (fn, arg1, arg2, d, next, first) => {
28
+ try {
29
+ const promise = fn(arg1, arg2);
30
+ if (promise && promise.then) {
31
+ const p = promise.then((result) => next(result, d), onError);
32
+ if (first) promises.push(data.p = p);
33
+ else return p;
34
+ } else return next(promise, d, first);
35
+ } catch (error) {
36
+ onError(error);
37
+ }
38
+ };
39
+ const onExternal = (external, _, first) => external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
40
+ var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
41
+ var onFactory = (factory) => {
42
+ data.p = 1;
43
+ webpackRequire.m[id] = (module) => {
44
+ module.exports = factory();
45
+ };
46
+ };
47
+ const onRemoteLoaded = () => {
48
+ try {
49
+ const remoteModuleName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX) + data[1].slice(1);
50
+ const instance = webpackRequire.federation.instance;
51
+ const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
52
+ loadFactory: false,
53
+ from: "build"
54
+ });
55
+ if (instance.options.shareStrategy === "version-first") {
56
+ const shareScopes = Array.isArray(data[0]) ? data[0] : [data[0]];
57
+ return Promise.all(shareScopes.map((shareScope) => instance.sharedHandler.initializeSharing(shareScope))).then(() => {
58
+ return loadRemote();
59
+ });
60
+ }
61
+ return loadRemote();
62
+ } catch (error) {
63
+ onError(error);
64
+ }
65
+ };
66
+ if (remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name) handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
67
+ else handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
68
+ });
69
+ }
70
+
71
+ //#endregion
72
+ export { remotes };
73
+ //# sourceMappingURL=remotes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remotes.js","names":[],"sources":["../src/remotes.ts"],"sourcesContent":["import { attachShareScopeMap } from './attachShareScopeMap';\nimport type { RemoteEntryExports } from './types';\nimport { RemotesOptions } from './types';\nimport { FEDERATION_SUPPORTED_TYPES } from './constant';\nimport { decodeName, ENCODE_NAME_PREFIX } from '@module-federation/sdk';\nimport { updateRemoteOptions } from './updateOptions';\n\nexport function remotes(options: RemotesOptions) {\n updateRemoteOptions(options);\n\n const {\n chunkId,\n promises,\n webpackRequire,\n chunkMapping,\n idToExternalAndNameMapping,\n idToRemoteMap,\n } = options;\n attachShareScopeMap(webpackRequire);\n\n if (webpackRequire.o(chunkMapping, chunkId)) {\n chunkMapping[chunkId].forEach((id) => {\n let getScope = webpackRequire.R;\n if (!getScope) {\n getScope = [];\n }\n const data = idToExternalAndNameMapping[id];\n const remoteInfos = idToRemoteMap[id] || [];\n // @ts-ignore seems not work\n if (getScope.indexOf(data) >= 0) {\n return;\n }\n // @ts-ignore seems not work\n getScope.push(data);\n if (data.p) {\n return promises.push(data.p as Promise<any>);\n }\n const onError = (error?: Error) => {\n if (!error) {\n error = new Error('Container missing');\n }\n if (typeof error.message === 'string') {\n error.message += `\\nwhile loading \"${data[1]}\" from ${data[2]}`;\n }\n webpackRequire.m[id] = () => {\n throw error;\n };\n data.p = 0;\n };\n const handleFunction = (\n fn: (...args: any[]) => any,\n arg1: any,\n arg2: any,\n d: any,\n next: (...args: any[]) => any,\n first: 1 | 0,\n ) => {\n try {\n const promise = fn(arg1, arg2);\n if (promise && promise.then) {\n const p = promise.then((result: any) => next(result, d), onError);\n if (first) {\n promises.push((data.p = p));\n } else {\n return p;\n }\n } else {\n return next(promise, d, first);\n }\n } catch (error) {\n onError(error as Error);\n }\n };\n const onExternal = (\n external: (...args: any[]) => any,\n _: any,\n first: 1 | 0,\n ) =>\n external\n ? handleFunction(\n webpackRequire.I,\n data[0],\n 0,\n external,\n onInitialized,\n first,\n )\n : onError();\n\n // eslint-disable-next-line no-var\n var onInitialized = (\n _: any,\n external: RemoteEntryExports,\n first: 1 | 0,\n ) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);\n // eslint-disable-next-line no-var\n var onFactory = (factory: () => any) => {\n data.p = 1;\n webpackRequire.m[id] = (module) => {\n module.exports = factory();\n };\n };\n const onRemoteLoaded = () => {\n try {\n const remoteName = decodeName(\n remoteInfos[0].name,\n ENCODE_NAME_PREFIX,\n );\n\n const remoteModuleName = remoteName + data[1].slice(1);\n const instance = webpackRequire.federation.instance!;\n const loadRemote = () =>\n webpackRequire.federation.instance!.loadRemote(remoteModuleName, {\n loadFactory: false,\n from: 'build',\n });\n\n if (instance.options.shareStrategy === 'version-first') {\n const shareScopes = Array.isArray(data[0]) ? data[0] : [data[0]];\n\n return Promise.all(\n shareScopes.map((shareScope) =>\n instance.sharedHandler.initializeSharing(shareScope),\n ),\n ).then(() => {\n return loadRemote();\n });\n }\n\n return loadRemote();\n } catch (error) {\n onError(error as Error);\n }\n };\n\n const useRuntimeLoad =\n remoteInfos.length === 1 &&\n FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) &&\n remoteInfos[0].name;\n\n if (useRuntimeLoad) {\n handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);\n } else {\n handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);\n }\n });\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,QAAQ,SAAyB;AAC/C,qBAAoB,QAAQ;CAE5B,MAAM,EACJ,SACA,UACA,gBACA,cACA,4BACA,kBACE;AACJ,qBAAoB,eAAe;AAEnC,KAAI,eAAe,EAAE,cAAc,QAAQ,CACzC,cAAa,SAAS,SAAS,OAAO;EACpC,IAAI,WAAW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AAW,SAAU,WAAW,kBAAkB;KAC/D,aAAa;KACb,MAAM;KACP,CAAC;AAEJ,QAAI,SAAS,QAAQ,kBAAkB,iBAAiB;KACtD,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,GAAG,KAAK,KAAK,CAAC,KAAK,GAAG;AAEhE,YAAO,QAAQ,IACb,YAAY,KAAK,eACf,SAAS,cAAc,kBAAkB,WAAW,CACrD,CACF,CAAC,WAAW;AACX,aAAO,YAAY;OACnB;;AAGJ,WAAO,YAAY;YACZ,OAAO;AACd,YAAQ,MAAe;;;AAS3B,MAJE,YAAY,WAAW,KACvB,2BAA2B,SAAS,YAAY,GAAG,aAAa,IAChE,YAAY,GAAG,KAGf,gBAAe,gBAAgB,KAAK,IAAI,GAAG,GAAG,WAAW,EAAE;MAE3D,gBAAe,gBAAgB,KAAK,IAAI,GAAG,GAAG,YAAY,EAAE;GAE9D"}
@@ -0,0 +1,11 @@
1
+ //#region ../sdk/dist/types/plugins/ModuleFederationPlugin.d.ts
2
+ /**
3
+ * Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
4
+ */
5
+ type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'module-import' | 'script' | 'node-commonjs';
6
+ /**
7
+ * Container location from which modules should be resolved and loaded at runtime.
8
+ */
9
+ //#endregion
10
+ export { ExternalsType };
11
+ //# sourceMappingURL=ModuleFederationPlugin.d.ts.map
@@ -0,0 +1,201 @@
1
+ import { initializeSharing } from "./initializeSharing.js";
2
+ import { attachShareScopeMap } from "./attachShareScopeMap.js";
3
+ import { initContainerEntry } from "./initContainerEntry.js";
4
+ import * as runtime from "@module-federation/runtime";
5
+ import { moduleFederationPlugin } from "@module-federation/sdk";
6
+ import { Remote, RemoteEntryInitOptions, SharedConfig, SharedGetter, TreeShakingArgs } from "@module-federation/runtime/types";
7
+
8
+ //#region src/types.d.ts
9
+ type ExcludeUndefined<T> = T extends undefined ? never : T;
10
+ type Shared = InitOptions['shared'];
11
+ type NonUndefined<T = Shared> = ExcludeUndefined<T>;
12
+ type InitOptions = Omit<Parameters<typeof runtime.init>[0], 'remotes'> & {
13
+ remotes: Array<Remote & {
14
+ externalType: moduleFederationPlugin.ExternalsType;
15
+ }>;
16
+ };
17
+ type ModuleCache = runtime.ModuleFederation['moduleCache'];
18
+ type InferModule<T> = T extends Map<string, infer U> ? U : never;
19
+ type InferredModule = InferModule<ModuleCache>;
20
+ type ShareScopeMap = runtime.ModuleFederation['shareScopeMap'];
21
+ type InitToken = Record<string, Record<string, any>>;
22
+ interface InitializeSharingOptions {
23
+ shareScopeName: string | string[];
24
+ webpackRequire: WebpackRequire;
25
+ initPromises: Record<string, Promise<boolean> | boolean>;
26
+ initTokens: InitToken;
27
+ initScope: InitToken[];
28
+ }
29
+ type RemoteEntryExports = NonUndefined<InferredModule['remoteEntryExports']>;
30
+ type ExtractInitParameters<T> = T extends {
31
+ init: (shareScope: infer U, ...args: any[]) => void;
32
+ } ? U : never;
33
+ type InferredShareScope = ExtractInitParameters<RemoteEntryExports>;
34
+ type InferredGlobalShareScope = {
35
+ [scope: string]: InferredShareScope;
36
+ };
37
+ type IdToExternalAndNameMappingItem = [string | string[], string, string | number];
38
+ interface IdToExternalAndNameMappingItemWithPromise extends IdToExternalAndNameMappingItem {
39
+ p?: Promise<any> | number;
40
+ }
41
+ type IdToExternalAndNameMapping = Record<string, IdToExternalAndNameMappingItemWithPromise>;
42
+ type ModuleId = string | number;
43
+ type RemoteDataItem = {
44
+ shareScope: string | string[];
45
+ name: string;
46
+ externalModuleId: ModuleId;
47
+ remoteName: string;
48
+ };
49
+ type ModuleIdToRemoteDataMapping = Record<ModuleId, RemoteDataItem>;
50
+ type ModuleIdToConsumeDataMapping = {
51
+ fallback: () => Promise<any>;
52
+ shareKey: string;
53
+ shareScope: string | string[];
54
+ treeShakingMode?: 'server-calc' | 'runtime-infer';
55
+ } & SharedConfig;
56
+ type WithStatus<T> = T & {
57
+ _updated: number;
58
+ };
59
+ type ConsumesLoadingData = WithStatus<{
60
+ chunkMapping?: Record<string, Array<string | number>>;
61
+ moduleIdToConsumeDataMapping?: Record<string, ModuleIdToConsumeDataMapping>;
62
+ initialConsumes?: Array<ModuleId>;
63
+ }>;
64
+ type RemotesLoadingData = WithStatus<{
65
+ chunkMapping?: Record<string, Array<ModuleId>>;
66
+ moduleIdToRemoteDataMapping?: ModuleIdToRemoteDataMapping;
67
+ }>;
68
+ type InitializeSharingData = WithStatus<{
69
+ scopeToSharingDataMapping: {
70
+ [shareScope: string]: Array<{
71
+ name: string;
72
+ version: string;
73
+ factory: SharedGetter;
74
+ eager?: boolean;
75
+ singleton?: boolean;
76
+ requiredVersion?: string;
77
+ strictVersion?: boolean;
78
+ }>;
79
+ };
80
+ uniqueName: string;
81
+ }>;
82
+ interface WebpackRequire {
83
+ (moduleId: string | number): any;
84
+ p: string;
85
+ o: (obj: Record<string, any>, key: string | number) => boolean;
86
+ R: Array<string | number>;
87
+ m: Record<string, (mod: any) => any>;
88
+ j?: string;
89
+ c: Record<string, any>;
90
+ I: (scopeName: string | string[], initScope?: InitializeSharingOptions['initScope']) => ReturnType<typeof initializeSharing>;
91
+ S?: InferredGlobalShareScope;
92
+ federation: Federation;
93
+ consumesLoadingData?: ConsumesLoadingData;
94
+ remotesLoadingData?: RemotesLoadingData;
95
+ initializeSharingData?: InitializeSharingData;
96
+ }
97
+ interface ShareInfo {
98
+ shareConfig: SharedConfig;
99
+ scope: Array<string>;
100
+ treeShaking?: TreeShakingArgs;
101
+ }
102
+ interface ModuleToHandlerMappingItem {
103
+ getter: () => Promise<any>;
104
+ shareInfo: ShareInfo;
105
+ shareKey: string;
106
+ treeShakingGetter?: () => Promise<any>;
107
+ }
108
+ interface IdToRemoteMapItem {
109
+ externalType: string;
110
+ name: string;
111
+ }
112
+ type IdToRemoteMap = Record<string, IdToRemoteMapItem[]>;
113
+ type RemoteInfos = Record<string, Array<IdToRemoteMapItem & {
114
+ alias: string;
115
+ entry?: string;
116
+ shareScope: string;
117
+ }>>;
118
+ type RemoteChunkMapping = Record<string, Array<ModuleId>>;
119
+ type CoreRemotesOptions = {
120
+ idToRemoteMap: IdToRemoteMap;
121
+ chunkMapping: RemoteChunkMapping;
122
+ idToExternalAndNameMapping: IdToExternalAndNameMapping;
123
+ };
124
+ type RemotesOptions = {
125
+ chunkId: string | number;
126
+ promises: Promise<any>[];
127
+ webpackRequire: WebpackRequire;
128
+ } & CoreRemotesOptions;
129
+ interface HandleInitialConsumesOptions {
130
+ moduleId: string | number;
131
+ moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
132
+ webpackRequire: WebpackRequire;
133
+ asyncLoad?: boolean;
134
+ }
135
+ interface InstallInitialConsumesOptions {
136
+ moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
137
+ webpackRequire: WebpackRequire;
138
+ installedModules: Record<string, Promise<any> | 0>;
139
+ initialConsumes: Array<string | number>;
140
+ asyncLoad?: boolean;
141
+ }
142
+ interface ConsumesOptions {
143
+ chunkId: string | number;
144
+ promises: Promise<any>[];
145
+ chunkMapping: Record<string, Array<string | number>>;
146
+ installedModules: Record<string, Promise<any> | 0>;
147
+ moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
148
+ webpackRequire: WebpackRequire;
149
+ }
150
+ interface InitContainerEntryOptions {
151
+ shareScope: ShareScopeMap[string];
152
+ shareScopeKey: string | string[];
153
+ webpackRequire: WebpackRequire;
154
+ remoteEntryInitOptions?: RemoteEntryInitOptions;
155
+ initScope?: InitializeSharingOptions['initScope'];
156
+ }
157
+ interface GetSharedFallbackGetterOptions {
158
+ shareKey: string;
159
+ factory: SharedGetter;
160
+ version?: string;
161
+ webpackRequire: WebpackRequire;
162
+ libraryType?: string;
163
+ }
164
+ interface Federation {
165
+ runtime?: typeof runtime;
166
+ instance?: runtime.ModuleFederation;
167
+ initOptions?: InitOptions;
168
+ installInitialConsumes?: (options: InstallInitialConsumesOptions) => any;
169
+ bundlerRuntime?: {
170
+ remotes: (options: RemotesOptions) => void;
171
+ consumes: (options: ConsumesOptions) => void;
172
+ I: typeof initializeSharing;
173
+ S: InferredGlobalShareScope;
174
+ installInitialConsumes: (options: InstallInitialConsumesOptions) => any;
175
+ initContainerEntry: typeof initContainerEntry;
176
+ init: ({
177
+ webpackRequire,
178
+ libraryType
179
+ }: {
180
+ webpackRequire: WebpackRequire;
181
+ libraryType: string;
182
+ }) => void;
183
+ getSharedFallbackGetter: (options: GetSharedFallbackGetterOptions) => SharedGetter;
184
+ };
185
+ bundlerRuntimeOptions: {
186
+ remotes?: Exclude<RemotesOptions, 'chunkId' | 'promises'> & {
187
+ remoteInfos?: RemoteInfos;
188
+ };
189
+ };
190
+ attachShareScopeMap?: typeof attachShareScopeMap;
191
+ hasAttachShareScopeMap?: boolean;
192
+ prefetch?: () => void;
193
+ usedExports?: {
194
+ [sharedName: string]: string[];
195
+ };
196
+ libraryType?: string;
197
+ sharedFallback?: Record<string, Array<[string, string, string]>>;
198
+ }
199
+ //#endregion
200
+ export { ConsumesLoadingData, ConsumesOptions, CoreRemotesOptions, Federation, GetSharedFallbackGetterOptions, HandleInitialConsumesOptions, IdToExternalAndNameMapping, IdToRemoteMap, IdToRemoteMapItem, InitContainerEntryOptions, InitializeSharingData, InitializeSharingOptions, InstallInitialConsumesOptions, ModuleId, ModuleIdToRemoteDataMapping, RemoteChunkMapping, RemoteDataItem, RemoteEntryExports, RemoteInfos, RemotesLoadingData, RemotesOptions, ShareScopeMap, WebpackRequire };
201
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,112 @@
1
+
2
+ //#region src/updateOptions.ts
3
+ function updateConsumeOptions(options) {
4
+ const { webpackRequire, moduleToHandlerMapping } = options;
5
+ const { consumesLoadingData, initializeSharingData } = webpackRequire;
6
+ const { sharedFallback, bundlerRuntime, libraryType } = webpackRequire.federation;
7
+ if (consumesLoadingData && !consumesLoadingData._updated) {
8
+ const { moduleIdToConsumeDataMapping: updatedModuleIdToConsumeDataMapping = {}, initialConsumes: updatedInitialConsumes = [], chunkMapping: updatedChunkMapping = {} } = consumesLoadingData;
9
+ Object.entries(updatedModuleIdToConsumeDataMapping).forEach(([id, data]) => {
10
+ if (!moduleToHandlerMapping[id]) moduleToHandlerMapping[id] = {
11
+ getter: sharedFallback ? bundlerRuntime?.getSharedFallbackGetter({
12
+ shareKey: data.shareKey,
13
+ factory: data.fallback,
14
+ webpackRequire,
15
+ libraryType
16
+ }) : data.fallback,
17
+ treeShakingGetter: sharedFallback ? data.fallback : void 0,
18
+ shareInfo: {
19
+ shareConfig: {
20
+ requiredVersion: data.requiredVersion,
21
+ strictVersion: data.strictVersion,
22
+ singleton: data.singleton,
23
+ eager: data.eager,
24
+ layer: data.layer
25
+ },
26
+ scope: Array.isArray(data.shareScope) ? data.shareScope : [data.shareScope || "default"],
27
+ treeShaking: sharedFallback ? {
28
+ get: data.fallback,
29
+ mode: data.treeShakingMode
30
+ } : void 0
31
+ },
32
+ shareKey: data.shareKey
33
+ };
34
+ });
35
+ if ("initialConsumes" in options) {
36
+ const { initialConsumes = [] } = options;
37
+ updatedInitialConsumes.forEach((id) => {
38
+ if (!initialConsumes.includes(id)) initialConsumes.push(id);
39
+ });
40
+ }
41
+ if ("chunkMapping" in options) {
42
+ const { chunkMapping = {} } = options;
43
+ Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
44
+ if (!chunkMapping[id]) chunkMapping[id] = [];
45
+ chunkModules.forEach((moduleId) => {
46
+ if (!chunkMapping[id].includes(moduleId)) chunkMapping[id].push(moduleId);
47
+ });
48
+ });
49
+ }
50
+ consumesLoadingData._updated = 1;
51
+ }
52
+ if (initializeSharingData && !initializeSharingData._updated) {
53
+ const { federation } = webpackRequire;
54
+ if (!federation.instance || !initializeSharingData.scopeToSharingDataMapping) return;
55
+ const shared = {};
56
+ for (let [scope, stages] of Object.entries(initializeSharingData.scopeToSharingDataMapping)) for (let stage of stages) if (typeof stage === "object" && stage !== null) {
57
+ const { name, version, factory, eager, singleton, requiredVersion, strictVersion } = stage;
58
+ const shareConfig = { requiredVersion: `^${version}` };
59
+ const isValidValue = function(val) {
60
+ return typeof val !== "undefined";
61
+ };
62
+ if (isValidValue(singleton)) shareConfig.singleton = singleton;
63
+ if (isValidValue(requiredVersion)) shareConfig.requiredVersion = requiredVersion;
64
+ if (isValidValue(eager)) shareConfig.eager = eager;
65
+ if (isValidValue(strictVersion)) shareConfig.strictVersion = strictVersion;
66
+ const options = {
67
+ version,
68
+ scope: [scope],
69
+ shareConfig,
70
+ get: factory
71
+ };
72
+ if (shared[name]) shared[name].push(options);
73
+ else shared[name] = [options];
74
+ }
75
+ federation.instance.registerShared(shared);
76
+ initializeSharingData._updated = 1;
77
+ }
78
+ }
79
+ function updateRemoteOptions(options) {
80
+ const { webpackRequire, idToExternalAndNameMapping = {}, idToRemoteMap = {}, chunkMapping = {} } = options;
81
+ const { remotesLoadingData } = webpackRequire;
82
+ const remoteInfos = webpackRequire.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;
83
+ if (!remotesLoadingData || remotesLoadingData._updated || !remoteInfos) return;
84
+ const { chunkMapping: updatedChunkMapping, moduleIdToRemoteDataMapping } = remotesLoadingData;
85
+ if (!updatedChunkMapping || !moduleIdToRemoteDataMapping) return;
86
+ for (let [moduleId, data] of Object.entries(moduleIdToRemoteDataMapping)) {
87
+ if (!idToExternalAndNameMapping[moduleId]) idToExternalAndNameMapping[moduleId] = [
88
+ data.shareScope,
89
+ data.name,
90
+ data.externalModuleId
91
+ ];
92
+ if (!idToRemoteMap[moduleId] && remoteInfos[data.remoteName]) {
93
+ const items = remoteInfos[data.remoteName];
94
+ idToRemoteMap[moduleId] ||= [];
95
+ items.forEach((item) => {
96
+ if (!idToRemoteMap[moduleId].includes(item)) idToRemoteMap[moduleId].push(item);
97
+ });
98
+ }
99
+ }
100
+ if (chunkMapping) Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
101
+ if (!chunkMapping[id]) chunkMapping[id] = [];
102
+ chunkModules.forEach((moduleId) => {
103
+ if (!chunkMapping[id].includes(moduleId)) chunkMapping[id].push(moduleId);
104
+ });
105
+ });
106
+ remotesLoadingData._updated = 1;
107
+ }
108
+
109
+ //#endregion
110
+ exports.updateConsumeOptions = updateConsumeOptions;
111
+ exports.updateRemoteOptions = updateRemoteOptions;
112
+ //# sourceMappingURL=updateOptions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateOptions.cjs","names":[],"sources":["../src/updateOptions.ts"],"sourcesContent":["import type {\n IdToRemoteMapItem,\n RemotesOptions,\n InstallInitialConsumesOptions,\n ConsumesOptions,\n} from './types';\nimport type {\n UserOptions,\n ShareArgs,\n SharedConfig,\n} from '@module-federation/runtime/types';\n\nexport function updateConsumeOptions(\n options: InstallInitialConsumesOptions | ConsumesOptions,\n) {\n const { webpackRequire, moduleToHandlerMapping } = options;\n const { consumesLoadingData, initializeSharingData } = webpackRequire;\n const { sharedFallback, bundlerRuntime, libraryType } =\n webpackRequire.federation;\n if (consumesLoadingData && !consumesLoadingData._updated) {\n const {\n moduleIdToConsumeDataMapping: updatedModuleIdToConsumeDataMapping = {},\n initialConsumes: updatedInitialConsumes = [],\n chunkMapping: updatedChunkMapping = {},\n } = consumesLoadingData;\n\n Object.entries(updatedModuleIdToConsumeDataMapping).forEach(\n ([id, data]) => {\n if (!moduleToHandlerMapping[id]) {\n moduleToHandlerMapping[id] = {\n // @ts-ignore\n getter: sharedFallback\n ? bundlerRuntime?.getSharedFallbackGetter({\n shareKey: data.shareKey,\n factory: data.fallback,\n webpackRequire,\n libraryType,\n })\n : data.fallback,\n treeShakingGetter: sharedFallback ? data.fallback : undefined,\n shareInfo: {\n shareConfig: {\n requiredVersion: data.requiredVersion,\n strictVersion: data.strictVersion,\n singleton: data.singleton,\n eager: data.eager,\n layer: data.layer,\n },\n scope: Array.isArray(data.shareScope)\n ? data.shareScope\n : [data.shareScope || 'default'],\n treeShaking: sharedFallback\n ? {\n get: data.fallback,\n mode: data.treeShakingMode,\n }\n : undefined,\n },\n shareKey: data.shareKey,\n };\n }\n },\n );\n\n if ('initialConsumes' in options) {\n const { initialConsumes = [] } = options;\n updatedInitialConsumes.forEach((id) => {\n if (!initialConsumes.includes(id)) {\n initialConsumes.push(id);\n }\n });\n }\n\n if ('chunkMapping' in options) {\n const { chunkMapping = {} } = options;\n Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {\n if (!chunkMapping[id]) {\n chunkMapping[id] = [];\n }\n chunkModules.forEach((moduleId) => {\n if (!chunkMapping[id].includes(moduleId)) {\n chunkMapping[id].push(moduleId);\n }\n });\n });\n }\n consumesLoadingData._updated = 1;\n }\n\n if (initializeSharingData && !initializeSharingData._updated) {\n const { federation } = webpackRequire;\n if (\n !federation.instance ||\n !initializeSharingData.scopeToSharingDataMapping\n ) {\n return;\n }\n const shared: Record<string, Array<ShareArgs>> = {};\n for (let [scope, stages] of Object.entries(\n initializeSharingData.scopeToSharingDataMapping,\n )) {\n for (let stage of stages) {\n if (typeof stage === 'object' && stage !== null) {\n const {\n name,\n version,\n factory,\n eager,\n singleton,\n requiredVersion,\n strictVersion,\n } = stage;\n const shareConfig: SharedConfig = {\n requiredVersion: `^${version}`,\n };\n const isValidValue = function (\n val: unknown,\n ): val is NonNullable<unknown> {\n return typeof val !== 'undefined';\n };\n if (isValidValue(singleton)) {\n shareConfig.singleton = singleton;\n }\n if (isValidValue(requiredVersion)) {\n shareConfig.requiredVersion = requiredVersion;\n }\n if (isValidValue(eager)) {\n shareConfig.eager = eager;\n }\n if (isValidValue(strictVersion)) {\n shareConfig.strictVersion = strictVersion;\n }\n const options = {\n version,\n scope: [scope],\n shareConfig,\n get: factory,\n };\n if (shared[name]) {\n shared[name].push(options);\n } else {\n shared[name] = [options];\n }\n }\n }\n }\n federation.instance.registerShared(shared);\n initializeSharingData._updated = 1;\n }\n}\n\nexport function updateRemoteOptions(options: RemotesOptions) {\n const {\n webpackRequire,\n idToExternalAndNameMapping = {},\n idToRemoteMap = {},\n chunkMapping = {},\n } = options;\n const { remotesLoadingData } = webpackRequire;\n const remoteInfos =\n webpackRequire.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;\n if (!remotesLoadingData || remotesLoadingData._updated || !remoteInfos) {\n return;\n }\n const { chunkMapping: updatedChunkMapping, moduleIdToRemoteDataMapping } =\n remotesLoadingData;\n if (!updatedChunkMapping || !moduleIdToRemoteDataMapping) {\n return;\n }\n for (let [moduleId, data] of Object.entries(moduleIdToRemoteDataMapping)) {\n if (!idToExternalAndNameMapping[moduleId]) {\n idToExternalAndNameMapping[moduleId] = [\n data.shareScope,\n data.name,\n data.externalModuleId,\n ];\n }\n if (!idToRemoteMap[moduleId] && remoteInfos[data.remoteName]) {\n const items = remoteInfos[data.remoteName];\n idToRemoteMap[moduleId] ||= [];\n items.forEach((item) => {\n if (!idToRemoteMap[moduleId].includes(item)) {\n idToRemoteMap[moduleId].push(item);\n }\n });\n }\n }\n\n if (chunkMapping) {\n Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {\n if (!chunkMapping[id]) {\n chunkMapping[id] = [];\n }\n chunkModules.forEach((moduleId) => {\n if (!chunkMapping[id].includes(moduleId)) {\n chunkMapping[id].push(moduleId);\n }\n });\n });\n }\n remotesLoadingData._updated = 1;\n}\n"],"mappings":";;AAYA,SAAgB,qBACd,SACA;CACA,MAAM,EAAE,gBAAgB,2BAA2B;CACnD,MAAM,EAAE,qBAAqB,0BAA0B;CACvD,MAAM,EAAE,gBAAgB,gBAAgB,gBACtC,eAAe;AACjB,KAAI,uBAAuB,CAAC,oBAAoB,UAAU;EACxD,MAAM,EACJ,8BAA8B,sCAAsC,EAAE,EACtE,iBAAiB,yBAAyB,EAAE,EAC5C,cAAc,sBAAsB,EAAE,KACpC;AAEJ,SAAO,QAAQ,oCAA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