remote-components 0.4.7 → 0.4.9

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 (95) hide show
  1. package/dist/{chunk-ZSIOEMB3.js → chunk-4XWEMPKO.js} +6 -6
  2. package/dist/chunk-4XWEMPKO.js.map +1 -0
  3. package/dist/{chunk-W2TLJBAA.cjs → chunk-6NAV4SCF.cjs} +362 -82
  4. package/dist/chunk-6NAV4SCF.cjs.map +1 -0
  5. package/dist/{chunk-JZRA6DPE.js → chunk-6NUHDFSH.js} +6 -53
  6. package/dist/chunk-6NUHDFSH.js.map +1 -0
  7. package/dist/{chunk-7AUERPZ6.cjs → chunk-EZG36EB4.cjs} +23 -23
  8. package/dist/{chunk-7AUERPZ6.cjs.map → chunk-EZG36EB4.cjs.map} +1 -1
  9. package/dist/{chunk-YOFJE3RL.cjs → chunk-J42V6HSP.cjs} +18 -18
  10. package/dist/{chunk-KTUPOJQQ.js → chunk-JYGC7T6L.js} +313 -33
  11. package/dist/chunk-JYGC7T6L.js.map +1 -0
  12. package/dist/{chunk-I7VKDF3E.cjs → chunk-SELGX4Y2.cjs} +4 -51
  13. package/dist/chunk-SELGX4Y2.cjs.map +1 -0
  14. package/dist/{chunk-CFZOLSLP.js → chunk-T6E2WPAB.js} +3 -3
  15. package/dist/{chunk-4MLJE6UP.cjs → chunk-VB64GQX7.cjs} +3 -3
  16. package/dist/{chunk-VWEKLTPJ.js → chunk-X6SKTJ5N.js} +3 -3
  17. package/dist/{chunk-4WHSX7WW.cjs → chunk-XPMI4K3U.cjs} +19 -19
  18. package/dist/{chunk-WGSS7TJP.js → chunk-ZJW3GQTP.js} +2 -2
  19. package/dist/config/nextjs.cjs +5 -5
  20. package/dist/config/nextjs.cjs.map +1 -1
  21. package/dist/config/nextjs.js +1 -1
  22. package/dist/config/nextjs.js.map +1 -1
  23. package/dist/host/html.cjs +19 -19
  24. package/dist/host/html.js +7 -7
  25. package/dist/host/nextjs/app/client-only.cjs +11 -11
  26. package/dist/host/nextjs/app/client-only.js +6 -6
  27. package/dist/host/react.cjs +7 -7
  28. package/dist/host/react.js +6 -6
  29. package/dist/internal/config/webpack/apply-shared-modules.cjs +8 -0
  30. package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -1
  31. package/dist/internal/config/webpack/apply-shared-modules.d.ts +6 -1
  32. package/dist/internal/config/webpack/apply-shared-modules.js +10 -0
  33. package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -1
  34. package/dist/internal/config/webpack/provider-adapter.cjs +85 -0
  35. package/dist/internal/config/webpack/provider-adapter.cjs.map +1 -0
  36. package/dist/internal/config/webpack/provider-adapter.d.ts +7 -0
  37. package/dist/internal/config/webpack/provider-adapter.js +64 -0
  38. package/dist/internal/config/webpack/provider-adapter.js.map +1 -0
  39. package/dist/internal/config/webpack/shared-module-resolver.cjs +73 -0
  40. package/dist/internal/config/webpack/shared-module-resolver.cjs.map +1 -0
  41. package/dist/internal/config/webpack/shared-module-resolver.d.ts +35 -0
  42. package/dist/internal/config/webpack/shared-module-resolver.js +50 -0
  43. package/dist/internal/config/webpack/shared-module-resolver.js.map +1 -0
  44. package/dist/internal/host/shared/provider.cjs +188 -0
  45. package/dist/internal/host/shared/provider.cjs.map +1 -0
  46. package/dist/internal/host/shared/provider.d.ts +71 -0
  47. package/dist/internal/host/shared/provider.js +161 -0
  48. package/dist/internal/host/shared/provider.js.map +1 -0
  49. package/dist/internal/host/shared/shared-broker.cjs +0 -30
  50. package/dist/internal/host/shared/shared-broker.cjs.map +1 -1
  51. package/dist/internal/host/shared/shared-broker.d.ts +1 -7
  52. package/dist/internal/host/shared/shared-broker.js +0 -29
  53. package/dist/internal/host/shared/shared-broker.js.map +1 -1
  54. package/dist/internal/host/shared/shared-module-resolver.cjs +6 -28
  55. package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -1
  56. package/dist/internal/host/shared/shared-module-resolver.d.ts +9 -31
  57. package/dist/internal/host/shared/shared-module-resolver.js +4 -28
  58. package/dist/internal/host/shared/shared-module-resolver.js.map +1 -1
  59. package/dist/internal/runtime/loaders/component-loader.cjs +3 -2
  60. package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
  61. package/dist/internal/runtime/loaders/component-loader.js +2 -4
  62. package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
  63. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
  64. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
  65. package/dist/internal/runtime/turbopack/module.cjs +40 -8
  66. package/dist/internal/runtime/turbopack/module.cjs.map +1 -1
  67. package/dist/internal/runtime/turbopack/module.d.ts +7 -0
  68. package/dist/internal/runtime/turbopack/module.js +40 -8
  69. package/dist/internal/runtime/turbopack/module.js.map +1 -1
  70. package/dist/internal/runtime/turbopack/shared-modules.cjs +22 -21
  71. package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
  72. package/dist/internal/runtime/turbopack/shared-modules.js +27 -24
  73. package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
  74. package/dist/{turbopack-KFQ3A7UU.cjs → turbopack-6BXAJGS5.cjs} +11 -11
  75. package/dist/{turbopack-A2TW7XKF.js → turbopack-WAERWSWW.js} +4 -4
  76. package/dist/{webpack-XYIZEJQX.cjs → webpack-VTSF2B2G.cjs} +11 -11
  77. package/dist/webpack-VTSF2B2G.cjs.map +1 -0
  78. package/dist/{webpack-UYL4UYZL.js → webpack-ZYOBNVFE.js} +6 -6
  79. package/dist/webpack-ZYOBNVFE.js.map +1 -0
  80. package/package.json +1 -1
  81. package/dist/chunk-I7VKDF3E.cjs.map +0 -1
  82. package/dist/chunk-JZRA6DPE.js.map +0 -1
  83. package/dist/chunk-KTUPOJQQ.js.map +0 -1
  84. package/dist/chunk-W2TLJBAA.cjs.map +0 -1
  85. package/dist/chunk-ZSIOEMB3.js.map +0 -1
  86. package/dist/webpack-UYL4UYZL.js.map +0 -1
  87. package/dist/webpack-XYIZEJQX.cjs.map +0 -1
  88. /package/dist/{chunk-YOFJE3RL.cjs.map → chunk-J42V6HSP.cjs.map} +0 -0
  89. /package/dist/{chunk-CFZOLSLP.js.map → chunk-T6E2WPAB.js.map} +0 -0
  90. /package/dist/{chunk-4MLJE6UP.cjs.map → chunk-VB64GQX7.cjs.map} +0 -0
  91. /package/dist/{chunk-VWEKLTPJ.js.map → chunk-X6SKTJ5N.js.map} +0 -0
  92. /package/dist/{chunk-4WHSX7WW.cjs.map → chunk-XPMI4K3U.cjs.map} +0 -0
  93. /package/dist/{chunk-WGSS7TJP.js.map → chunk-ZJW3GQTP.js.map} +0 -0
  94. /package/dist/{turbopack-KFQ3A7UU.cjs.map → turbopack-6BXAJGS5.cjs.map} +0 -0
  95. /package/dist/{turbopack-A2TW7XKF.js.map → turbopack-WAERWSWW.js.map} +0 -0
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
2
 
3
3
 
4
- var _chunk4WHSX7WWcjs = require('../../../chunk-4WHSX7WW.cjs');
4
+ var _chunkXPMI4K3Ucjs = require('../../../chunk-XPMI4K3U.cjs');
5
5
 
6
6
 
7
- var _chunk7AUERPZ6cjs = require('../../../chunk-7AUERPZ6.cjs');
8
- require('../../../chunk-4MLJE6UP.cjs');
9
- require('../../../chunk-YOFJE3RL.cjs');
10
- require('../../../chunk-W2TLJBAA.cjs');
7
+ var _chunkEZG36EB4cjs = require('../../../chunk-EZG36EB4.cjs');
8
+ require('../../../chunk-VB64GQX7.cjs');
9
+ require('../../../chunk-J42V6HSP.cjs');
10
+ require('../../../chunk-6NAV4SCF.cjs');
11
11
  require('../../../chunk-3AX5WLZD.cjs');
