@module-federation/webpack-bundler-runtime 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/consumes.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  const require_attachShareScopeMap = require('./attachShareScopeMap.cjs');
2
2
  const require_updateOptions = require('./updateOptions.cjs');
3
3
  const require_getUsedExports = require('./getUsedExports.cjs');
4
+ const require_error_codes = require('./error-codes/dist/error-codes.cjs');
5
+ const require_getShortErrorMsg = require('./error-codes/dist/getShortErrorMsg.cjs');
4
6
 
5
7
  //#region src/consumes.ts
6
8
  function consumes(options) {
@@ -40,7 +42,10 @@ function consumes(options) {
40
42
  useIn: [federationInstance.options.name]
41
43
  };
42
44
  const promise = federationInstance.loadShare(shareKey, { customShareInfo }).then((factory) => {
43
- if (factory === false) return treeShakingGetter?.() || getter();
45
+ if (factory === false) {
46
+ if (typeof getter !== "function") throw new Error(require_getShortErrorMsg.getShortErrorMsg(require_error_codes.RUNTIME_012, { [require_error_codes.RUNTIME_012]: "The getter for the shared module is not a function. This may be caused by setting \"shared.import: false\" without the host providing the corresponding lib." }, { shareKey }));
47
+ return treeShakingGetter?.() || getter();
48
+ }
44
49
  return factory;
45
50
  });
46
51
  if (promise.then) promises.push(installedModules[id] = promise.then(onFactory).catch(onError));
@@ -1 +1 @@
1
- {"version":3,"file":"consumes.cjs","names":["getUsedExports"],"sources":["../src/consumes.ts"],"sourcesContent":["import { ConsumesOptions } from './types';\nimport { attachShareScopeMap } from './attachShareScopeMap';\nimport { updateConsumeOptions } from './updateOptions';\nimport { getUsedExports } from './getUsedExports';\nimport type { Shared } from '@module-federation/runtime/types';\n\nexport function consumes(options: ConsumesOptions) {\n updateConsumeOptions(options);\n const {\n chunkId,\n promises,\n installedModules,\n webpackRequire,\n chunkMapping,\n moduleToHandlerMapping,\n } = options;\n\n attachShareScopeMap(webpackRequire);\n if (webpackRequire.o(chunkMapping, chunkId)) {\n chunkMapping[chunkId].forEach((id) => {\n if (webpackRequire.o(installedModules, id)) {\n return promises.push(installedModules[id] as Promise<any>);\n }\n const onFactory = (factory: () => any) => {\n installedModules[id] = 0;\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\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 const onError = (error: unknown) => {\n delete installedModules[id];\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\n throw error;\n };\n };\n try {\n const federationInstance = webpackRequire.federation.instance;\n if (!federationInstance) {\n throw new Error('Federation instance not found!');\n }\n const { shareKey, getter, shareInfo, treeShakingGetter } =\n moduleToHandlerMapping[id];\n const usedExports = getUsedExports(webpackRequire, shareKey);\n const customShareInfo: Partial<Shared> = { ...shareInfo };\n // compatibility for rspack, which will wrap scope with array, but webpack will not\n // https://github.com/web-infra-dev/rspack/blob/main/packages/rspack/src/runtime/moduleFederationDefaultRuntime.js#L95\n if (\n Array.isArray(customShareInfo.scope) &&\n Array.isArray(customShareInfo.scope[0])\n ) {\n customShareInfo.scope = customShareInfo.scope[0];\n }\n if (usedExports) {\n customShareInfo.treeShaking = {\n usedExports,\n useIn: [federationInstance.options.name],\n };\n }\n const promise = federationInstance\n .loadShare(shareKey, {\n customShareInfo,\n })\n .then((factory: any) => {\n if (factory === false) {\n return treeShakingGetter?.() || getter();\n }\n return factory;\n });\n\n if (promise.then) {\n promises.push(\n (installedModules[id] = promise.then(onFactory).catch(onError)),\n );\n } else {\n // @ts-ignore maintain previous logic\n onFactory(promise);\n }\n } catch (e) {\n onError(e);\n }\n });\n }\n}\n"],"m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YAAiB;AACtB,QAAI,YAAY,MACd,QAAO,qBAAqB,IAAI,QAAQ;AAE1C,WAAO;KACP;AAEJ,OAAI,QAAQ,KACV,UAAS,KACN,iBAAiB,MAAM,QAAQ,KAAK,UAAU,CAAC,MAAM,QAAQ,CAC/D;OAGD,WAAU,QAAQ;WAEb,GAAG;AACV,WAAQ,EAAE;;GAEZ"}
1
+ {"version":3,"file":"consumes.cjs","names":["getUsedExports","getShortErrorMsg","RUNTIME_012"],"sources":["../src/consumes.ts"],"sourcesContent":["import { ConsumesOptions } from './types';\nimport { attachShareScopeMap } from './attachShareScopeMap';\nimport { updateConsumeOptions } from './updateOptions';\nimport { getUsedExports } from './getUsedExports';\nimport type { Shared } from '@module-federation/runtime/types';\nimport { getShortErrorMsg, RUNTIME_012 } from '@module-federation/error-codes';\n\nexport function consumes(options: ConsumesOptions) {\n updateConsumeOptions(options);\n const {\n chunkId,\n promises,\n installedModules,\n webpackRequire,\n chunkMapping,\n moduleToHandlerMapping,\n } = options;\n\n attachShareScopeMap(webpackRequire);\n if (webpackRequire.o(chunkMapping, chunkId)) {\n chunkMapping[chunkId].forEach((id) => {\n if (webpackRequire.o(installedModules, id)) {\n return promises.push(installedModules[id] as Promise<any>);\n }\n const onFactory = (factory: () => any) => {\n installedModules[id] = 0;\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\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 const onError = (error: unknown) => {\n delete installedModules[id];\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\n throw error;\n };\n };\n try {\n const federationInstance = webpackRequire.federation.instance;\n if (!federationInstance) {\n throw new Error('Federation instance not found!');\n }\n const { shareKey, getter, shareInfo, treeShakingGetter } =\n moduleToHandlerMapping[id];\n const usedExports = getUsedExports(webpackRequire, shareKey);\n const customShareInfo: Partial<Shared> = { ...shareInfo };\n // compatibility for rspack, which will wrap scope with array, but webpack will not\n // https://github.com/web-infra-dev/rspack/blob/main/packages/rspack/src/runtime/moduleFederationDefaultRuntime.js#L95\n if (\n Array.isArray(customShareInfo.scope) &&\n Array.isArray(customShareInfo.scope[0])\n ) {\n customShareInfo.scope = customShareInfo.scope[0];\n }\n if (usedExports) {\n customShareInfo.treeShaking = {\n usedExports,\n useIn: [federationInstance.options.name],\n };\n }\n const promise = federationInstance\n .loadShare(shareKey, {\n customShareInfo,\n })\n .then((factory: any) => {\n if (factory === false) {\n if (typeof getter !== 'function') {\n throw new Error(\n getShortErrorMsg(\n RUNTIME_012,\n {\n [RUNTIME_012]:\n 'The getter for the shared module is not a function. This may be caused by setting \"shared.import: false\" without the host providing the corresponding lib.',\n },\n { shareKey },\n ),\n );\n }\n return treeShakingGetter?.() || getter();\n }\n return factory;\n });\n\n if (promise.then) {\n promises.push(\n (installedModules[id] = promise.then(onFactory).catch(onError)),\n );\n } else {\n // @ts-ignore maintain previous logic\n onFactory(promise);\n }\n } catch (e) {\n onError(e);\n }\n });\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,SAAS,SAA0B;AACjD,4CAAqB,QAAQ;CAC7B,MAAM,EACJ,SACA,UACA,kBACA,gBACA,cACA,2BACE;AAEJ,iDAAoB,eAAe;AACnC,KAAI,eAAe,EAAE,cAAc,QAAQ,CACzC,cAAa,SAAS,SAAS,OAAO;AACpC,MAAI,eAAe,EAAE,kBAAkB,GAAG,CACxC,QAAO,SAAS,KAAK,iBAAiB,IAAoB;EAE5D,MAAM,aAAa,YAAuB;AACxC,oBAAiB,MAAM;AACvB,kBAAe,EAAE,OAAO,WAAW;AACjC,WAAO,eAAe,EAAE;IACxB,MAA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
  import { attachShareScopeMap } from "./attachShareScopeMap.js";
2
2
  import { updateConsumeOptions } from "./updateOptions.js";
3
3
  import { getUsedExports } from "./getUsedExports.js";
4
+ import { RUNTIME_012 } from "./error-codes/dist/error-codes.js";
5
+ import { getShortErrorMsg } from "./error-codes/dist/getShortErrorMsg.js";
4
6
 
5
7
  //#region src/consumes.ts
6
8
  function consumes(options) {
@@ -40,7 +42,10 @@ function consumes(options) {
40
42
  useIn: [federationInstance.options.name]
41
43
  };
42
44
  const promise = federationInstance.loadShare(shareKey, { customShareInfo }).then((factory) => {
43
- if (factory === false) return treeShakingGetter?.() || getter();
45
+ if (factory === false) {
46
+ if (typeof getter !== "function") throw new Error(getShortErrorMsg(RUNTIME_012, { [RUNTIME_012]: "The getter for the shared module is not a function. This may be caused by setting \"shared.import: false\" without the host providing the corresponding lib." }, { shareKey }));
47
+ return treeShakingGetter?.() || getter();
48
+ }
44
49
  return factory;
45
50
  });
46
51
  if (promise.then) promises.push(installedModules[id] = promise.then(onFactory).catch(onError));
@@ -1 +1 @@
1
- {"version":3,"file":"consumes.js","names":[],"sources":["../src/consumes.ts"],"sourcesContent":["import { ConsumesOptions } from './types';\nimport { attachShareScopeMap } from './attachShareScopeMap';\nimport { updateConsumeOptions } from './updateOptions';\nimport { getUsedExports } from './getUsedExports';\nimport type { Shared } from '@module-federation/runtime/types';\n\nexport function consumes(options: ConsumesOptions) {\n updateConsumeOptions(options);\n const {\n chunkId,\n promises,\n installedModules,\n webpackRequire,\n chunkMapping,\n moduleToHandlerMapping,\n } = options;\n\n attachShareScopeMap(webpackRequire);\n if (webpackRequire.o(chunkMapping, chunkId)) {\n chunkMapping[chunkId].forEach((id) => {\n if (webpackRequire.o(installedModules, id)) {\n return promises.push(installedModules[id] as Promise<any>);\n }\n const onFactory = (factory: () => any) => {\n installedModules[id] = 0;\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\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 const onError = (error: unknown) => {\n delete installedModules[id];\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\n throw error;\n };\n };\n try {\n const federationInstance = webpackRequire.federation.instance;\n if (!federationInstance) {\n throw new Error('Federation instance not found!');\n }\n const { shareKey, getter, shareInfo, treeShakingGetter } =\n moduleToHandlerMapping[id];\n const usedExports = getUsedExports(webpackRequire, shareKey);\n const customShareInfo: Partial<Shared> = { ...shareInfo };\n // compatibility for rspack, which will wrap scope with array, but webpack will not\n // https://github.com/web-infra-dev/rspack/blob/main/packages/rspack/src/runtime/moduleFederationDefaultRuntime.js#L95\n if (\n Array.isArray(customShareInfo.scope) &&\n Array.isArray(customShareInfo.scope[0])\n ) {\n customShareInfo.scope = customShareInfo.scope[0];\n }\n if (usedExports) {\n customShareInfo.treeShaking = {\n usedExports,\n useIn: [federationInstance.options.name],\n };\n }\n const promise = federationInstance\n .loadShare(shareKey, {\n customShareInfo,\n })\n .then((factory: any) => {\n if (factory === false) {\n return treeShakingGetter?.() || getter();\n }\n return factory;\n });\n\n if (promise.then) {\n promises.push(\n (installedModules[id] = promise.then(onFactory).catch(onError)),\n );\n } else {\n // @ts-ignore maintain previous logic\n onFactory(promise);\n }\n } catch (e) {\n onError(e);\n }\n });\n }\n}\n"],"mappings":";;;;;AAMA,SAAgB,SAAS,SAA0B;AACjD,sBAAqB,QAAQ;CAC7B,MAAM,EACJ,SACA,UACA,kBACA,gBACA,cACA,2BACE;AAEJ,qBAAoB,eAAe;AACnC,KAAI,eAAe,EAAE,cAAc,QAAQ,CACzC,cAAa,SAAS,SAAS,OAAO;AACpC,MAAI,eAAe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AE;;GAEZ"}
1
+ {"version":3,"file":"consumes.js","names":[],"sources":["../src/consumes.ts"],"sourcesContent":["import { ConsumesOptions } from './types';\nimport { attachShareScopeMap } from './attachShareScopeMap';\nimport { updateConsumeOptions } from './updateOptions';\nimport { getUsedExports } from './getUsedExports';\nimport type { Shared } from '@module-federation/runtime/types';\nimport { getShortErrorMsg, RUNTIME_012 } from '@module-federation/error-codes';\n\nexport function consumes(options: ConsumesOptions) {\n updateConsumeOptions(options);\n const {\n chunkId,\n promises,\n installedModules,\n webpackRequire,\n chunkMapping,\n moduleToHandlerMapping,\n } = options;\n\n attachShareScopeMap(webpackRequire);\n if (webpackRequire.o(chunkMapping, chunkId)) {\n chunkMapping[chunkId].forEach((id) => {\n if (webpackRequire.o(installedModules, id)) {\n return promises.push(installedModules[id] as Promise<any>);\n }\n const onFactory = (factory: () => any) => {\n installedModules[id] = 0;\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\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 const onError = (error: unknown) => {\n delete installedModules[id];\n webpackRequire.m[id] = (module) => {\n delete webpackRequire.c[id];\n throw error;\n };\n };\n try {\n const federationInstance = webpackRequire.federation.instance;\n if (!federationInstance) {\n throw new Error('Federation instance not found!');\n }\n const { shareKey, getter, shareInfo, treeShakingGetter } =\n moduleToHandlerMapping[id];\n const usedExports = getUsedExports(webpackRequire, shareKey);\n const customShareInfo: Partial<Shared> = { ...shareInfo };\n // compatibility for rspack, which will wrap scope with array, but webpack will not\n // https://github.com/web-infra-dev/rspack/blob/main/packages/rspack/src/runtime/moduleFederationDefaultRuntime.js#L95\n if (\n Array.isArray(customShareInfo.scope) &&\n Array.isArray(customShareInfo.scope[0])\n ) {\n customShareInfo.scope = customShareInfo.scope[0];\n }\n if (usedExports) {\n customShareInfo.treeShaking = {\n usedExports,\n useIn: [federationInstance.options.name],\n };\n }\n const promise = federationInstance\n .loadShare(shareKey, {\n customShareInfo,\n })\n .then((factory: any) => {\n if (factory === false) {\n if (typeof getter !== 'function') {\n throw new Error(\n getShortErrorMsg(\n RUNTIME_012,\n {\n [RUNTIME_012]:\n 'The getter for the shared module is not a function. This may be caused by setting \"shared.import: false\" without the host providing the corresponding lib.',\n },\n { shareKey },\n ),\n );\n }\n return treeShakingGetter?.() || getter();\n }\n return factory;\n });\n\n if (promise.then) {\n promises.push(\n (installedModules[id] = promise.then(onFactory).catch(onError)),\n );\n } else {\n // @ts-ignore maintain previous logic\n onFactory(promise);\n }\n } catch (e) {\n onError(e);\n }\n });\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,SAAS,SAA0B;AACjD,sBAAqB,QAAQ;CAC7B,MAAM,EACJ,SACA,UACA,kBACA,gBACA,cACA,2BACE;AAEJ,qBAAoB,eAAe;AACnC,KAAI,eAAe,EAAE,cAAc,QAAQ,CACzC,cAAa,SAAS,SAAS,OAAO;AACpC,MAAI,eAAe,EAAE,kBAAkB,GAAG,CACxC,QAAO,SAAS,KAAK,iBAAiB,IAAoB;EAE5D,MAAM,aAAa,YAAuB;AACxC,oBAAiB,MAAM;AACvB,kBAAe,EAAE,OAAO,WAAW;AACjC,WAAO,eAAe,EAAE;IACxB,MAAM,SAAS,SAAS;IAExB,MAAM,EAAE,cAAc,uBAAuB;AAC7C,QACE,WAAW,aAAa,SACxB,UACA,OAAO,WAAW,SAElB,KAAI;AAEF,SACE,CAAC,OAAO,eAAe,QAAQ,IAC9B,OAAe,UAAU,OAE1B,CAAC,OAAe,QAAQ,UAAU,YAAY;aAEzC,GAAG;AAId,WAAO,UAAU;;;EAGrB,MAAM,WAAW,UAAmB;AAClC,UAAO,iBAAiB;AACxB,kBAAe,EAAE,OAAO,WAAW;AACjC,WAAO,eAAe,EAAE;AACxB,UAAM;;;AAGV,MAAI;GACF,MAAM,qBAAqB,eAAe,WAAW;AACrD,OAAI,CAAC,mBACH,OAAM,IAAI,MAAM,iCAAiC;GAEnD,MAAM,EAAE,UAAU,QAAQ,WAAW,sBACnC,uBAAuB;GACzB,MAAM,cAAc,eAAe,gBAAgB,SAAS;GAC5D,MAAM,kBAAmC,EAAE,GAAG,WAAW;AAGzD,OACE,MAAM,QAAQ,gBAAgB,MAAM,IACpC,MAAM,QAAQ,gBAAgB,MAAM,GAAG,CAEvC,iBAAgB,QAAQ,gBAAgB,MAAM;AAEhD,OAAI,YACF,iBAAgB,cAAc;IAC5B;IACA,OAAO,CAAC,mBAAmB,QAAQ,KAAK;IACzC;GAEH,MAAM,UAAU,mBACb,UAAU,UAAU,EACnB,iBACD,CAAC,CACD,MAAM,YAAiB;AACtB,QAAI,YAAY,OAAO;AACrB,SAAI,OAAO,WAAW,WACpB,OAAM,IAAI,MACR,iBACE,aACA,GACG,cACC,gKACH,EACD,EAAE,UAAU,CACb,CACF;AAEH,YAAO,qBAAqB,IAAI,QAAQ;;AAE1C,WAAO;KACP;AAEJ,OAAI,QAAQ,KACV,UAAS,KACN,iBAAiB,MAAM,QAAQ,KAAK,UAAU,CAAC,MAAM,QAAQ,CAC/D;OAGD,WAAU,QAAQ;WAEb,GAAG;AACV,WAAQ,EAAE;;GAEZ"}
@@ -0,0 +1,7 @@
1
+
2
+ //#region ../error-codes/dist/error-codes.mjs
3
+ const RUNTIME_012 = "RUNTIME-012";
4
+
5
+ //#endregion
6
+ exports.RUNTIME_012 = RUNTIME_012;
7
+ //# sourceMappingURL=error-codes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.cjs","names":[],"sources":["../../../../error-codes/dist/error-codes.mjs"],"sourcesContent":["//#region src/error-codes.ts\nconst RUNTIME_001 = \"RUNTIME-001\";\nconst RUNTIME_002 = \"RUNTIME-002\";\nconst RUNTIME_003 = \"RUNTIME-003\";\nconst RUNTIME_004 = \"RUNTIME-004\";\nconst RUNTIME_005 = \"RUNTIME-005\";\nconst RUNTIME_006 = \"RUNTIME-006\";\nconst RUNTIME_007 = \"RUNTIME-007\";\nconst RUNTIME_008 = \"RUNTIME-008\";\nconst RUNTIME_009 = \"RUNTIME-009\";\nconst RUNTIME_010 = \"RUNTIME-010\";\nconst RUNTIME_011 = \"RUNTIME-011\";\nconst RUNTIME_012 = \"RUNTIME-012\";\nconst TYPE_001 = \"TYPE-001\";\nconst BUILD_001 = \"BUILD-001\";\nconst BUILD_002 = \"BUILD-002\";\n\n//#endregion\nexport { BUILD_001, BUILD_002, RUNTIME_001, RUNTIME_002, RUNTIME_003, RUNTIME_004, RUNTIME_005, RUNTIME_006, RUNTIME_007, RUNTIME_008, RUNTIME_009, RUNTIME_010, RUNTIME_011, RUNTIME_012, TYPE_001 };\n//# sourceMappingURL=error-codes.mjs.map"],"mappings":";;AAYA,MAAM,cAAc"}
@@ -0,0 +1,6 @@
1
+ //#region ../error-codes/dist/error-codes.mjs
2
+ const RUNTIME_012 = "RUNTIME-012";
3
+
4
+ //#endregion
5
+ export { RUNTIME_012 };
6
+ //# sourceMappingURL=error-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.js","names":[],"sources":["../../../../error-codes/dist/error-codes.mjs"],"sourcesContent":["//#region src/error-codes.ts\nconst RUNTIME_001 = \"RUNTIME-001\";\nconst RUNTIME_002 = \"RUNTIME-002\";\nconst RUNTIME_003 = \"RUNTIME-003\";\nconst RUNTIME_004 = \"RUNTIME-004\";\nconst RUNTIME_005 = \"RUNTIME-005\";\nconst RUNTIME_006 = \"RUNTIME-006\";\nconst RUNTIME_007 = \"RUNTIME-007\";\nconst RUNTIME_008 = \"RUNTIME-008\";\nconst RUNTIME_009 = \"RUNTIME-009\";\nconst RUNTIME_010 = \"RUNTIME-010\";\nconst RUNTIME_011 = \"RUNTIME-011\";\nconst RUNTIME_012 = \"RUNTIME-012\";\nconst TYPE_001 = \"TYPE-001\";\nconst BUILD_001 = \"BUILD-001\";\nconst BUILD_002 = \"BUILD-002\";\n\n//#endregion\nexport { BUILD_001, BUILD_002, RUNTIME_001, RUNTIME_002, RUNTIME_003, RUNTIME_004, RUNTIME_005, RUNTIME_006, RUNTIME_007, RUNTIME_008, RUNTIME_009, RUNTIME_010, RUNTIME_011, RUNTIME_012, TYPE_001 };\n//# sourceMappingURL=error-codes.mjs.map"],"mappings":";AAYA,MAAM,cAAc"}
@@ -0,0 +1,16 @@
1
+
2
+ //#region ../error-codes/dist/getShortErrorMsg.mjs
3
+ const getDocsUrl = (errorCode) => {
4
+ return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split("-")[0].toLowerCase()}#${errorCode.toLowerCase()}`;
5
+ };
6
+ const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
7
+ const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
8
+ args && msg.push(`args: ${JSON.stringify(args)}`);
9
+ msg.push(getDocsUrl(errorCode));
10
+ originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);
11
+ return msg.join("\n");
12
+ };
13
+
14
+ //#endregion
15
+ exports.getShortErrorMsg = getShortErrorMsg;
16
+ //# sourceMappingURL=getShortErrorMsg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getShortErrorMsg.cjs","names":[],"sources":["../../../../error-codes/dist/getShortErrorMsg.mjs"],"sourcesContent":["//#region src/getShortErrorMsg.ts\nconst getDocsUrl = (errorCode) => {\n\treturn `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split(\"-\")[0].toLowerCase()}#${errorCode.toLowerCase()}`;\n};\nconst getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {\n\tconst msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];\n\targs && msg.push(`args: ${JSON.stringify(args)}`);\n\tmsg.push(getDocsUrl(errorCode));\n\toriginalErrorMsg && msg.push(`Original Error Message:\\n ${originalErrorMsg}`);\n\treturn msg.join(\"\\n\");\n};\n\n//#endregion\nexport { getShortErrorMsg };\n//# sourceMappingURL=getShortErrorMsg.mjs.map"],"mappings":";;AACA,MAAM,cAAc,cAAc;AACjC,QAAO,yFAAyF,UAAU,MAAM,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,UAAU,aAAa;;AAEjK,MAAM,oBAAoB,WAAW,cAAc,MAAM,qBAAqB;CAC7E,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,WAAW,CAAC,IAAI,YAAY;AAC1D,SAAQ,IAAI,KAAK,SAAS,KAAK,UAAU,KAAK,GAAG;AACjD,KAAI,KAAK,WAAW,UAAU,CAAC;AAC/B,qBAAoB,IAAI,KAAK,6BAA6B,mBAAmB;AAC7E,QAAO,IAAI,KAAK,KAAK"}
@@ -0,0 +1,15 @@
1
+ //#region ../error-codes/dist/getShortErrorMsg.mjs
2
+ const getDocsUrl = (errorCode) => {
3
+ return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split("-")[0].toLowerCase()}#${errorCode.toLowerCase()}`;
4
+ };
5
+ const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
6
+ const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
7
+ args && msg.push(`args: ${JSON.stringify(args)}`);
8
+ msg.push(getDocsUrl(errorCode));
9
+ originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);
10
+ return msg.join("\n");
11
+ };
12
+
13
+ //#endregion
14
+ export { getShortErrorMsg };
15
+ //# sourceMappingURL=getShortErrorMsg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getShortErrorMsg.js","names":[],"sources":["../../../../error-codes/dist/getShortErrorMsg.mjs"],"sourcesContent":["//#region src/getShortErrorMsg.ts\nconst getDocsUrl = (errorCode) => {\n\treturn `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split(\"-\")[0].toLowerCase()}#${errorCode.toLowerCase()}`;\n};\nconst getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {\n\tconst msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];\n\targs && msg.push(`args: ${JSON.stringify(args)}`);\n\tmsg.push(getDocsUrl(errorCode));\n\toriginalErrorMsg && msg.push(`Original Error Message:\\n ${originalErrorMsg}`);\n\treturn msg.join(\"\\n\");\n};\n\n//#endregion\nexport { getShortErrorMsg };\n//# sourceMappingURL=getShortErrorMsg.mjs.map"],"mappings":";AACA,MAAM,cAAc,cAAc;AACjC,QAAO,yFAAyF,UAAU,MAAM,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,UAAU,aAAa;;AAEjK,MAAM,oBAAoB,WAAW,cAAc,MAAM,qBAAqB;CAC7E,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,WAAW,CAAC,IAAI,YAAY;AAC1D,SAAQ,IAAI,KAAK,SAAS,KAAK,UAAU,KAAK,GAAG;AACjD,KAAI,KAAK,WAAW,UAAU,CAAC;AAC/B,qBAAoB,IAAI,KAAK,6BAA6B,mBAAmB;AAC7E,QAAO,IAAI,KAAK,KAAK"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "@module-federation/webpack-bundler-runtime",
4
- "version": "2.2.2",
4
+ "version": "2.3.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Module Federation Runtime for webpack",
@@ -26,8 +26,9 @@
26
26
  "module": "./dist/index.js",
27
27
  "types": "./dist/index.d.ts",
28
28
  "dependencies": {
29
- "@module-federation/runtime": "2.2.2",
30
- "@module-federation/sdk": "2.2.2"
29
+ "@module-federation/error-codes": "2.3.0",
30
+ "@module-federation/runtime": "2.3.0",
31
+ "@module-federation/sdk": "2.3.0"
31
32
  },
32
33
  "exports": {
33
34
  ".": {