12
12
  require('../../../chunk-N3SQTOSE.cjs');
13
13
 
14
14
 
15
15
 
16
- var _chunkI7VKDF3Ecjs = require('../../../chunk-I7VKDF3E.cjs');
16
+ var _chunkSELGX4Y2cjs = require('../../../chunk-SELGX4Y2.cjs');
17
17
  require('../../../chunk-Z2SLBFQL.cjs');
18
18
  require('../../../chunk-5KTAEO52.cjs');
19
19
 
@@ -31,8 +31,8 @@ var _react = require('react');
31
31
  function resolveForBundle(unbound, bundle) {
32
32
  if (!unbound)
33
33
  return void 0;
34
- const remoteSrc = _nullishCoalesce(_optionalChain([_chunkI7VKDF3Ecjs.getScope.call(void 0, bundle), 'optionalAccess', _2 => _2.url, 'access', _3 => _3.href]), () => ( ""));
35
- return _chunk7AUERPZ6cjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
34
+ const remoteSrc = _nullishCoalesce(_optionalChain([_chunkSELGX4Y2cjs.getScope.call(void 0, bundle), 'optionalAccess', _2 => _2.url, 'access', _3 => _3.href]), () => ( ""));
35
+ return _chunkEZG36EB4cjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
36
36
  }
37
37
  function createImageLoaderSharedEntries({
38
38
  bound,
@@ -41,13 +41,13 @@ function createImageLoaderSharedEntries({
41
41
  const loaderEntry = (bundle) => {
42
42
  const resolveClientUrl = _nullishCoalesce(bound, () => ( resolveForBundle(unbound, bundle)));
43
43
  return Promise.resolve({
44
- default: _chunkI7VKDF3Ecjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl),
44
+ default: _chunkSELGX4Y2cjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl),
45
45
  __esModule: true
46
46
  });
47
47
  };
48
48
  const imageEntry = async (bundle) => {
49
49
  const resolveClientUrl = _nullishCoalesce(bound, () => ( resolveForBundle(unbound, bundle)));
50
- const rawLoader = _chunkI7VKDF3Ecjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl);
50
+ const rawLoader = _chunkSELGX4Y2cjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl);
51
51
  const remoteLoader = Object.assign(
52
52
  (p) => rawLoader({ ...p, config: { path: "/_next/image" } }),
53
53
  { __next_img_default: true }
@@ -191,7 +191,7 @@ function ConsumeRemoteComponent2(props) {
191
191
  return _nullishCoalesce(props.children, () => ( null));
192
192
  }
193
193
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
194
- _chunk4WHSX7WWcjs.ConsumeRemoteComponent,
194
+ _chunkXPMI4K3Ucjs.ConsumeRemoteComponent,
195
195
  {
196
196
  ...props,
197
197
  shared: sharedModules(props.shared, props.resolveClientUrl)
@@ -1,19 +1,19 @@
1
1
  "use client";
2
2
  import {
3
3
  ConsumeRemoteComponent
4
- } from "../../../chunk-CFZOLSLP.js";
4
+ } from "../../../chunk-T6E2WPAB.js";
5
5
  import {
6
6
  bindResolveClientUrl
7
- } from "../../../chunk-ZSIOEMB3.js";
8
- import "../../../chunk-WGSS7TJP.js";
9
- import "../../../chunk-VWEKLTPJ.js";
10
- import "../../../chunk-KTUPOJQQ.js";
7
+ } from "../../../chunk-4XWEMPKO.js";
8
+ import "../../../chunk-ZJW3GQTP.js";
9
+ import "../../../chunk-X6SKTJ5N.js";
10
+ import "../../../chunk-JYGC7T6L.js";
11
11
  import "../../../chunk-LEKG4YWI.js";
12
12
  import "../../../chunk-RHGEBXPL.js";
13
13
  import {
14
14
  createRemoteImageLoader,
15
15
  getScope
16
- } from "../../../chunk-JZRA6DPE.js";
16
+ } from "../../../chunk-6NUHDFSH.js";
17
17
  import "../../../chunk-D5GNZB6O.js";
18
18
  import "../../../chunk-STIJO4AG.js";
19
19
  import {
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunk4WHSX7WWcjs = require('../chunk-4WHSX7WW.cjs');
5
- require('../chunk-7AUERPZ6.cjs');
6
- require('../chunk-4MLJE6UP.cjs');
7
- require('../chunk-YOFJE3RL.cjs');
8
- require('../chunk-W2TLJBAA.cjs');
4
+ var _chunkXPMI4K3Ucjs = require('../chunk-XPMI4K3U.cjs');
5
+ require('../chunk-EZG36EB4.cjs');
6
+ require('../chunk-VB64GQX7.cjs');
7
+ require('../chunk-J42V6HSP.cjs');
8
+ require('../chunk-6NAV4SCF.cjs');
9
9
  require('../chunk-3AX5WLZD.cjs');
10
10
  require('../chunk-N3SQTOSE.cjs');
11
- require('../chunk-I7VKDF3E.cjs');
11
+ require('../chunk-SELGX4Y2.cjs');
12
12
  require('../chunk-Z2SLBFQL.cjs');
13
13
  require('../chunk-5KTAEO52.cjs');
14
14
  require('../chunk-BBXVML3D.cjs');
@@ -18,5 +18,5 @@ require('../chunk-SHFJ5OQA.cjs');
18
18
 
19
19
 
20
20
 
21
- exports.ConsumeRemoteComponent = _chunk4WHSX7WWcjs.ConsumeRemoteComponent; exports.useRemoteNavigate = _chunk4WHSX7WWcjs.useRemoteNavigate;
21
+ exports.ConsumeRemoteComponent = _chunkXPMI4K3Ucjs.ConsumeRemoteComponent; exports.useRemoteNavigate = _chunkXPMI4K3Ucjs.useRemoteNavigate;
22
22
  //# sourceMappingURL=react.cjs.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  ConsumeRemoteComponent,
3
3
  useRemoteNavigate
4
- } from "../chunk-CFZOLSLP.js";
5
- import "../chunk-ZSIOEMB3.js";
6
- import "../chunk-WGSS7TJP.js";
7
- import "../chunk-VWEKLTPJ.js";
8
- import "../chunk-KTUPOJQQ.js";
4
+ } from "../chunk-T6E2WPAB.js";
5
+ import "../chunk-4XWEMPKO.js";
6
+ import "../chunk-ZJW3GQTP.js";
7
+ import "../chunk-X6SKTJ5N.js";
8
+ import "../chunk-JYGC7T6L.js";
9
9
  import "../chunk-LEKG4YWI.js";
10
10
  import "../chunk-RHGEBXPL.js";
11
- import "../chunk-JZRA6DPE.js";
11
+ import "../chunk-6NUHDFSH.js";
12
12
  import "../chunk-D5GNZB6O.js";
13
13
  import "../chunk-STIJO4AG.js";
14
14
  import "../chunk-ULXU6XWH.js";
@@ -21,8 +21,11 @@ __export(apply_shared_modules_exports, {
21
21
  applySharedModules: () => applySharedModules
22
22
  });
23
23
  module.exports = __toCommonJS(apply_shared_modules_exports);
24
+ var import_shared_broker = require("#internal/host/shared/shared-broker");
24
25
  var import_remote_scope = require("#internal/runtime/turbopack/remote-scope");
25
26
  var import_logger = require("#internal/utils/logger");
27
+ var import_provider_adapter = require("./provider-adapter");
28
+ var import_shared_module_resolver = require("./shared-module-resolver");
26
29
  const DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
27
30
  function applySharedModules(bundle, resolve) {
28
31
  (0, import_logger.logDebug)(
@@ -33,6 +36,11 @@ function applySharedModules(bundle, resolve) {
33
36
  "SharedModules",
34
37
  `Shared modules to resolve: ${Object.keys(resolve)}`
35
38
  );
39
+ const metadata = resolve[import_shared_module_resolver.WEBPACK_SHARED_RESOLVE_METADATA];
40
+ if (metadata?.protocol === import_shared_broker.SHARED_MODULE_MANIFEST_PROTOCOL) {
41
+ (0, import_provider_adapter.applyWebpackSharedProviderModules)(bundle, metadata.entries);
42
+ return;
43
+ }
36
44
  const self = globalThis;
37
45
  const scope = (0, import_remote_scope.getScope)(bundle);
38
46
  const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/config/webpack/apply-shared-modules.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\n\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { logDebug, logWarn } from '#internal/utils/logger';\n\nconst DEDUPLICATION_SKIPPED =\n 'shared module deduplication skipped. The remote may load its own copy of shared dependencies.';\n\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n logDebug(\n 'SharedModules',\n `applySharedModules called for bundle: \"${bundle}\"`,\n );\n logDebug(\n 'SharedModules',\n `Shared modules to resolve: ${Object.keys(resolve)}`,\n );\n\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // Prefer scope-based access when available.\n const scope = getScope(bundle);\n // @legacy(v0.3.4) — fall back to global __remote_webpack_require__ for hosts that\n // haven't run setupWebpackRuntime yet (e.g. HTML host's inline path).\n // Remove once all host types go through the shared pipeline (Phase 5).\n const webpackBundle =\n scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];\n\n if (webpackBundle) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {},\n );\n logDebug(\n 'SharedModules',\n `Available module paths for bundle \"${bundle}\": ${modulePaths}`,\n );\n\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const exactIds = modulePaths.filter((p) => p === key);\n const ids =\n exactIds.length > 0\n ? exactIds\n : modulePaths.filter((p) => p.includes(key));\n\n if (ids.length === 0) {\n logDebug(\n 'SharedModules',\n `No matching module path found for shared module \"${key}\"`,\n );\n }\n\n for (const id of ids) {\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id]\n ? `${self.__remote_webpack_module_map__[bundle][id]}`\n : id;\n if (resolvedId !== id) {\n logDebug(\n 'SharedModules',\n `Mapped module id: \"${id}\" -> \"${resolvedId}\"`,\n );\n }\n // create a mock module which exports the shared module\n webpackBundle.m[resolvedId] = (module) => {\n module.exports = value;\n };\n } else {\n logWarn(\n 'SharedModules',\n `webpackBundle.m is not available for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n }\n }\n }\n } else {\n logWarn(\n 'SharedModules',\n `No webpack require found for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n logDebug(\n 'SharedModules',\n `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAyB;AACzB,oBAAkC;AAElC,MAAM,wBACJ;AAEK,SAAS,mBACd,QACA,SACA;AACA;AAAA,IACE;AAAA,IACA,0CAA0C;AAAA,EAC5C;AACA;AAAA,IACE;AAAA,IACA,8BAA8B,OAAO,KAAK,OAAO;AAAA,EACnD;AAGA,QAAM,OAAO;AAab,QAAM,YAAQ,8BAAS,MAAM;AAI7B,QAAM,gBACJ,OAAO,kBAAkB,KAAK,6BAA6B,MAAM;AAEnE,MAAI,eAAe;AACjB,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KAAK,cAAc,KAAK,CAAC;AAAA,IACtE;AACA;AAAA,MACE;AAAA,MACA,sCAAsC,YAAY;AAAA,IACpD;AAGA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,WAAW,YAAY,OAAO,CAAC,MAAM,MAAM,GAAG;AACpD,YAAM,MACJ,SAAS,SAAS,IACd,WACA,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AAE/C,UAAI,IAAI,WAAW,GAAG;AACpB;AAAA,UACE;AAAA,UACA,oDAAoD;AAAA,QACtD;AAAA,MACF;AAEA,iBAAW,MAAM,KAAK;AACpB,YAAI,cAAc,GAAG;AAGnB,gBAAM,aAAa,KAAK,gCAAgC,MAAM,IAAI,EAAE,IAChE,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE,MAChD;AACJ,cAAI,eAAe,IAAI;AACrB;AAAA,cACE;AAAA,cACA,sBAAsB,WAAW;AAAA,YACnC;AAAA,UACF;AAEA,wBAAc,EAAE,UAAU,IAAI,CAACA,YAAW;AACxC,YAAAA,QAAO,UAAU;AAAA,UACnB;AAAA,QACF,OAAO;AACL;AAAA,YACE;AAAA,YACA,gDAAgD,kBAAa;AAAA,UAC/D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AACL;AAAA,MACE;AAAA,MACA,wCAAwC,kBAAa;AAAA,IACvD;AACA;AAAA,MACE;AAAA,MACA,sBAAsB,OAAO,KAAK,KAAK,8BAA8B,CAAC,CAAC;AAAA,IACzE;AAAA,EACF;AACF;","names":["module"]}
1
+ {"version":3,"sources":["../../../../src/config/webpack/apply-shared-modules.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\n\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { logDebug, logWarn } from '#internal/utils/logger';\nimport { applyWebpackSharedProviderModules } from './provider-adapter';\nimport {\n WEBPACK_SHARED_RESOLVE_METADATA,\n type WebpackSharedResolveMap,\n} from './shared-module-resolver';\n\nconst DEDUPLICATION_SKIPPED =\n 'shared module deduplication skipped. The remote may load its own copy of shared dependencies.';\n\nexport function applySharedModules(\n bundle: string,\n resolve: WebpackSharedResolveMap,\n) {\n logDebug(\n 'SharedModules',\n `applySharedModules called for bundle: \"${bundle}\"`,\n );\n logDebug(\n 'SharedModules',\n `Shared modules to resolve: ${Object.keys(resolve)}`,\n );\n\n const metadata = resolve[WEBPACK_SHARED_RESOLVE_METADATA];\n if (metadata?.protocol === SHARED_MODULE_MANIFEST_PROTOCOL) {\n applyWebpackSharedProviderModules(bundle, metadata.entries);\n return;\n }\n\n // @legacy(remote-components<=0.4.x): direct resolve-map patching is only for\n // old remotes that do not emit sharedManifest. Manifest-aware remotes return\n // above and must stay on the strict provider path.\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // Prefer scope-based access when available.\n const scope = getScope(bundle);\n // @legacy(v0.3.4) — fall back to global __remote_webpack_require__ for hosts that\n // haven't run setupWebpackRuntime yet (e.g. HTML host's inline path).\n // Remove once all host types go through the shared pipeline (Phase 5).\n const webpackBundle =\n scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];\n\n if (webpackBundle) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {},\n );\n logDebug(\n 'SharedModules',\n `Available module paths for bundle \"${bundle}\": ${modulePaths}`,\n );\n\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const exactIds = modulePaths.filter((p) => p === key);\n const ids =\n exactIds.length > 0\n ? exactIds\n : modulePaths.filter((p) => p.includes(key));\n\n if (ids.length === 0) {\n logDebug(\n 'SharedModules',\n `No matching module path found for shared module \"${key}\"`,\n );\n }\n\n for (const id of ids) {\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id]\n ? `${self.__remote_webpack_module_map__[bundle][id]}`\n : id;\n if (resolvedId !== id) {\n logDebug(\n 'SharedModules',\n `Mapped module id: \"${id}\" -> \"${resolvedId}\"`,\n );\n }\n // create a mock module which exports the shared module\n webpackBundle.m[resolvedId] = (module) => {\n module.exports = value;\n };\n } else {\n logWarn(\n 'SharedModules',\n `webpackBundle.m is not available for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n }\n }\n }\n } else {\n logWarn(\n 'SharedModules',\n `No webpack require found for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n logDebug(\n 'SharedModules',\n `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,2BAAgD;AAChD,0BAAyB;AACzB,oBAAkC;AAClC,8BAAkD;AAClD,oCAGO;AAEP,MAAM,wBACJ;AAEK,SAAS,mBACd,QACA,SACA;AACA;AAAA,IACE;AAAA,IACA,0CAA0C;AAAA,EAC5C;AACA;AAAA,IACE;AAAA,IACA,8BAA8B,OAAO,KAAK,OAAO;AAAA,EACnD;AAEA,QAAM,WAAW,QAAQ,6DAA+B;AACxD,MAAI,UAAU,aAAa,sDAAiC;AAC1D,mEAAkC,QAAQ,SAAS,OAAO;AAC1D;AAAA,EACF;AAMA,QAAM,OAAO;AAab,QAAM,YAAQ,8BAAS,MAAM;AAI7B,QAAM,gBACJ,OAAO,kBAAkB,KAAK,6BAA6B,MAAM;AAEnE,MAAI,eAAe;AACjB,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KAAK,cAAc,KAAK,CAAC;AAAA,IACtE;AACA;AAAA,MACE;AAAA,MACA,sCAAsC,YAAY;AAAA,IACpD;AAGA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,WAAW,YAAY,OAAO,CAAC,MAAM,MAAM,GAAG;AACpD,YAAM,MACJ,SAAS,SAAS,IACd,WACA,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AAE/C,UAAI,IAAI,WAAW,GAAG;AACpB;AAAA,UACE;AAAA,UACA,oDAAoD;AAAA,QACtD;AAAA,MACF;AAEA,iBAAW,MAAM,KAAK;AACpB,YAAI,cAAc,GAAG;AAGnB,gBAAM,aAAa,KAAK,gCAAgC,MAAM,IAAI,EAAE,IAChE,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE,MAChD;AACJ,cAAI,eAAe,IAAI;AACrB;AAAA,cACE;AAAA,cACA,sBAAsB,WAAW;AAAA,YACnC;AAAA,UACF;AAEA,wBAAc,EAAE,UAAU,IAAI,CAACA,YAAW;AACxC,YAAAA,QAAO,UAAU;AAAA,UACnB;AAAA,QACF,OAAO;AACL;AAAA,YACE;AAAA,YACA,gDAAgD,kBAAa;AAAA,UAC/D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AACL;AAAA,MACE;AAAA,MACA,wCAAwC,kBAAa;AAAA,IACvD;AACA;AAAA,MACE;AAAA,MACA,sBAAsB,OAAO,KAAK,KAAK,8BAA8B,CAAC,CAAC;AAAA,IACzE;AAAA,EACF;AACF;","names":["module"]}
@@ -1,3 +1,8 @@
1
- declare function applySharedModules(bundle: string, resolve: Record<string, unknown>): void;
1
+ import { WebpackSharedResolveMap } from './shared-module-resolver.js';
2
+ import '../../host/shared/provider.js';
3
+ import '../../host/shared/shared-broker.js';
4
+ import '../../utils/logger.js';
5
+
6
+ declare function applySharedModules(bundle: string, resolve: WebpackSharedResolveMap): void;
2
7
 
3
8
  export { applySharedModules };
@@ -1,5 +1,10 @@
1
+ import { SHARED_MODULE_MANIFEST_PROTOCOL } from "#internal/host/shared/shared-broker";
1
2
  import { getScope } from "#internal/runtime/turbopack/remote-scope";
2
3
  import { logDebug, logWarn } from "#internal/utils/logger";
4
+ import { applyWebpackSharedProviderModules } from "./provider-adapter";
5
+ import {
6
+ WEBPACK_SHARED_RESOLVE_METADATA
7
+ } from "./shared-module-resolver";
3
8
  const DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
4
9
  function applySharedModules(bundle, resolve) {
5
10
  logDebug(
@@ -10,6 +15,11 @@ function applySharedModules(bundle, resolve) {
10
15
  "SharedModules",
11
16
  `Shared modules to resolve: ${Object.keys(resolve)}`
12
17
  );
18
+ const metadata = resolve[WEBPACK_SHARED_RESOLVE_METADATA];
19
+ if (metadata?.protocol === SHARED_MODULE_MANIFEST_PROTOCOL) {
20
+ applyWebpackSharedProviderModules(bundle, metadata.entries);
21
+ return;
22
+ }
13
23
  const self = globalThis;
14
24
  const scope = getScope(bundle);
15
25
  const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/config/webpack/apply-shared-modules.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\n\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { logDebug, logWarn } from '#internal/utils/logger';\n\nconst DEDUPLICATION_SKIPPED =\n 'shared module deduplication skipped. The remote may load its own copy of shared dependencies.';\n\nexport function applySharedModules(\n bundle: string,\n resolve: Record<string, unknown>,\n) {\n logDebug(\n 'SharedModules',\n `applySharedModules called for bundle: \"${bundle}\"`,\n );\n logDebug(\n 'SharedModules',\n `Shared modules to resolve: ${Object.keys(resolve)}`,\n );\n\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // Prefer scope-based access when available.\n const scope = getScope(bundle);\n // @legacy(v0.3.4) — fall back to global __remote_webpack_require__ for hosts that\n // haven't run setupWebpackRuntime yet (e.g. HTML host's inline path).\n // Remove once all host types go through the shared pipeline (Phase 5).\n const webpackBundle =\n scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];\n\n if (webpackBundle) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {},\n );\n logDebug(\n 'SharedModules',\n `Available module paths for bundle \"${bundle}\": ${modulePaths}`,\n );\n\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const exactIds = modulePaths.filter((p) => p === key);\n const ids =\n exactIds.length > 0\n ? exactIds\n : modulePaths.filter((p) => p.includes(key));\n\n if (ids.length === 0) {\n logDebug(\n 'SharedModules',\n `No matching module path found for shared module \"${key}\"`,\n );\n }\n\n for (const id of ids) {\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id]\n ? `${self.__remote_webpack_module_map__[bundle][id]}`\n : id;\n if (resolvedId !== id) {\n logDebug(\n 'SharedModules',\n `Mapped module id: \"${id}\" -> \"${resolvedId}\"`,\n );\n }\n // create a mock module which exports the shared module\n webpackBundle.m[resolvedId] = (module) => {\n module.exports = value;\n };\n } else {\n logWarn(\n 'SharedModules',\n `webpackBundle.m is not available for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n }\n }\n }\n } else {\n logWarn(\n 'SharedModules',\n `No webpack require found for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n logDebug(\n 'SharedModules',\n `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`,\n );\n }\n}\n"],"mappings":"AAMA,SAAS,gBAAgB;AACzB,SAAS,UAAU,eAAe;AAElC,MAAM,wBACJ;AAEK,SAAS,mBACd,QACA,SACA;AACA;AAAA,IACE;AAAA,IACA,0CAA0C;AAAA,EAC5C;AACA;AAAA,IACE;AAAA,IACA,8BAA8B,OAAO,KAAK,OAAO;AAAA,EACnD;AAGA,QAAM,OAAO;AAab,QAAM,QAAQ,SAAS,MAAM;AAI7B,QAAM,gBACJ,OAAO,kBAAkB,KAAK,6BAA6B,MAAM;AAEnE,MAAI,eAAe;AACjB,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KAAK,cAAc,KAAK,CAAC;AAAA,IACtE;AACA;AAAA,MACE;AAAA,MACA,sCAAsC,YAAY;AAAA,IACpD;AAGA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,WAAW,YAAY,OAAO,CAAC,MAAM,MAAM,GAAG;AACpD,YAAM,MACJ,SAAS,SAAS,IACd,WACA,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AAE/C,UAAI,IAAI,WAAW,GAAG;AACpB;AAAA,UACE;AAAA,UACA,oDAAoD;AAAA,QACtD;AAAA,MACF;AAEA,iBAAW,MAAM,KAAK;AACpB,YAAI,cAAc,GAAG;AAGnB,gBAAM,aAAa,KAAK,gCAAgC,MAAM,IAAI,EAAE,IAChE,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE,MAChD;AACJ,cAAI,eAAe,IAAI;AACrB;AAAA,cACE;AAAA,cACA,sBAAsB,WAAW;AAAA,YACnC;AAAA,UACF;AAEA,wBAAc,EAAE,UAAU,IAAI,CAAC,WAAW;AACxC,mBAAO,UAAU;AAAA,UACnB;AAAA,QACF,OAAO;AACL;AAAA,YACE;AAAA,YACA,gDAAgD,kBAAa;AAAA,UAC/D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AACL;AAAA,MACE;AAAA,MACA,wCAAwC,kBAAa;AAAA,IACvD;AACA;AAAA,MACE;AAAA,MACA,sBAAsB,OAAO,KAAK,KAAK,8BAA8B,CAAC,CAAC;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/config/webpack/apply-shared-modules.ts"],"sourcesContent":["// Webpack shared module patching\n// used in multiple remote component host types\n// multiple host types includes: HTML custom element for remote components and Next.js host application\n// we are using this shared function to patch a Webpack module map\n// to use shared modules between the host application and the remote component\n\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { logDebug, logWarn } from '#internal/utils/logger';\nimport { applyWebpackSharedProviderModules } from './provider-adapter';\nimport {\n WEBPACK_SHARED_RESOLVE_METADATA,\n type WebpackSharedResolveMap,\n} from './shared-module-resolver';\n\nconst DEDUPLICATION_SKIPPED =\n 'shared module deduplication skipped. The remote may load its own copy of shared dependencies.';\n\nexport function applySharedModules(\n bundle: string,\n resolve: WebpackSharedResolveMap,\n) {\n logDebug(\n 'SharedModules',\n `applySharedModules called for bundle: \"${bundle}\"`,\n );\n logDebug(\n 'SharedModules',\n `Shared modules to resolve: ${Object.keys(resolve)}`,\n );\n\n const metadata = resolve[WEBPACK_SHARED_RESOLVE_METADATA];\n if (metadata?.protocol === SHARED_MODULE_MANIFEST_PROTOCOL) {\n applyWebpackSharedProviderModules(bundle, metadata.entries);\n return;\n }\n\n // @legacy(remote-components<=0.4.x): direct resolve-map patching is only for\n // old remotes that do not emit sharedManifest. Manifest-aware remotes return\n // above and must stay on the strict provider path.\n // make a typed reference to the global scope\n const self = globalThis as typeof globalThis & {\n // webpack remote module loading function scoped for each bundle\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n // webpack module map for each bundle used in production builds\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n } & Record<string, string[]>;\n\n // Prefer scope-based access when available.\n const scope = getScope(bundle);\n // @legacy(v0.3.4) — fall back to global __remote_webpack_require__ for hosts that\n // haven't run setupWebpackRuntime yet (e.g. HTML host's inline path).\n // Remove once all host types go through the shared pipeline (Phase 5).\n const webpackBundle =\n scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];\n\n if (webpackBundle) {\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {},\n );\n logDebug(\n 'SharedModules',\n `Available module paths for bundle \"${bundle}\": ${modulePaths}`,\n );\n\n // patch all modules in the bundle to use the shared modules\n for (const [key, value] of Object.entries(resolve)) {\n const exactIds = modulePaths.filter((p) => p === key);\n const ids =\n exactIds.length > 0\n ? exactIds\n : modulePaths.filter((p) => p.includes(key));\n\n if (ids.length === 0) {\n logDebug(\n 'SharedModules',\n `No matching module path found for shared module \"${key}\"`,\n );\n }\n\n for (const id of ids) {\n if (webpackBundle.m) {\n // if we have a module map, we need to use the mapped id\n // this is required for production builds where the module ids are module id numbers\n const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id]\n ? `${self.__remote_webpack_module_map__[bundle][id]}`\n : id;\n if (resolvedId !== id) {\n logDebug(\n 'SharedModules',\n `Mapped module id: \"${id}\" -> \"${resolvedId}\"`,\n );\n }\n // create a mock module which exports the shared module\n webpackBundle.m[resolvedId] = (module) => {\n module.exports = value;\n };\n } else {\n logWarn(\n 'SharedModules',\n `webpackBundle.m is not available for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n }\n }\n }\n } else {\n logWarn(\n 'SharedModules',\n `No webpack require found for bundle \"${bundle}\" — ${DEDUPLICATION_SKIPPED}`,\n );\n logDebug(\n 'SharedModules',\n `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`,\n );\n }\n}\n"],"mappings":"AAMA,SAAS,uCAAuC;AAChD,SAAS,gBAAgB;AACzB,SAAS,UAAU,eAAe;AAClC,SAAS,yCAAyC;AAClD;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,wBACJ;AAEK,SAAS,mBACd,QACA,SACA;AACA;AAAA,IACE;AAAA,IACA,0CAA0C;AAAA,EAC5C;AACA;AAAA,IACE;AAAA,IACA,8BAA8B,OAAO,KAAK,OAAO;AAAA,EACnD;AAEA,QAAM,WAAW,QAAQ,+BAA+B;AACxD,MAAI,UAAU,aAAa,iCAAiC;AAC1D,sCAAkC,QAAQ,SAAS,OAAO;AAC1D;AAAA,EACF;AAMA,QAAM,OAAO;AAab,QAAM,QAAQ,SAAS,MAAM;AAI7B,QAAM,gBACJ,OAAO,kBAAkB,KAAK,6BAA6B,MAAM;AAEnE,MAAI,eAAe;AACjB,UAAM,cAAc,OAAO;AAAA,MACzB,KAAK,gCAAgC,MAAM,KAAK,cAAc,KAAK,CAAC;AAAA,IACtE;AACA;AAAA,MACE;AAAA,MACA,sCAAsC,YAAY;AAAA,IACpD;AAGA,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,YAAM,WAAW,YAAY,OAAO,CAAC,MAAM,MAAM,GAAG;AACpD,YAAM,MACJ,SAAS,SAAS,IACd,WACA,YAAY,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC;AAE/C,UAAI,IAAI,WAAW,GAAG;AACpB;AAAA,UACE;AAAA,UACA,oDAAoD;AAAA,QACtD;AAAA,MACF;AAEA,iBAAW,MAAM,KAAK;AACpB,YAAI,cAAc,GAAG;AAGnB,gBAAM,aAAa,KAAK,gCAAgC,MAAM,IAAI,EAAE,IAChE,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE,MAChD;AACJ,cAAI,eAAe,IAAI;AACrB;AAAA,cACE;AAAA,cACA,sBAAsB,WAAW;AAAA,YACnC;AAAA,UACF;AAEA,wBAAc,EAAE,UAAU,IAAI,CAAC,WAAW;AACxC,mBAAO,UAAU;AAAA,UACnB;AAAA,QACF,OAAO;AACL;AAAA,YACE;AAAA,YACA,gDAAgD,kBAAa;AAAA,UAC/D;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AACL;AAAA,MACE;AAAA,MACA,wCAAwC,kBAAa;AAAA,IACvD;AACA;AAAA,MACE;AAAA,MACA,sBAAsB,OAAO,KAAK,KAAK,8BAA8B,CAAC,CAAC;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var provider_adapter_exports = {};
20
+ __export(provider_adapter_exports, {
21
+ applyWebpackSharedProviderModules: () => applyWebpackSharedProviderModules
22
+ });
23
+ module.exports = __toCommonJS(provider_adapter_exports);
24
+ var import_provider = require("#internal/host/shared/provider");
25
+ var import_remote_scope = require("#internal/runtime/turbopack/remote-scope");
26
+ var import_error = require("#internal/utils/error");
27
+ var import_logger = require("#internal/utils/logger");
28
+ function applyWebpackSharedProviderModules(bundle, entries) {
29
+ (0, import_logger.logDebug)(
30
+ "SharedModules",
31
+ `applyWebpackSharedProviderModules called for bundle: "${bundle}"`
32
+ );
33
+ const self = globalThis;
34
+ const scope = (0, import_remote_scope.getScope)(bundle);
35
+ const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
36
+ if (!webpackBundle) {
37
+ throw new import_error.RemoteComponentsError(
38
+ `No Webpack require found for manifest-aware Remote Component bundle "${bundle}".`
39
+ );
40
+ }
41
+ if (!webpackBundle.m) {
42
+ throw new import_error.RemoteComponentsError(
43
+ `Webpack module factories are not available for manifest-aware Remote Component bundle "${bundle}".`
44
+ );
45
+ }
46
+ const modulePaths = Object.keys(
47
+ self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m
48
+ );
49
+ for (const entry of entries) {
50
+ (0, import_provider.installSharedProviderEntry)(entry);
51
+ const ids = resolveWebpackModuleIds(bundle, modulePaths, entry.id);
52
+ if (ids.length === 0) {
53
+ continue;
54
+ }
55
+ for (const id of ids) {
56
+ const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
57
+ webpackBundle.m[resolvedId] = (module2) => {
58
+ module2.exports = (0, import_provider.getSharedProviderModule)({
59
+ scope: entry.scope,
60
+ specifier: entry.specifier
61
+ });
62
+ };
63
+ }
64
+ }
65
+ }
66
+ function resolveWebpackModuleIds(bundle, modulePaths, id) {
67
+ const exactIds = modulePaths.filter((path) => path === id);
68
+ if (exactIds.length > 0) {
69
+ return exactIds;
70
+ }
71
+ const containedIds = modulePaths.filter((path) => path.includes(id));
72
+ if (containedIds.length > 0) {
73
+ return containedIds;
74
+ }
75
+ (0, import_logger.logDebug)(
76
+ "SharedModules",
77
+ `No matching module path found for manifest shared module "${id}" in bundle "${bundle}"`
78
+ );
79
+ return [];
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ applyWebpackSharedProviderModules
84
+ });
85
+ //# sourceMappingURL=provider-adapter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/config/webpack/provider-adapter.ts"],"sourcesContent":["import {\n getSharedProviderModule,\n installSharedProviderEntry,\n type SharedProviderEntry,\n} from '#internal/host/shared/provider';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { RemoteComponentsError } from '#internal/utils/error';\nimport { logDebug } from '#internal/utils/logger';\n\nexport function applyWebpackSharedProviderModules(\n bundle: string,\n entries: SharedProviderEntry[],\n) {\n logDebug(\n 'SharedModules',\n `applyWebpackSharedProviderModules called for bundle: \"${bundle}\"`,\n );\n\n const self = globalThis as typeof globalThis & {\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n };\n\n const scope = getScope(bundle);\n const webpackBundle =\n scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];\n\n if (!webpackBundle) {\n throw new RemoteComponentsError(\n `No Webpack require found for manifest-aware Remote Component bundle \"${bundle}\".`,\n );\n }\n\n if (!webpackBundle.m) {\n throw new RemoteComponentsError(\n `Webpack module factories are not available for manifest-aware Remote Component bundle \"${bundle}\".`,\n );\n }\n\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m,\n );\n\n for (const entry of entries) {\n installSharedProviderEntry(entry);\n\n const ids = resolveWebpackModuleIds(bundle, modulePaths, entry.id);\n if (ids.length === 0) {\n continue;\n }\n\n for (const id of ids) {\n const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id]\n ? `${self.__remote_webpack_module_map__[bundle][id]}`\n : id;\n\n webpackBundle.m[resolvedId] = (module) => {\n module.exports = getSharedProviderModule({\n scope: entry.scope,\n specifier: entry.specifier,\n });\n };\n }\n }\n}\n\nfunction resolveWebpackModuleIds(\n bundle: string,\n modulePaths: string[],\n id: string,\n): string[] {\n const exactIds = modulePaths.filter((path) => path === id);\n if (exactIds.length > 0) {\n return exactIds;\n }\n\n const containedIds = modulePaths.filter((path) => path.includes(id));\n if (containedIds.length > 0) {\n return containedIds;\n }\n\n logDebug(\n 'SharedModules',\n `No matching module path found for manifest shared module \"${id}\" in bundle \"${bundle}\"`,\n );\n return [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAIO;AACP,0BAAyB;AACzB,mBAAsC;AACtC,oBAAyB;AAElB,SAAS,kCACd,QACA,SACA;AACA;AAAA,IACE;AAAA,IACA,yDAAyD;AAAA,EAC3D;AAEA,QAAM,OAAO;AAUb,QAAM,YAAQ,8BAAS,MAAM;AAC7B,QAAM,gBACJ,OAAO,kBAAkB,KAAK,6BAA6B,MAAM;AAEnE,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI;AAAA,MACR,wEAAwE;AAAA,IAC1E;AAAA,EACF;AAEA,MAAI,CAAC,cAAc,GAAG;AACpB,UAAM,IAAI;AAAA,MACR,0FAA0F;AAAA,IAC5F;AAAA,EACF;AAEA,QAAM,cAAc,OAAO;AAAA,IACzB,KAAK,gCAAgC,MAAM,KAAK,cAAc;AAAA,EAChE;AAEA,aAAW,SAAS,SAAS;AAC3B,oDAA2B,KAAK;AAEhC,UAAM,MAAM,wBAAwB,QAAQ,aAAa,MAAM,EAAE;AACjE,QAAI,IAAI,WAAW,GAAG;AACpB;AAAA,IACF;AAEA,eAAW,MAAM,KAAK;AACpB,YAAM,aAAa,KAAK,gCAAgC,MAAM,IAAI,EAAE,IAChE,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE,MAChD;AAEJ,oBAAc,EAAE,UAAU,IAAI,CAACA,YAAW;AACxC,QAAAA,QAAO,cAAU,yCAAwB;AAAA,UACvC,OAAO,MAAM;AAAA,UACb,WAAW,MAAM;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBACP,QACA,aACA,IACU;AACV,QAAM,WAAW,YAAY,OAAO,CAAC,SAAS,SAAS,EAAE;AACzD,MAAI,SAAS,SAAS,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,YAAY,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;AACnE,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA;AAAA,IACE;AAAA,IACA,6DAA6D,kBAAkB;AAAA,EACjF;AACA,SAAO,CAAC;AACV;","names":["module"]}
@@ -0,0 +1,7 @@
1
+ import { SharedProviderEntry } from '../../host/shared/provider.js';
2
+ import '../../host/shared/shared-broker.js';
3
+ import '../../utils/logger.js';
4
+
5
+ declare function applyWebpackSharedProviderModules(bundle: string, entries: SharedProviderEntry[]): void;
6
+
7
+ export { applyWebpackSharedProviderModules };
@@ -0,0 +1,64 @@
1
+ import {
2
+ getSharedProviderModule,
3
+ installSharedProviderEntry
4
+ } from "#internal/host/shared/provider";
5
+ import { getScope } from "#internal/runtime/turbopack/remote-scope";
6
+ import { RemoteComponentsError } from "#internal/utils/error";
7
+ import { logDebug } from "#internal/utils/logger";
8
+ function applyWebpackSharedProviderModules(bundle, entries) {
9
+ logDebug(
10
+ "SharedModules",
11
+ `applyWebpackSharedProviderModules called for bundle: "${bundle}"`
12
+ );
13
+ const self = globalThis;
14
+ const scope = getScope(bundle);
15
+ const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
16
+ if (!webpackBundle) {
17
+ throw new RemoteComponentsError(
18
+ `No Webpack require found for manifest-aware Remote Component bundle "${bundle}".`
19
+ );
20
+ }
21
+ if (!webpackBundle.m) {
22
+ throw new RemoteComponentsError(
23
+ `Webpack module factories are not available for manifest-aware Remote Component bundle "${bundle}".`
24
+ );
25
+ }
26
+ const modulePaths = Object.keys(
27
+ self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m
28
+ );
29
+ for (const entry of entries) {
30
+ installSharedProviderEntry(entry);
31
+ const ids = resolveWebpackModuleIds(bundle, modulePaths, entry.id);
32
+ if (ids.length === 0) {
33
+ continue;
34
+ }
35
+ for (const id of ids) {
36
+ const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
37
+ webpackBundle.m[resolvedId] = (module) => {
38
+ module.exports = getSharedProviderModule({
39
+ scope: entry.scope,
40
+ specifier: entry.specifier
41
+ });
42
+ };
43
+ }
44
+ }
45
+ }
46
+ function resolveWebpackModuleIds(bundle, modulePaths, id) {
47
+ const exactIds = modulePaths.filter((path) => path === id);
48
+ if (exactIds.length > 0) {
49
+ return exactIds;
50
+ }
51
+ const containedIds = modulePaths.filter((path) => path.includes(id));
52
+ if (containedIds.length > 0) {
53
+ return containedIds;
54
+ }
55
+ logDebug(
56
+ "SharedModules",
57
+ `No matching module path found for manifest shared module "${id}" in bundle "${bundle}"`
58
+ );
59
+ return [];
60
+ }
61
+ export {
62
+ applyWebpackSharedProviderModules
63
+ };
64
+ //# sourceMappingURL=provider-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/config/webpack/provider-adapter.ts"],"sourcesContent":["import {\n getSharedProviderModule,\n installSharedProviderEntry,\n type SharedProviderEntry,\n} from '#internal/host/shared/provider';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport { RemoteComponentsError } from '#internal/utils/error';\nimport { logDebug } from '#internal/utils/logger';\n\nexport function applyWebpackSharedProviderModules(\n bundle: string,\n entries: SharedProviderEntry[],\n) {\n logDebug(\n 'SharedModules',\n `applyWebpackSharedProviderModules called for bundle: \"${bundle}\"`,\n );\n\n const self = globalThis as typeof globalThis & {\n __remote_webpack_require__?: Record<\n string,\n ((remoteId: string | number) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n }\n >;\n __remote_webpack_module_map__?: Record<string, Record<string, number>>;\n };\n\n const scope = getScope(bundle);\n const webpackBundle =\n scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];\n\n if (!webpackBundle) {\n throw new RemoteComponentsError(\n `No Webpack require found for manifest-aware Remote Component bundle \"${bundle}\".`,\n );\n }\n\n if (!webpackBundle.m) {\n throw new RemoteComponentsError(\n `Webpack module factories are not available for manifest-aware Remote Component bundle \"${bundle}\".`,\n );\n }\n\n const modulePaths = Object.keys(\n self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m,\n );\n\n for (const entry of entries) {\n installSharedProviderEntry(entry);\n\n const ids = resolveWebpackModuleIds(bundle, modulePaths, entry.id);\n if (ids.length === 0) {\n continue;\n }\n\n for (const id of ids) {\n const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id]\n ? `${self.__remote_webpack_module_map__[bundle][id]}`\n : id;\n\n webpackBundle.m[resolvedId] = (module) => {\n module.exports = getSharedProviderModule({\n scope: entry.scope,\n specifier: entry.specifier,\n });\n };\n }\n }\n}\n\nfunction resolveWebpackModuleIds(\n bundle: string,\n modulePaths: string[],\n id: string,\n): string[] {\n const exactIds = modulePaths.filter((path) => path === id);\n if (exactIds.length > 0) {\n return exactIds;\n }\n\n const containedIds = modulePaths.filter((path) => path.includes(id));\n if (containedIds.length > 0) {\n return containedIds;\n }\n\n logDebug(\n 'SharedModules',\n `No matching module path found for manifest shared module \"${id}\" in bundle \"${bundle}\"`,\n );\n return [];\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAElB,SAAS,kCACd,QACA,SACA;AACA;AAAA,IACE;AAAA,IACA,yDAAyD;AAAA,EAC3D;AAEA,QAAM,OAAO;AAUb,QAAM,QAAQ,SAAS,MAAM;AAC7B,QAAM,gBACJ,OAAO,kBAAkB,KAAK,6BAA6B,MAAM;AAEnE,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI;AAAA,MACR,wEAAwE;AAAA,IAC1E;AAAA,EACF;AAEA,MAAI,CAAC,cAAc,GAAG;AACpB,UAAM,IAAI;AAAA,MACR,0FAA0F;AAAA,IAC5F;AAAA,EACF;AAEA,QAAM,cAAc,OAAO;AAAA,IACzB,KAAK,gCAAgC,MAAM,KAAK,cAAc;AAAA,EAChE;AAEA,aAAW,SAAS,SAAS;AAC3B,+BAA2B,KAAK;AAEhC,UAAM,MAAM,wBAAwB,QAAQ,aAAa,MAAM,EAAE;AACjE,QAAI,IAAI,WAAW,GAAG;AACpB;AAAA,IACF;AAEA,eAAW,MAAM,KAAK;AACpB,YAAM,aAAa,KAAK,gCAAgC,MAAM,IAAI,EAAE,IAChE,GAAG,KAAK,8BAA8B,MAAM,EAAE,EAAE,MAChD;AAEJ,oBAAc,EAAE,UAAU,IAAI,CAAC,WAAW;AACxC,eAAO,UAAU,wBAAwB;AAAA,UACvC,OAAO,MAAM;AAAA,UACb,WAAW,MAAM;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,wBACP,QACA,aACA,IACU;AACV,QAAM,WAAW,YAAY,OAAO,CAAC,SAAS,SAAS,EAAE;AACzD,MAAI,SAAS,SAAS,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,YAAY,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;AACnE,MAAI,aAAa,SAAS,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA;AAAA,IACE;AAAA,IACA,6DAA6D,kBAAkB;AAAA,EACjF;AACA,SAAO,CAAC;AACV;","names":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var shared_module_resolver_exports = {};
20
+ __export(shared_module_resolver_exports, {
21
+ WEBPACK_SHARED_RESOLVE_METADATA: () => WEBPACK_SHARED_RESOLVE_METADATA,
22
+ buildWebpackResolve: () => buildWebpackResolve
23
+ });
24
+ module.exports = __toCommonJS(shared_module_resolver_exports);
25
+ var import_provider = require("#internal/host/shared/provider");
26
+ var import_shared_module_resolver = require("#internal/host/shared/shared-module-resolver");
27
+ const WEBPACK_SHARED_RESOLVE_METADATA = Symbol.for(
28
+ "remote-components.webpackSharedResolveMetadata"
29
+ );
30
+ function normalizeWebpackSharedId(id) {
31
+ return id.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "");
32
+ }
33
+ async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
34
+ const sharedProviderPlan = await (0, import_provider.buildSharedProviderPlan)({
35
+ bundle,
36
+ hostShared,
37
+ remoteShared,
38
+ callerTag,
39
+ normalizeId: normalizeWebpackSharedId,
40
+ additionalEntries: Object.entries(import_shared_module_resolver.CORE_REACT_SHARED_MODULE_IDS).map(
41
+ ([specifier, id]) => ({
42
+ id,
43
+ specifier,
44
+ value: reactModules[id],
45
+ required: true,
46
+ singleton: true,
47
+ scope: `remote:${bundle}`
48
+ })
49
+ )
50
+ });
51
+ const resolve = {
52
+ ...Object.fromEntries(
53
+ sharedProviderPlan.entries.map((entry) => [
54
+ entry.id,
55
+ entry.provider.get()
56
+ ])
57
+ )
58
+ };
59
+ Object.defineProperty(resolve, WEBPACK_SHARED_RESOLVE_METADATA, {
60
+ enumerable: false,
61
+ value: {
62
+ protocol: sharedProviderPlan.protocol,
63
+ entries: sharedProviderPlan.entries
64
+ }
65
+ });
66
+ return resolve;
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ WEBPACK_SHARED_RESOLVE_METADATA,
71
+ buildWebpackResolve
72
+ });
73
+ //# sourceMappingURL=shared-module-resolver.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/config/webpack/shared-module-resolver.ts"],"sourcesContent":["import {\n buildSharedProviderPlan,\n type SharedProviderEntry,\n} from '#internal/host/shared/provider';\nimport type {\n RemoteSharedModules,\n SHARED_MODULE_MANIFEST_PROTOCOL,\n SharedModuleFactory,\n} from '#internal/host/shared/shared-broker';\nimport { CORE_REACT_SHARED_MODULE_IDS } from '#internal/host/shared/shared-module-resolver';\nimport type { LogLocation } from '#internal/utils/logger';\n\n/**\n * React module instances keyed by Webpack module path, e.g.\n * `{ '/react/index.js': React }`. Passed into `buildWebpackResolve` so it\n * can populate the resolve map without importing React itself.\n */\nexport interface WebpackReactModules {\n '/react/index.js': unknown;\n '/react/jsx-dev-runtime.js': unknown;\n '/react/jsx-runtime.js': unknown;\n '/react-dom/index.js': unknown;\n '/react-dom/client.js': unknown;\n}\n\nexport const WEBPACK_SHARED_RESOLVE_METADATA = Symbol.for(\n 'remote-components.webpackSharedResolveMetadata',\n);\n\nexport type WebpackSharedResolveMap = Record<string, unknown> & {\n [WEBPACK_SHARED_RESOLVE_METADATA]?: {\n protocol: 'legacy' | typeof SHARED_MODULE_MANIFEST_PROTOCOL;\n entries: SharedProviderEntry[];\n };\n};\n\nfunction normalizeWebpackSharedId(id: string): string {\n return id.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '');\n}\n\n/**\n * Builds the `resolve` map passed to `applySharedModules` for the Webpack\n * runtime. Combines:\n * - Static React module path keys (`/react/index.js`, etc.)\n * - Remote shared modules matched against host shared, with `(ssr)/` prefix stripped\n *\n * After building the map, resolves any factory functions by awaiting them\n * with the given bundle name.\n */\nexport async function buildWebpackResolve(\n hostShared: Record<string, SharedModuleFactory | unknown>,\n remoteShared: RemoteSharedModules,\n bundle: string,\n reactModules: WebpackReactModules,\n callerTag: LogLocation = 'SharedModuleResolver',\n): Promise<WebpackSharedResolveMap> {\n const sharedProviderPlan = await buildSharedProviderPlan({\n bundle,\n hostShared,\n remoteShared,\n callerTag,\n normalizeId: normalizeWebpackSharedId,\n additionalEntries: Object.entries(CORE_REACT_SHARED_MODULE_IDS).map(\n ([specifier, id]) => ({\n id,\n specifier,\n value: reactModules[id as keyof WebpackReactModules],\n required: true,\n singleton: true,\n scope: `remote:${bundle}`,\n }),\n ),\n });\n // @legacy(remote-components<=0.4.x): keep the enumerable resolved-value map so\n // old applySharedModules callers can patch Webpack modules directly. Once\n // remotes without sharedManifest are unsupported, applySharedModules can read\n // only WEBPACK_SHARED_RESOLVE_METADATA and this object body can be empty.\n const resolve: WebpackSharedResolveMap = {\n ...Object.fromEntries(\n sharedProviderPlan.entries.map((entry) => [\n entry.id,\n entry.provider.get(),\n ]),\n ),\n };\n\n Object.defineProperty(resolve, WEBPACK_SHARED_RESOLVE_METADATA, {\n enumerable: false,\n value: {\n protocol: sharedProviderPlan.protocol,\n entries: sharedProviderPlan.entries,\n },\n });\n\n return resolve;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAGO;AAMP,oCAA6C;AAgBtC,MAAM,kCAAkC,OAAO;AAAA,EACpD;AACF;AASA,SAAS,yBAAyB,IAAoB;AACpD,SAAO,GAAG,QAAQ,gCAAgC,EAAE;AACtD;AAWA,eAAsB,oBACpB,YACA,cACA,QACA,cACA,YAAyB,wBACS;AAClC,QAAM,qBAAqB,UAAM,yCAAwB;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,mBAAmB,OAAO,QAAQ,0DAA4B,EAAE;AAAA,MAC9D,CAAC,CAAC,WAAW,EAAE,OAAO;AAAA,QACpB;AAAA,QACA;AAAA,QACA,OAAO,aAAa,EAA+B;AAAA,QACnD,UAAU;AAAA,QACV,WAAW;AAAA,QACX,OAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AAKD,QAAM,UAAmC;AAAA,IACvC,GAAG,OAAO;AAAA,MACR,mBAAmB,QAAQ,IAAI,CAAC,UAAU;AAAA,QACxC,MAAM;AAAA,QACN,MAAM,SAAS,IAAI;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,eAAe,SAAS,iCAAiC;AAAA,IAC9D,YAAY;AAAA,IACZ,OAAO;AAAA,MACL,UAAU,mBAAmB;AAAA,MAC7B,SAAS,mBAAmB;AAAA,IAC9B;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,35 @@
1
+ import { SharedProviderEntry } from '../../host/shared/provider.js';
2
+ import { SHARED_MODULE_MANIFEST_PROTOCOL, SharedModuleFactory, RemoteSharedModules } from '../../host/shared/shared-broker.js';
3
+ import { LogLocation } from '../../utils/logger.js';
4
+
5
+ /**
6
+ * React module instances keyed by Webpack module path, e.g.
7
+ * `{ '/react/index.js': React }`. Passed into `buildWebpackResolve` so it
8
+ * can populate the resolve map without importing React itself.
9
+ */
10
+ interface WebpackReactModules {
11
+ '/react/index.js': unknown;
12
+ '/react/jsx-dev-runtime.js': unknown;
13
+ '/react/jsx-runtime.js': unknown;
14
+ '/react-dom/index.js': unknown;
15
+ '/react-dom/client.js': unknown;
16
+ }
17
+ declare const WEBPACK_SHARED_RESOLVE_METADATA: unique symbol;
18
+ type WebpackSharedResolveMap = Record<string, unknown> & {
19
+ [WEBPACK_SHARED_RESOLVE_METADATA]?: {
20
+ protocol: 'legacy' | typeof SHARED_MODULE_MANIFEST_PROTOCOL;
21
+ entries: SharedProviderEntry[];
22
+ };
23
+ };
24
+ /**
25
+ * Builds the `resolve` map passed to `applySharedModules` for the Webpack
26
+ * runtime. Combines:
27
+ * - Static React module path keys (`/react/index.js`, etc.)
28
+ * - Remote shared modules matched against host shared, with `(ssr)/` prefix stripped
29
+ *
30
+ * After building the map, resolves any factory functions by awaiting them
31
+ * with the given bundle name.
32
+ */
33
+ declare function buildWebpackResolve(hostShared: Record<string, SharedModuleFactory | unknown>, remoteShared: RemoteSharedModules, bundle: string, reactModules: WebpackReactModules, callerTag?: LogLocation): Promise<WebpackSharedResolveMap>;
34
+
35
+ export { WEBPACK_SHARED_RESOLVE_METADATA, WebpackReactModules, WebpackSharedResolveMap, buildWebpackResolve };
@@ -0,0 +1,50 @@
1
+ import {
2
+ buildSharedProviderPlan
3
+ } from "#internal/host/shared/provider";
4
+ import { CORE_REACT_SHARED_MODULE_IDS } from "#internal/host/shared/shared-module-resolver";
5
+ const WEBPACK_SHARED_RESOLVE_METADATA = Symbol.for(
6
+ "remote-components.webpackSharedResolveMetadata"
7
+ );
8
+ function normalizeWebpackSharedId(id) {
9
+ return id.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "");
10
+ }
11
+ async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
12
+ const sharedProviderPlan = await buildSharedProviderPlan({
13
+ bundle,
14
+ hostShared,
15
+ remoteShared,
16
+ callerTag,
17
+ normalizeId: normalizeWebpackSharedId,
18
+ additionalEntries: Object.entries(CORE_REACT_SHARED_MODULE_IDS).map(
19
+ ([specifier, id]) => ({
20
+ id,
21
+ specifier,
22
+ value: reactModules[id],
23
+ required: true,
24
+ singleton: true,
25
+ scope: `remote:${bundle}`
26
+ })
27
+ )
28
+ });
29
+ const resolve = {
30
+ ...Object.fromEntries(
31
+ sharedProviderPlan.entries.map((entry) => [
32
+ entry.id,
33
+ entry.provider.get()
34
+ ])
35
+ )
36
+ };
37
+ Object.defineProperty(resolve, WEBPACK_SHARED_RESOLVE_METADATA, {
38
+ enumerable: false,
39
+ value: {
40
+ protocol: sharedProviderPlan.protocol,
41
+ entries: sharedProviderPlan.entries
42
+ }
43
+ });
44
+ return resolve;
45
+ }
46
+ export {
47
+ WEBPACK_SHARED_RESOLVE_METADATA,
48
+ buildWebpackResolve
49
+ };
50
+ //# sourceMappingURL=shared-module-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/config/webpack/shared-module-resolver.ts"],"sourcesContent":["import {\n buildSharedProviderPlan,\n type SharedProviderEntry,\n} from '#internal/host/shared/provider';\nimport type {\n RemoteSharedModules,\n SHARED_MODULE_MANIFEST_PROTOCOL,\n SharedModuleFactory,\n} from '#internal/host/shared/shared-broker';\nimport { CORE_REACT_SHARED_MODULE_IDS } from '#internal/host/shared/shared-module-resolver';\nimport type { LogLocation } from '#internal/utils/logger';\n\n/**\n * React module instances keyed by Webpack module path, e.g.\n * `{ '/react/index.js': React }`. Passed into `buildWebpackResolve` so it\n * can populate the resolve map without importing React itself.\n */\nexport interface WebpackReactModules {\n '/react/index.js': unknown;\n '/react/jsx-dev-runtime.js': unknown;\n '/react/jsx-runtime.js': unknown;\n '/react-dom/index.js': unknown;\n '/react-dom/client.js': unknown;\n}\n\nexport const WEBPACK_SHARED_RESOLVE_METADATA = Symbol.for(\n 'remote-components.webpackSharedResolveMetadata',\n);\n\nexport type WebpackSharedResolveMap = Record<string, unknown> & {\n [WEBPACK_SHARED_RESOLVE_METADATA]?: {\n protocol: 'legacy' | typeof SHARED_MODULE_MANIFEST_PROTOCOL;\n entries: SharedProviderEntry[];\n };\n};\n\nfunction normalizeWebpackSharedId(id: string): string {\n return id.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '');\n}\n\n/**\n * Builds the `resolve` map passed to `applySharedModules` for the Webpack\n * runtime. Combines:\n * - Static React module path keys (`/react/index.js`, etc.)\n * - Remote shared modules matched against host shared, with `(ssr)/` prefix stripped\n *\n * After building the map, resolves any factory functions by awaiting them\n * with the given bundle name.\n */\nexport async function buildWebpackResolve(\n hostShared: Record<string, SharedModuleFactory | unknown>,\n remoteShared: RemoteSharedModules,\n bundle: string,\n reactModules: WebpackReactModules,\n callerTag: LogLocation = 'SharedModuleResolver',\n): Promise<WebpackSharedResolveMap> {\n const sharedProviderPlan = await buildSharedProviderPlan({\n bundle,\n hostShared,\n remoteShared,\n callerTag,\n normalizeId: normalizeWebpackSharedId,\n additionalEntries: Object.entries(CORE_REACT_SHARED_MODULE_IDS).map(\n ([specifier, id]) => ({\n id,\n specifier,\n value: reactModules[id as keyof WebpackReactModules],\n required: true,\n singleton: true,\n scope: `remote:${bundle}`,\n }),\n ),\n });\n // @legacy(remote-components<=0.4.x): keep the enumerable resolved-value map so\n // old applySharedModules callers can patch Webpack modules directly. Once\n // remotes without sharedManifest are unsupported, applySharedModules can read\n // only WEBPACK_SHARED_RESOLVE_METADATA and this object body can be empty.\n const resolve: WebpackSharedResolveMap = {\n ...Object.fromEntries(\n sharedProviderPlan.entries.map((entry) => [\n entry.id,\n entry.provider.get(),\n ]),\n ),\n };\n\n Object.defineProperty(resolve, WEBPACK_SHARED_RESOLVE_METADATA, {\n enumerable: false,\n value: {\n protocol: sharedProviderPlan.protocol,\n entries: sharedProviderPlan.entries,\n },\n });\n\n return resolve;\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AAMP,SAAS,oCAAoC;AAgBtC,MAAM,kCAAkC,OAAO;AAAA,EACpD;AACF;AASA,SAAS,yBAAyB,IAAoB;AACpD,SAAO,GAAG,QAAQ,gCAAgC,EAAE;AACtD;AAWA,eAAsB,oBACpB,YACA,cACA,QACA,cACA,YAAyB,wBACS;AAClC,QAAM,qBAAqB,MAAM,wBAAwB;AAAA,IACvD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,mBAAmB,OAAO,QAAQ,4BAA4B,EAAE;AAAA,MAC9D,CAAC,CAAC,WAAW,EAAE,OAAO;AAAA,QACpB;AAAA,QACA;AAAA,QACA,OAAO,aAAa,EAA+B;AAAA,QACnD,UAAU;AAAA,QACV,WAAW;AAAA,QACX,OAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AAKD,QAAM,UAAmC;AAAA,IACvC,GAAG,OAAO;AAAA,MACR,mBAAmB,QAAQ,IAAI,CAAC,UAAU;AAAA,QACxC,MAAM;AAAA,QACN,MAAM,SAAS,IAAI;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,eAAe,SAAS,iCAAiC;AAAA,IAC9D,YAAY;AAAA,IACZ,OAAO;AAAA,MACL,UAAU,mBAAmB;AAAA,MAC7B,SAAS,mBAAmB;AAAA,IAC9B;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}