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
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunk7AUERPZ6cjs = require('./chunk-7AUERPZ6.cjs');
10
+ var _chunkEZG36EB4cjs = require('./chunk-EZG36EB4.cjs');
11
11
 
12
12
 
13
13
  var _chunk3AX5WLZDcjs = require('./chunk-3AX5WLZD.cjs');
@@ -21,7 +21,7 @@ var _chunkN3SQTOSEcjs = require('./chunk-N3SQTOSE.cjs');
21
21
 
22
22
 
23
23
 
24
- var _chunkI7VKDF3Ecjs = require('./chunk-I7VKDF3E.cjs');
24
+ var _chunkSELGX4Y2cjs = require('./chunk-SELGX4Y2.cjs');
25
25
 
26
26
 
27
27
  var _chunkZ2SLBFQLcjs = require('./chunk-Z2SLBFQL.cjs');
@@ -92,7 +92,7 @@ function setAttributesFromProps(el, props) {
92
92
  function useResolveClientUrl(prop, urlHref) {
93
93
  const { resolveClientUrl: contextValue } = _context.useRemoteComponentsContext.call(void 0, );
94
94
  const raw = _nullishCoalesce(prop, () => ( contextValue));
95
- return _react.useMemo.call(void 0, () => _chunk7AUERPZ6cjs.bindResolveClientUrl.call(void 0, raw, urlHref), [raw, urlHref]);
95
+ return _react.useMemo.call(void 0, () => _chunkEZG36EB4cjs.bindResolveClientUrl.call(void 0, raw, urlHref), [raw, urlHref]);
96
96
  }
97
97
 
98
98
  // src/host/react/hooks/use-shadow-root.ts
@@ -154,7 +154,7 @@ function getRemoteComponentHtml(html) {
154
154
  return ssrRemoteComponentContainer.innerHTML;
155
155
  }
156
156
  const remoteComponentContainer = temp.querySelectorAll(
157
- `div[data-bundle][data-route][data-runtime][id^="${_chunkI7VKDF3Ecjs.DEFAULT_COMPONENT_NAME}"],div[data-bundle][data-route],div#__next,remote-component:not([src])`
157
+ `div[data-bundle][data-route][data-runtime][id^="${_chunkSELGX4Y2cjs.DEFAULT_COMPONENT_NAME}"],div[data-bundle][data-route],div#__next,remote-component:not([src])`
158
158
  );
159
159
  if (remoteComponentContainer.length > 0) {
160
160
  return `${Array.from(temp.querySelectorAll("link,script")).map((link) => link.outerHTML).join("")}${Array.from(remoteComponentContainer).map((container) => container.outerHTML).join("")}`;
@@ -179,7 +179,7 @@ function ConsumeRemoteComponent({
179
179
  mode = "open",
180
180
  reset,
181
181
  credentials: credentialsProp,
182
- name: nameProp = _chunkI7VKDF3Ecjs.DEFAULT_COMPONENT_NAME,
182
+ name: nameProp = _chunkSELGX4Y2cjs.DEFAULT_COMPONENT_NAME,
183
183
  shared: sharedProp,
184
184
  children,
185
185
  onBeforeLoad,
@@ -195,22 +195,22 @@ function ConsumeRemoteComponent({
195
195
  const credentials = _nullishCoalesce(_nullishCoalesce(credentialsProp, () => ( contextCredentials)), () => ( "same-origin"));
196
196
  const shared = _nullishCoalesce(_nullishCoalesce(sharedProp, () => ( contextShared)), () => ( {}));
197
197
  const emitter = _react.useMemo.call(void 0,
198
- () => _chunk7AUERPZ6cjs.makeReactEmitter.call(void 0, { onBeforeLoad, onLoad, onError, onChange }),
198
+ () => _chunkEZG36EB4cjs.makeReactEmitter.call(void 0, { onBeforeLoad, onLoad, onError, onChange }),
199
199
  [onBeforeLoad, onLoad, onError, onChange]
200
200
  );
201
201
  const name = _react.useMemo.call(void 0,
202
- () => _chunk7AUERPZ6cjs.resolveNameFromSrc.call(void 0, src, nameProp),
202
+ () => _chunkEZG36EB4cjs.resolveNameFromSrc.call(void 0, src, nameProp),
203
203
  [src, nameProp]
204
204
  );
205
205
  const [data, setData] = _react.useState.call(void 0,
206
206
  null
207
207
  );
208
- const url = _react.useMemo.call(void 0, () => _chunk7AUERPZ6cjs.getClientOrServerUrl.call(void 0, src, DUMMY_FALLBACK), [src]);
208
+ const url = _react.useMemo.call(void 0, () => _chunkEZG36EB4cjs.getClientOrServerUrl.call(void 0, src, DUMMY_FALLBACK), [src]);
209
209
  const resolveClientUrl = useResolveClientUrl(resolveClientUrlProp, url.href);
210
210
  const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
211
- const keySuffix = `${_chunkI7VKDF3Ecjs.escapeString.call(void 0, id)}_${_chunkI7VKDF3Ecjs.escapeString.call(void 0,
211
+ const keySuffix = `${_chunkSELGX4Y2cjs.escapeString.call(void 0, id)}_${_chunkSELGX4Y2cjs.escapeString.call(void 0,
212
212
  _nullishCoalesce(_optionalChain([data, 'optionalAccess', _5 => _5.name]), () => ( name))
213
- )}_${_chunkI7VKDF3Ecjs.escapeString.call(void 0, instanceId)}`;
213
+ )}_${_chunkSELGX4Y2cjs.escapeString.call(void 0, instanceId)}`;
214
214
  const [remoteComponent, setRemoteComponent] = _react.useState.call(void 0, null);
215
215
  const { shadowRoot, shadowRootContainerRef } = useShadowRoot({
216
216
  isolate,
@@ -236,7 +236,7 @@ function ConsumeRemoteComponent({
236
236
  return elements;
237
237
  })() : []
238
238
  );
239
- const hostStateRef = _react.useRef.call(void 0, _chunk7AUERPZ6cjs.createHostState.call(void 0, ));
239
+ const hostStateRef = _react.useRef.call(void 0, _chunkEZG36EB4cjs.createHostState.call(void 0, ));
240
240
  const componentHydrationHtml = _react.useRef.call(void 0, null);
241
241
  const prevRemoteComponentContainerRef = _react.useRef.call(void 0, null);
242
242
  const unmountRef = _react.useRef.call(void 0, null);
@@ -302,7 +302,7 @@ function ConsumeRemoteComponent({
302
302
  _nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _29 => _29(url.href)]), () => ( url.href)),
303
303
  location.href
304
304
  );
305
- const res = await _chunk7AUERPZ6cjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
305
+ const res = await _chunkEZG36EB4cjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
306
306
  onRequest,
307
307
  onResponse,
308
308
  abortController: hostStateRef.current.abortController
@@ -321,7 +321,7 @@ function ConsumeRemoteComponent({
321
321
  const userShared = await shared;
322
322
  if (signal.aborted)
323
323
  return;
324
- const prepared = _chunk7AUERPZ6cjs.preparePipeline.call(void 0, {
324
+ const prepared = _chunkEZG36EB4cjs.preparePipeline.call(void 0, {
325
325
  html,
326
326
  name,
327
327
  url,
@@ -362,7 +362,7 @@ function ConsumeRemoteComponent({
362
362
  href: new URL(_nullishCoalesce(link.getAttribute("href"), () => ( link.href)), url).href,
363
363
  ...link.getAttributeNames().reduce((acc, key) => {
364
364
  if (key !== "href") {
365
- acc[_nullishCoalesce(_chunkI7VKDF3Ecjs.attrToProp[key], () => ( key))] = _nullishCoalesce(link.getAttribute(key), () => ( ""));
365
+ acc[_nullishCoalesce(_chunkSELGX4Y2cjs.attrToProp[key], () => ( key))] = _nullishCoalesce(link.getAttribute(key), () => ( ""));
366
366
  }
367
367
  return acc;
368
368
  }, {})
@@ -424,7 +424,7 @@ function ConsumeRemoteComponent({
424
424
  });
425
425
  self.__next_s = prevNextScripts;
426
426
  }
427
- const rscName = rsc ? `__remote_component_rsc_${_chunkI7VKDF3Ecjs.escapeString.call(void 0, id)}_${_chunkI7VKDF3Ecjs.escapeString.call(void 0,
427
+ const rscName = rsc ? `__remote_component_rsc_${_chunkSELGX4Y2cjs.escapeString.call(void 0, id)}_${_chunkSELGX4Y2cjs.escapeString.call(void 0,
428
428
  remoteName
429
429
  )}` : void 0;
430
430
  if (rsc) {
@@ -497,7 +497,7 @@ function ConsumeRemoteComponent({
497
497
  }
498
498
  hostStateRef.current.stage = "loaded";
499
499
  } else {
500
- const result = await _chunk7AUERPZ6cjs.loadPrepared.call(void 0, {
500
+ const result = await _chunkEZG36EB4cjs.loadPrepared.call(void 0, {
501
501
  prepared,
502
502
  url,
503
503
  signal,
@@ -566,8 +566,8 @@ function ConsumeRemoteComponent({
566
566
  const metadataJson = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
567
567
  name: _optionalChain([data, 'optionalAccess', _33 => _33.name]) || name,
568
568
  bundle: _optionalChain([data, 'optionalAccess', _34 => _34.bundle]) || "default",
569
- route: _optionalChain([data, 'optionalAccess', _35 => _35.route]) || _chunkI7VKDF3Ecjs.DEFAULT_ROUTE,
570
- runtime: hostStateRef.current.prevIsRemoteComponent ? _chunkI7VKDF3Ecjs.RUNTIME_SCRIPT : _optionalChain([data, 'optionalAccess', _36 => _36.runtime]) || _chunkI7VKDF3Ecjs.RUNTIME_WEBPACK
569
+ route: _optionalChain([data, 'optionalAccess', _35 => _35.route]) || _chunkSELGX4Y2cjs.DEFAULT_ROUTE,
570
+ runtime: hostStateRef.current.prevIsRemoteComponent ? _chunkSELGX4Y2cjs.RUNTIME_SCRIPT : _optionalChain([data, 'optionalAccess', _36 => _36.runtime]) || _chunkSELGX4Y2cjs.RUNTIME_WEBPACK
571
571
  }) });
572
572
  const resetStyle = reset ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
573
573
  const linksToRender = _optionalChain([data, 'optionalAccess', _37 => _37.links, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((link) => /* @__PURE__ */ _react.createElement.call(void 0,
@@ -679,4 +679,4 @@ function ConsumeRemoteComponent({
679
679
 
680
680
 
681
681
  exports.useRemoteNavigate = useRemoteNavigate; exports.ConsumeRemoteComponent = ConsumeRemoteComponent;
682
- //# sourceMappingURL=chunk-4WHSX7WW.cjs.map
682
+ //# sourceMappingURL=chunk-XPMI4K3U.cjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NEXT_BUNDLE_PATH_RE
3
- } from "./chunk-JZRA6DPE.js";
3
+ } from "./chunk-6NUHDFSH.js";
4
4
  import {
5
5
  RemoteComponentsError,
6
6
  failedProxiedAssetError,
@@ -55,4 +55,4 @@ async function loadScripts(scripts, resolveClientUrl) {
55
55
  export {
56
56
  loadScripts
57
57
  };
58
- //# sourceMappingURL=chunk-WGSS7TJP.js.map
58
+ //# sourceMappingURL=chunk-ZJW3GQTP.js.map
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkI7VKDF3Ecjs = require('../chunk-I7VKDF3E.cjs');
5
+ var _chunkSELGX4Y2cjs = require('../chunk-SELGX4Y2.cjs');
6
6
  require('../chunk-Z2SLBFQL.cjs');
7
7
  require('../chunk-5KTAEO52.cjs');
8
8
 
@@ -155,7 +155,7 @@ function withRemoteComponentsConfig(nextConfig, options) {
155
155
  ".remote-components/shared/pages-host.tsx"
156
156
  );
157
157
  const appShared = /* @__PURE__ */ new Set([
158
- ..._chunkI7VKDF3Ecjs.CORE_REACT_SHARED_KEYS,
158
+ ..._chunkSELGX4Y2cjs.CORE_REACT_SHARED_KEYS,
159
159
  "next/navigation",
160
160
  "next/dist/client/components/navigation",
161
161
  "next/link",
@@ -169,7 +169,7 @@ function withRemoteComponentsConfig(nextConfig, options) {
169
169
  ..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.shared]), () => ( []))
170
170
  ]);
171
171
  const pagesShared = /* @__PURE__ */ new Set([
172
- ..._chunkI7VKDF3Ecjs.CORE_REACT_SHARED_KEYS,
172
+ ..._chunkSELGX4Y2cjs.CORE_REACT_SHARED_KEYS,
173
173
  "next/router",
174
174
  "next/link",
175
175
  "next/dist/shared/lib/image-loader",
@@ -177,7 +177,7 @@ function withRemoteComponentsConfig(nextConfig, options) {
177
177
  "next/form",
178
178
  ..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.shared]), () => ( []))
179
179
  ]);
180
- const vendorShared = { ..._chunkI7VKDF3Ecjs.VENDOR_SHARED };
180
+ const vendorShared = { ..._chunkSELGX4Y2cjs.VENDOR_SHARED };
181
181
  const resolve = _enhancedresolve2.default.create.sync({
182
182
  conditionNames: ["browser", "import", "module", "require"],
183
183
  ..._fs.existsSync.call(void 0, _path.join.call(void 0, process.cwd(), "tsconfig.json")) ? {
@@ -248,7 +248,7 @@ ${sharedManifest ? `export const sharedManifest = ${sharedManifest};
248
248
  ).join(",\n");
249
249
  return generateSharedModule({
250
250
  sharedEntries,
251
- sharedManifest: `{ protocol: '${_chunkI7VKDF3Ecjs.SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [
251
+ sharedManifest: `{ protocol: '${_chunkSELGX4Y2cjs.SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [
252
252
  ${requirements}
253
253
  ] }`
254
254
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/nextjs/index.ts","../../src/utils/project-id.ts","../../src/utils/project-id-env.ts","../../src/config/webpack/nextjs.ts"],"names":["readFileSync","join","findUpSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAAS,UAAU,SAAS,QAAAC,OAAM,gBAAgB;AAClD,OAAO,qBAAqB;AAC5B,SAAS,cAAAC,mBAAkB;AAE3B,OAAO,gCAAgC;;;ACNvC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;;;ACGpB,SAAS,0BAA8C;AAC5D,SACE,QAAQ,IAAI,gCACZ,QAAQ,IAAI,uCACZ,QAAQ,IAAI,qBACZ;AAEJ;;;ADFO,SAAS,iBAAiB,aAA6B;AAC5D,QAAM,UAAU,wBAAwB;AACxC,MAAI;AAAS,WAAO;AAE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AM,kBAAkB,oBAAoB;AAC5C,QACE,CAAC,iBAAiB,UAAU;AAAA,MAC1B,WAAW;AAAA,QACT,cAAc;AAAA,UACZ,GAAG;AAAA,QACL;AAAA,MACF;AAAA,MACA,UAAU;AAAA,QACR,cAAc;AAAA,UACZ,8BAA8B;AAAA,QAChC;AAAA,MACF;AAAA,IACF,CAAC,EAAE,SACH;AACA;AAAA,QACE;AAAA,QACA;AAAA,MAEF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,UAAM,8BACJ,oBAAoB,UACpB,8BAA8B,eAAe;AAI/C,UAAM,0BAA0B,yCAAyC;AACzE,QAAI,6BAA6B;AAC/B;AAAA,QACE;AAAA,QACA,wCAAwC;AAAA,MAE1C;AAAA,IACF,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,MAEF;AAAA,IACF;AACA,eAAW,YAAY;AAAA,MACrB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,WAAW;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,MACA,GAAI,8BACA,EAAE,oBAAoB,wBAAwB,IAC9C,CAAC;AAAA,IACP;AACA,eAAW,WAAW;AAAA,MACpB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,UAAU;AAAA,QACxB,4CAA4C;AAAA,MAC9C;AAAA,IACF;AACA,oBAAgB;AAChB,WAAO;AAAA,EACT;AAGA,SAAO,UAAiB,YAAY;AAAA,IAClC,KAAK,EAAE,MAAM,UAAU;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { basename, dirname, join, relative } from 'node:path';\nimport enhancedResolve from 'enhanced-resolve';\nimport { findUpSync } from 'find-up';\nimport type { NextConfig } from 'next';\nimport TsConfigPathsWebpackPlugin from 'tsconfig-paths-webpack-plugin';\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport {\n CORE_REACT_SHARED_KEYS,\n VENDOR_SHARED,\n} from '#internal/host/shared/shared-module-resolver';\nimport { logDebug, logError, logWarn } from '#internal/utils/logger';\nimport { resolveProjectId } from '#internal/utils/project-id';\nimport { transform as webpackTransform } from '../webpack/nextjs';\n\nfunction getNextMajorVersion(): number | undefined {\n try {\n const nextPkgPath = findUpSync('node_modules/next/package.json', {\n cwd: process.cwd(),\n });\n if (!nextPkgPath) return undefined;\n const { version } = JSON.parse(readFileSync(nextPkgPath, 'utf8')) as {\n version: string;\n };\n const major = version.split('.')[0];\n return major ? Number.parseInt(major, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hasPagesDirectory(): boolean {\n return (\n existsSync(join(process.cwd(), 'pages')) ||\n existsSync(join(process.cwd(), 'src/pages'))\n );\n}\n\ninterface ZodSchema {\n safeParse: (data: unknown) => { success: boolean };\n}\n\n/**\n * Returns true when the installed Next.js version's config schema accepts\n * `turbopack.chunkLoadingGlobal`. The turbopack schema uses `z.strictObject`\n * so unrecognised keys fail — a successful parse means the field is present.\n *\n * Exported for unit testing.\n */\nexport function isChunkLoadingGlobalSupported(schema: ZodSchema): boolean {\n return schema.safeParse({ turbopack: { chunkLoadingGlobal: '__test__' } })\n .success;\n}\n\n/**\n * Loads `next/dist/server/config-schema.js` from the consuming app's own\n * `node_modules` (resolved from `process.cwd()`), not from the location of\n * this package. This ensures the schema reflects the exact Next.js version\n * installed in the app rather than whatever is hoisted to the workspace root.\n */\nfunction loadAppConfigSchema(): ZodSchema | undefined {\n try {\n const appRequire = createRequire(join(process.cwd(), 'package.json'));\n const mod = appRequire('next/dist/server/config-schema.js') as {\n configSchema: ZodSchema;\n };\n return mod.configSchema;\n } catch {\n return undefined;\n }\n}\n\nfunction readProjectPackageJson(): { name: string; type: string } {\n const defaults = { name: basename(process.cwd()), type: 'module' };\n try {\n const packageJsonPath = findUpSync('package.json', {\n cwd: process.cwd(),\n });\n if (packageJsonPath) {\n return {\n ...defaults,\n ...(JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n name: string;\n type: string;\n }),\n };\n }\n } catch {\n // noop\n }\n return defaults;\n}\n\ninterface WithRemoteComponentsOptions {\n /**\n * An array of package names that should be shared between the host and remote components.\n * This is useful for ensuring that both the host and remote components use the same version\n * of shared libraries.\n *\n * Essential packages are included by default: `react`, `react-dom`, `next/navigation`, `next/link`, `next/form`, `next/image` (loader only), and `next/script`.\n */\n shared?: string[];\n}\n\n/**\n * This function configures Next.js to support Remote Components.\n * You need to also use the `withMicrofrontends` function to extend your Next.js configuration.\n *\n * @param nextConfig - The Next.js configuration object.\n * @param options - Optional configuration for remote components.\n * @returns The modified Next.js configuration object with remote components support.\n *\n * @example\n *\n * ```js\n * import { withMicrofrontends } from '@vercel/microfrontends/next/config';\n * import { withRemoteComponentsConfig } from 'remote-components/config/nextjs';\n *\n * const nextConfig = {\n * // your Next.js configuration\n * };\n *\n * export default withRemoteComponentsConfig(\n * withMicrofrontends(nextConfig),\n * {\n * shared: ['some-package', 'another-package'],\n * },\n * );\n * ```\n */\nexport function withRemoteComponentsConfig(\n nextConfig: NextConfig,\n options?: WithRemoteComponentsOptions,\n) {\n const virtualRemoteComponentAppSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/app-remote.tsx',\n );\n const virtualRemoteComponentPagesSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/pages-remote.tsx',\n );\n const virtualRemoteComponentAppSharedHost = join(\n process.cwd(),\n '.remote-components/shared/app-host.tsx',\n );\n const virtualRemoteComponentPagesSharedHost = join(\n process.cwd(),\n '.remote-components/shared/pages-host.tsx',\n );\n\n const appShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/navigation',\n 'next/dist/client/components/navigation',\n 'next/link',\n 'next/dist/client/app-dir/link',\n 'next/form',\n 'next/dist/client/app-dir/form',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/dist/client/script',\n 'next/dist/build/polyfills/process',\n ...(options?.shared ?? []),\n ]);\n const pagesShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/router',\n 'next/link',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/form',\n ...(options?.shared ?? []),\n ]);\n\n const vendorShared = { ...VENDOR_SHARED };\n\n // resolve using enhanced-resolve\n // named import does not work with enhanced-resolve when using cjs\n // eslint-disable-next-line import/no-named-as-default-member\n const resolve = enhancedResolve.create.sync({\n conditionNames: ['browser', 'import', 'module', 'require'],\n ...(existsSync(join(process.cwd(), 'tsconfig.json'))\n ? {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n plugins: [\n new TsConfigPathsWebpackPlugin({\n configFile: join(process.cwd(), 'tsconfig.json'),\n }) as unknown as enhancedResolve.Plugin,\n ],\n }\n : {}),\n });\n\n const packageJson = readProjectPackageJson();\n\n const generateSharedModule = ({\n sharedEntries,\n sharedManifest,\n }: {\n sharedEntries: string[];\n sharedManifest?: string;\n }) => {\n const shared = sharedEntries.join('\\n');\n\n if (packageJson.type !== 'module') {\n const exports = [`shared: {\\n${shared}\\n}`];\n if (sharedManifest) {\n exports.push(`sharedManifest: ${sharedManifest}`);\n }\n return `'use client';\\nmodule.exports = {\\n${exports.join(',\\n')}\\n};\\n`;\n }\n\n return `'use client';\\nexport const shared = {\\n${shared}\\n};\\n${\n sharedManifest ? `export const sharedManifest = ${sharedManifest};\\n` : ''\n }`;\n };\n\n const resolveSharedPath = (moduleName: string): string | undefined => {\n try {\n const resolved = resolve(process.cwd(), moduleName);\n if (resolved) {\n return relative(process.cwd(), resolved).replace(\n /^(?<relative>\\.\\.\\/)+/,\n '',\n );\n }\n } catch {\n // if module resolution using enhanced-resolve fails, fallback to require.resolve called in the shared/remote file\n }\n };\n\n const sharedKeyExpression = (moduleName: string): string => {\n const path = resolveSharedPath(moduleName);\n return (\n vendorShared[moduleName] ??\n (path ? `'${path}'` : `require.resolve('${moduleName}')`)\n );\n };\n\n const generateSharedRemote = (sharedRemote: Set<string>) => {\n const sharedEntries = Array.from(sharedRemote).reduce<string[]>(\n (acc, curr) => {\n const id = sharedKeyExpression(curr);\n // @legacy(remote-components<=0.4.x): keep emitting the historical\n // shared map until hosts on 0.4.x are outside the compatibility window.\n acc.push(`[${id}]: '${curr}',`);\n acc.push(\n `['__remote_shared_module_${curr}']: () => import('${curr}'),`,\n );\n return acc;\n },\n [],\n );\n const requirements = Array.from(sharedRemote)\n .map(\n (curr) =>\n `{ id: ${sharedKeyExpression(curr)}, specifier: '${curr}', required: true, singleton: true }`,\n )\n .join(',\\n');\n return generateSharedModule({\n sharedEntries,\n sharedManifest: `{ protocol: '${SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [\\n${requirements}\\n] }`,\n });\n };\n const generateSharedHost = (sharedHost: Set<string>) =>\n generateSharedModule({\n sharedEntries: Array.from(sharedHost).reduce<string[]>((acc, curr) => {\n acc.push(`['${curr}']: () => import('${curr}'),`);\n return acc;\n }, []),\n });\n\n const appSharedRemote = generateSharedRemote(appShared);\n const pagesSharedRemote = generateSharedRemote(pagesShared);\n\n const appSharedHost = generateSharedHost(appShared);\n const pagesSharedHost = generateSharedHost(pagesShared);\n\n const emitSharedFiles = () => {\n mkdirSync(dirname(virtualRemoteComponentAppSharedRemote), {\n recursive: true,\n });\n\n writeFileSync(\n virtualRemoteComponentAppSharedRemote,\n appSharedRemote,\n 'utf-8',\n );\n writeFileSync(\n virtualRemoteComponentPagesSharedRemote,\n pagesSharedRemote,\n 'utf-8',\n );\n writeFileSync(virtualRemoteComponentAppSharedHost, appSharedHost, 'utf-8');\n writeFileSync(\n virtualRemoteComponentPagesSharedHost,\n pagesSharedHost,\n 'utf-8',\n );\n };\n\n nextConfig.transpilePackages = [\n ...(nextConfig.transpilePackages ?? []),\n 'remote-components',\n ];\n\n nextConfig.env = {\n ...nextConfig.env,\n REMOTE_COMPONENTS_CONFIGURED: '1',\n };\n\n const alias = {\n '#remote-components/remote/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedRemote,\n )}`,\n '#remote-components/remote/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedRemote,\n )}`,\n '#remote-components/host/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedHost,\n )}`,\n '#remote-components/host/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedHost,\n )}`,\n };\n\n const projectId = resolveProjectId(packageJson.name);\n process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;\n\n if (hasPagesDirectory()) {\n // Log instead of throwing for the version check because\n // withRemoteComponentsConfig is shared by both hosts and remotes.\n // Only Pages Router hosts are broken on Next.js < 16 — remotes\n // work fine and must not have their builds blocked.\n const nextMajor = getNextMajorVersion();\n if (nextMajor !== undefined && nextMajor < 16) {\n const log =\n process.env.NODE_ENV !== 'production' ||\n process.env.VERCEL_ENV === 'preview'\n ? logWarn\n : logDebug;\n log(\n 'Config',\n `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. ` +\n 'Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.',\n );\n }\n }\n\n if (process.env.TURBOPACK) {\n const appConfigSchema = loadAppConfigSchema();\n if (\n !appConfigSchema?.safeParse({\n turbopack: {\n resolveAlias: {\n ...alias,\n },\n },\n compiler: {\n defineServer: {\n REMOTE_COMPONENTS_PROJECT_ID: projectId,\n },\n },\n }).success\n ) {\n logError(\n 'Config',\n 'Turbopack support requires a Next.js version that includes `compiler.defineServer`. ' +\n 'Upgrade Next.js to continue using Remote Components with Turbopack.',\n );\n process.exit(1);\n }\n const chunkLoadingGlobalSupported =\n appConfigSchema !== undefined &&\n isChunkLoadingGlobalSupported(appConfigSchema);\n // Next.js auto-prefixes chunkLoadingGlobal with \"TURBOPACK_\" when the value\n // doesn't already start with it. We set the prefix ourselves so the final\n // global name is predictable: TURBOPACK_remote_chunk_loading_global_<id>.\n const chunkLoadingGlobalValue = `TURBOPACK_remote_chunk_loading_global_${projectId}`;\n if (chunkLoadingGlobalSupported) {\n logDebug(\n 'Config',\n `Turbopack chunkLoadingGlobal set to \"${chunkLoadingGlobalValue}\" — ` +\n 'chunks will use a build-time scoped global (no runtime TURBOPACK rename needed).',\n );\n } else {\n logDebug(\n 'Config',\n 'Turbopack chunkLoadingGlobal not supported by this Next.js version — ' +\n 'falling back to runtime TURBOPACK global rename.',\n );\n }\n nextConfig.turbopack = {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n ...alias,\n },\n ...(chunkLoadingGlobalSupported\n ? { chunkLoadingGlobal: chunkLoadingGlobalValue }\n : {}),\n };\n nextConfig.compiler = {\n ...nextConfig.compiler,\n defineServer: {\n ...nextConfig.compiler?.defineServer,\n 'process.env.REMOTE_COMPONENTS_PROJECT_ID': projectId,\n },\n };\n emitSharedFiles();\n return nextConfig;\n }\n\n // apply the webpack transform\n return webpackTransform(nextConfig, {\n app: { name: projectId },\n alias,\n emitSharedFiles,\n });\n}\n","import { readFileSync } from 'node:fs';\nimport { findUpSync } from 'find-up';\nimport { resolveProjectIdFromEnv } from './project-id-env';\n\n/**\n * Resolves the project ID using environment variables first, then\n * falling back to `.vercel/project.json` and finally the package name.\n * Node-only — requires file system access.\n */\nexport function resolveProjectId(packageName: string): string {\n const fromEnv = resolveProjectIdFromEnv();\n if (fromEnv) return fromEnv;\n\n try {\n const projectPath = findUpSync('.vercel/project.json', {\n cwd: process.cwd(),\n });\n if (projectPath) {\n return (\n JSON.parse(readFileSync(projectPath, 'utf8')) as { projectId: string }\n ).projectId;\n }\n } catch {\n // fallback below\n }\n\n return packageName;\n}\n","/**\n * Resolves the project ID from environment variables only.\n * Safe for edge/browser contexts where file system access is unavailable.\n */\nexport function resolveProjectIdFromEnv(): string | undefined {\n return (\n process.env.REMOTE_COMPONENTS_PROJECT_ID ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n process.env.VERCEL_PROJECT_ID ||\n undefined\n );\n}\n","import { join } from 'node:path';\nimport type { NextConfig } from 'next';\nimport type { WebpackOptionsNormalized } from 'webpack';\nimport { ConditionalExecPlugin } from './plugins/conditional-exec';\nimport { ModuleIdEmbedPlugin } from './plugins/module-id-embed';\nimport { PatchRequirePlugin } from './plugins/patch-require';\nimport { RemoteWebpackRequirePlugin } from './plugins/remote-webpack-require';\n\nexport function transform(\n nextConfig: NextConfig,\n {\n app,\n alias = {},\n emitSharedFiles = () => {\n // no-op by default\n },\n }: {\n app: { name: string };\n alias?: Record<string, string>;\n emitSharedFiles?: () => void;\n },\n) {\n const webpackConfig = nextConfig.webpack;\n\n nextConfig.webpack = (\n baseConfig: WebpackOptionsNormalized,\n webpackContext,\n ) => {\n // execute the client config first, otherwise their config may accidentally\n // overwrite our required config - leading to unexpected errors.\n const config = (\n typeof webpackConfig === 'function'\n ? (webpackConfig(baseConfig, webpackContext) ?? baseConfig)\n : baseConfig\n ) as WebpackOptionsNormalized;\n\n // remote component specific plugins\n config.plugins.push(\n new RemoteWebpackRequirePlugin(app.name),\n new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),\n new ConditionalExecPlugin(app.name),\n new PatchRequirePlugin(app.name),\n );\n if (!webpackContext.isServer) {\n // change the chunk loading global to avoid conflicts with other remote components\n config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;\n }\n\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve.alias,\n ...Object.fromEntries(\n Object.entries(alias).map(([key, value]) => [\n key,\n join(process.cwd(), value),\n ]),\n ),\n },\n };\n\n emitSharedFiles();\n return config;\n };\n\n return nextConfig;\n}\n"]}
1
+ {"version":3,"sources":["../../src/config/nextjs/index.ts","../../src/utils/project-id.ts","../../src/utils/project-id-env.ts","../../src/config/webpack/nextjs.ts"],"names":["readFileSync","join","findUpSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAA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UAAiB,YAAY;AAAA,IAClC,KAAK,EAAE,MAAM,UAAU;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { basename, dirname, join, relative } from 'node:path';\nimport enhancedResolve from 'enhanced-resolve';\nimport { findUpSync } from 'find-up';\nimport type { NextConfig } from 'next';\nimport TsConfigPathsWebpackPlugin from 'tsconfig-paths-webpack-plugin';\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport {\n CORE_REACT_SHARED_KEYS,\n VENDOR_SHARED,\n} from '#internal/host/shared/shared-module-resolver';\nimport { logDebug, logError, logWarn } from '#internal/utils/logger';\nimport { resolveProjectId } from '#internal/utils/project-id';\nimport { transform as webpackTransform } from '../webpack/nextjs';\n\nfunction getNextMajorVersion(): number | undefined {\n try {\n const nextPkgPath = findUpSync('node_modules/next/package.json', {\n cwd: process.cwd(),\n });\n if (!nextPkgPath) return undefined;\n const { version } = JSON.parse(readFileSync(nextPkgPath, 'utf8')) as {\n version: string;\n };\n const major = version.split('.')[0];\n return major ? Number.parseInt(major, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hasPagesDirectory(): boolean {\n return (\n existsSync(join(process.cwd(), 'pages')) ||\n existsSync(join(process.cwd(), 'src/pages'))\n );\n}\n\ninterface ZodSchema {\n safeParse: (data: unknown) => { success: boolean };\n}\n\n/**\n * Returns true when the installed Next.js version's config schema accepts\n * `turbopack.chunkLoadingGlobal`. The turbopack schema uses `z.strictObject`\n * so unrecognised keys fail — a successful parse means the field is present.\n *\n * Exported for unit testing.\n */\nexport function isChunkLoadingGlobalSupported(schema: ZodSchema): boolean {\n return schema.safeParse({ turbopack: { chunkLoadingGlobal: '__test__' } })\n .success;\n}\n\n/**\n * Loads `next/dist/server/config-schema.js` from the consuming app's own\n * `node_modules` (resolved from `process.cwd()`), not from the location of\n * this package. This ensures the schema reflects the exact Next.js version\n * installed in the app rather than whatever is hoisted to the workspace root.\n */\nfunction loadAppConfigSchema(): ZodSchema | undefined {\n try {\n const appRequire = createRequire(join(process.cwd(), 'package.json'));\n const mod = appRequire('next/dist/server/config-schema.js') as {\n configSchema: ZodSchema;\n };\n return mod.configSchema;\n } catch {\n return undefined;\n }\n}\n\nfunction readProjectPackageJson(): { name: string; type: string } {\n const defaults = { name: basename(process.cwd()), type: 'module' };\n try {\n const packageJsonPath = findUpSync('package.json', {\n cwd: process.cwd(),\n });\n if (packageJsonPath) {\n return {\n ...defaults,\n ...(JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n name: string;\n type: string;\n }),\n };\n }\n } catch {\n // noop\n }\n return defaults;\n}\n\ninterface WithRemoteComponentsOptions {\n /**\n * An array of package names that should be shared between the host and remote components.\n * This is useful for ensuring that both the host and remote components use the same version\n * of shared libraries.\n *\n * Essential packages are included by default: `react`, `react-dom`, `next/navigation`, `next/link`, `next/form`, `next/image` (loader only), and `next/script`.\n */\n shared?: string[];\n}\n\n/**\n * This function configures Next.js to support Remote Components.\n * You need to also use the `withMicrofrontends` function to extend your Next.js configuration.\n *\n * @param nextConfig - The Next.js configuration object.\n * @param options - Optional configuration for remote components.\n * @returns The modified Next.js configuration object with remote components support.\n *\n * @example\n *\n * ```js\n * import { withMicrofrontends } from '@vercel/microfrontends/next/config';\n * import { withRemoteComponentsConfig } from 'remote-components/config/nextjs';\n *\n * const nextConfig = {\n * // your Next.js configuration\n * };\n *\n * export default withRemoteComponentsConfig(\n * withMicrofrontends(nextConfig),\n * {\n * shared: ['some-package', 'another-package'],\n * },\n * );\n * ```\n */\nexport function withRemoteComponentsConfig(\n nextConfig: NextConfig,\n options?: WithRemoteComponentsOptions,\n) {\n const virtualRemoteComponentAppSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/app-remote.tsx',\n );\n const virtualRemoteComponentPagesSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/pages-remote.tsx',\n );\n const virtualRemoteComponentAppSharedHost = join(\n process.cwd(),\n '.remote-components/shared/app-host.tsx',\n );\n const virtualRemoteComponentPagesSharedHost = join(\n process.cwd(),\n '.remote-components/shared/pages-host.tsx',\n );\n\n const appShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/navigation',\n 'next/dist/client/components/navigation',\n 'next/link',\n 'next/dist/client/app-dir/link',\n 'next/form',\n 'next/dist/client/app-dir/form',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/dist/client/script',\n 'next/dist/build/polyfills/process',\n ...(options?.shared ?? []),\n ]);\n const pagesShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/router',\n 'next/link',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/form',\n ...(options?.shared ?? []),\n ]);\n\n const vendorShared = { ...VENDOR_SHARED };\n\n // resolve using enhanced-resolve\n // named import does not work with enhanced-resolve when using cjs\n // eslint-disable-next-line import/no-named-as-default-member\n const resolve = enhancedResolve.create.sync({\n conditionNames: ['browser', 'import', 'module', 'require'],\n ...(existsSync(join(process.cwd(), 'tsconfig.json'))\n ? {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n plugins: [\n new TsConfigPathsWebpackPlugin({\n configFile: join(process.cwd(), 'tsconfig.json'),\n }) as unknown as enhancedResolve.Plugin,\n ],\n }\n : {}),\n });\n\n const packageJson = readProjectPackageJson();\n\n const generateSharedModule = ({\n sharedEntries,\n sharedManifest,\n }: {\n sharedEntries: string[];\n sharedManifest?: string;\n }) => {\n const shared = sharedEntries.join('\\n');\n\n if (packageJson.type !== 'module') {\n const exports = [`shared: {\\n${shared}\\n}`];\n if (sharedManifest) {\n exports.push(`sharedManifest: ${sharedManifest}`);\n }\n return `'use client';\\nmodule.exports = {\\n${exports.join(',\\n')}\\n};\\n`;\n }\n\n return `'use client';\\nexport const shared = {\\n${shared}\\n};\\n${\n sharedManifest ? `export const sharedManifest = ${sharedManifest};\\n` : ''\n }`;\n };\n\n const resolveSharedPath = (moduleName: string): string | undefined => {\n try {\n const resolved = resolve(process.cwd(), moduleName);\n if (resolved) {\n return relative(process.cwd(), resolved).replace(\n /^(?<relative>\\.\\.\\/)+/,\n '',\n );\n }\n } catch {\n // if module resolution using enhanced-resolve fails, fallback to require.resolve called in the shared/remote file\n }\n };\n\n const sharedKeyExpression = (moduleName: string): string => {\n const path = resolveSharedPath(moduleName);\n return (\n vendorShared[moduleName] ??\n (path ? `'${path}'` : `require.resolve('${moduleName}')`)\n );\n };\n\n const generateSharedRemote = (sharedRemote: Set<string>) => {\n const sharedEntries = Array.from(sharedRemote).reduce<string[]>(\n (acc, curr) => {\n const id = sharedKeyExpression(curr);\n // @legacy(remote-components<=0.4.x): keep emitting the historical\n // [module id]: specifier shared map until hosts on 0.4.x are outside\n // the compatibility window. The sharedManifest below is the primary\n // contract for new hosts.\n acc.push(`[${id}]: '${curr}',`);\n acc.push(\n `['__remote_shared_module_${curr}']: () => import('${curr}'),`,\n );\n return acc;\n },\n [],\n );\n const requirements = Array.from(sharedRemote)\n .map(\n (curr) =>\n `{ id: ${sharedKeyExpression(curr)}, specifier: '${curr}', required: true, singleton: true }`,\n )\n .join(',\\n');\n return generateSharedModule({\n sharedEntries,\n sharedManifest: `{ protocol: '${SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [\\n${requirements}\\n] }`,\n });\n };\n const generateSharedHost = (sharedHost: Set<string>) =>\n generateSharedModule({\n sharedEntries: Array.from(sharedHost).reduce<string[]>((acc, curr) => {\n acc.push(`['${curr}']: () => import('${curr}'),`);\n return acc;\n }, []),\n });\n\n const appSharedRemote = generateSharedRemote(appShared);\n const pagesSharedRemote = generateSharedRemote(pagesShared);\n\n const appSharedHost = generateSharedHost(appShared);\n const pagesSharedHost = generateSharedHost(pagesShared);\n\n const emitSharedFiles = () => {\n mkdirSync(dirname(virtualRemoteComponentAppSharedRemote), {\n recursive: true,\n });\n\n writeFileSync(\n virtualRemoteComponentAppSharedRemote,\n appSharedRemote,\n 'utf-8',\n );\n writeFileSync(\n virtualRemoteComponentPagesSharedRemote,\n pagesSharedRemote,\n 'utf-8',\n );\n writeFileSync(virtualRemoteComponentAppSharedHost, appSharedHost, 'utf-8');\n writeFileSync(\n virtualRemoteComponentPagesSharedHost,\n pagesSharedHost,\n 'utf-8',\n );\n };\n\n nextConfig.transpilePackages = [\n ...(nextConfig.transpilePackages ?? []),\n 'remote-components',\n ];\n\n nextConfig.env = {\n ...nextConfig.env,\n REMOTE_COMPONENTS_CONFIGURED: '1',\n };\n\n const alias = {\n '#remote-components/remote/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedRemote,\n )}`,\n '#remote-components/remote/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedRemote,\n )}`,\n '#remote-components/host/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedHost,\n )}`,\n '#remote-components/host/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedHost,\n )}`,\n };\n\n const projectId = resolveProjectId(packageJson.name);\n process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;\n\n if (hasPagesDirectory()) {\n // Log instead of throwing for the version check because\n // withRemoteComponentsConfig is shared by both hosts and remotes.\n // Only Pages Router hosts are broken on Next.js < 16 — remotes\n // work fine and must not have their builds blocked.\n const nextMajor = getNextMajorVersion();\n if (nextMajor !== undefined && nextMajor < 16) {\n const log =\n process.env.NODE_ENV !== 'production' ||\n process.env.VERCEL_ENV === 'preview'\n ? logWarn\n : logDebug;\n log(\n 'Config',\n `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. ` +\n 'Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.',\n );\n }\n }\n\n if (process.env.TURBOPACK) {\n const appConfigSchema = loadAppConfigSchema();\n if (\n !appConfigSchema?.safeParse({\n turbopack: {\n resolveAlias: {\n ...alias,\n },\n },\n compiler: {\n defineServer: {\n REMOTE_COMPONENTS_PROJECT_ID: projectId,\n },\n },\n }).success\n ) {\n logError(\n 'Config',\n 'Turbopack support requires a Next.js version that includes `compiler.defineServer`. ' +\n 'Upgrade Next.js to continue using Remote Components with Turbopack.',\n );\n process.exit(1);\n }\n const chunkLoadingGlobalSupported =\n appConfigSchema !== undefined &&\n isChunkLoadingGlobalSupported(appConfigSchema);\n // Next.js auto-prefixes chunkLoadingGlobal with \"TURBOPACK_\" when the value\n // doesn't already start with it. We set the prefix ourselves so the final\n // global name is predictable: TURBOPACK_remote_chunk_loading_global_<id>.\n const chunkLoadingGlobalValue = `TURBOPACK_remote_chunk_loading_global_${projectId}`;\n if (chunkLoadingGlobalSupported) {\n logDebug(\n 'Config',\n `Turbopack chunkLoadingGlobal set to \"${chunkLoadingGlobalValue}\" — ` +\n 'chunks will use a build-time scoped global (no runtime TURBOPACK rename needed).',\n );\n } else {\n logDebug(\n 'Config',\n 'Turbopack chunkLoadingGlobal not supported by this Next.js version — ' +\n 'falling back to runtime TURBOPACK global rename.',\n );\n }\n nextConfig.turbopack = {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n ...alias,\n },\n ...(chunkLoadingGlobalSupported\n ? { chunkLoadingGlobal: chunkLoadingGlobalValue }\n : {}),\n };\n nextConfig.compiler = {\n ...nextConfig.compiler,\n defineServer: {\n ...nextConfig.compiler?.defineServer,\n 'process.env.REMOTE_COMPONENTS_PROJECT_ID': projectId,\n },\n };\n emitSharedFiles();\n return nextConfig;\n }\n\n // apply the webpack transform\n return webpackTransform(nextConfig, {\n app: { name: projectId },\n alias,\n emitSharedFiles,\n });\n}\n","import { readFileSync } from 'node:fs';\nimport { findUpSync } from 'find-up';\nimport { resolveProjectIdFromEnv } from './project-id-env';\n\n/**\n * Resolves the project ID using environment variables first, then\n * falling back to `.vercel/project.json` and finally the package name.\n * Node-only — requires file system access.\n */\nexport function resolveProjectId(packageName: string): string {\n const fromEnv = resolveProjectIdFromEnv();\n if (fromEnv) return fromEnv;\n\n try {\n const projectPath = findUpSync('.vercel/project.json', {\n cwd: process.cwd(),\n });\n if (projectPath) {\n return (\n JSON.parse(readFileSync(projectPath, 'utf8')) as { projectId: string }\n ).projectId;\n }\n } catch {\n // fallback below\n }\n\n return packageName;\n}\n","/**\n * Resolves the project ID from environment variables only.\n * Safe for edge/browser contexts where file system access is unavailable.\n */\nexport function resolveProjectIdFromEnv(): string | undefined {\n return (\n process.env.REMOTE_COMPONENTS_PROJECT_ID ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n process.env.VERCEL_PROJECT_ID ||\n undefined\n );\n}\n","import { join } from 'node:path';\nimport type { NextConfig } from 'next';\nimport type { WebpackOptionsNormalized } from 'webpack';\nimport { ConditionalExecPlugin } from './plugins/conditional-exec';\nimport { ModuleIdEmbedPlugin } from './plugins/module-id-embed';\nimport { PatchRequirePlugin } from './plugins/patch-require';\nimport { RemoteWebpackRequirePlugin } from './plugins/remote-webpack-require';\n\nexport function transform(\n nextConfig: NextConfig,\n {\n app,\n alias = {},\n emitSharedFiles = () => {\n // no-op by default\n },\n }: {\n app: { name: string };\n alias?: Record<string, string>;\n emitSharedFiles?: () => void;\n },\n) {\n const webpackConfig = nextConfig.webpack;\n\n nextConfig.webpack = (\n baseConfig: WebpackOptionsNormalized,\n webpackContext,\n ) => {\n // execute the client config first, otherwise their config may accidentally\n // overwrite our required config - leading to unexpected errors.\n const config = (\n typeof webpackConfig === 'function'\n ? (webpackConfig(baseConfig, webpackContext) ?? baseConfig)\n : baseConfig\n ) as WebpackOptionsNormalized;\n\n // remote component specific plugins\n config.plugins.push(\n new RemoteWebpackRequirePlugin(app.name),\n new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),\n new ConditionalExecPlugin(app.name),\n new PatchRequirePlugin(app.name),\n );\n if (!webpackContext.isServer) {\n // change the chunk loading global to avoid conflicts with other remote components\n config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;\n }\n\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve.alias,\n ...Object.fromEntries(\n Object.entries(alias).map(([key, value]) => [\n key,\n join(process.cwd(), value),\n ]),\n ),\n },\n };\n\n emitSharedFiles();\n return config;\n };\n\n return nextConfig;\n}\n"]}
@@ -2,7 +2,7 @@ import {
2
2
  CORE_REACT_SHARED_KEYS,
3
3
  SHARED_MODULE_MANIFEST_PROTOCOL,
4
4
  VENDOR_SHARED
5
- } from "../chunk-JZRA6DPE.js";
5
+ } from "../chunk-6NUHDFSH.js";
6
6
  import "../chunk-D5GNZB6O.js";
7
7
  import "../chunk-STIJO4AG.js";
8
8
  import {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/nextjs/index.ts","../../src/utils/project-id.ts","../../src/utils/project-id-env.ts","../../src/config/webpack/nextjs.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { basename, dirname, join, relative } from 'node:path';\nimport enhancedResolve from 'enhanced-resolve';\nimport { findUpSync } from 'find-up';\nimport type { NextConfig } from 'next';\nimport TsConfigPathsWebpackPlugin from 'tsconfig-paths-webpack-plugin';\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport {\n CORE_REACT_SHARED_KEYS,\n VENDOR_SHARED,\n} from '#internal/host/shared/shared-module-resolver';\nimport { logDebug, logError, logWarn } from '#internal/utils/logger';\nimport { resolveProjectId } from '#internal/utils/project-id';\nimport { transform as webpackTransform } from '../webpack/nextjs';\n\nfunction getNextMajorVersion(): number | undefined {\n try {\n const nextPkgPath = findUpSync('node_modules/next/package.json', {\n cwd: process.cwd(),\n });\n if (!nextPkgPath) return undefined;\n const { version } = JSON.parse(readFileSync(nextPkgPath, 'utf8')) as {\n version: string;\n };\n const major = version.split('.')[0];\n return major ? Number.parseInt(major, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hasPagesDirectory(): boolean {\n return (\n existsSync(join(process.cwd(), 'pages')) ||\n existsSync(join(process.cwd(), 'src/pages'))\n );\n}\n\ninterface ZodSchema {\n safeParse: (data: unknown) => { success: boolean };\n}\n\n/**\n * Returns true when the installed Next.js version's config schema accepts\n * `turbopack.chunkLoadingGlobal`. The turbopack schema uses `z.strictObject`\n * so unrecognised keys fail — a successful parse means the field is present.\n *\n * Exported for unit testing.\n */\nexport function isChunkLoadingGlobalSupported(schema: ZodSchema): boolean {\n return schema.safeParse({ turbopack: { chunkLoadingGlobal: '__test__' } })\n .success;\n}\n\n/**\n * Loads `next/dist/server/config-schema.js` from the consuming app's own\n * `node_modules` (resolved from `process.cwd()`), not from the location of\n * this package. This ensures the schema reflects the exact Next.js version\n * installed in the app rather than whatever is hoisted to the workspace root.\n */\nfunction loadAppConfigSchema(): ZodSchema | undefined {\n try {\n const appRequire = createRequire(join(process.cwd(), 'package.json'));\n const mod = appRequire('next/dist/server/config-schema.js') as {\n configSchema: ZodSchema;\n };\n return mod.configSchema;\n } catch {\n return undefined;\n }\n}\n\nfunction readProjectPackageJson(): { name: string; type: string } {\n const defaults = { name: basename(process.cwd()), type: 'module' };\n try {\n const packageJsonPath = findUpSync('package.json', {\n cwd: process.cwd(),\n });\n if (packageJsonPath) {\n return {\n ...defaults,\n ...(JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n name: string;\n type: string;\n }),\n };\n }\n } catch {\n // noop\n }\n return defaults;\n}\n\ninterface WithRemoteComponentsOptions {\n /**\n * An array of package names that should be shared between the host and remote components.\n * This is useful for ensuring that both the host and remote components use the same version\n * of shared libraries.\n *\n * Essential packages are included by default: `react`, `react-dom`, `next/navigation`, `next/link`, `next/form`, `next/image` (loader only), and `next/script`.\n */\n shared?: string[];\n}\n\n/**\n * This function configures Next.js to support Remote Components.\n * You need to also use the `withMicrofrontends` function to extend your Next.js configuration.\n *\n * @param nextConfig - The Next.js configuration object.\n * @param options - Optional configuration for remote components.\n * @returns The modified Next.js configuration object with remote components support.\n *\n * @example\n *\n * ```js\n * import { withMicrofrontends } from '@vercel/microfrontends/next/config';\n * import { withRemoteComponentsConfig } from 'remote-components/config/nextjs';\n *\n * const nextConfig = {\n * // your Next.js configuration\n * };\n *\n * export default withRemoteComponentsConfig(\n * withMicrofrontends(nextConfig),\n * {\n * shared: ['some-package', 'another-package'],\n * },\n * );\n * ```\n */\nexport function withRemoteComponentsConfig(\n nextConfig: NextConfig,\n options?: WithRemoteComponentsOptions,\n) {\n const virtualRemoteComponentAppSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/app-remote.tsx',\n );\n const virtualRemoteComponentPagesSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/pages-remote.tsx',\n );\n const virtualRemoteComponentAppSharedHost = join(\n process.cwd(),\n '.remote-components/shared/app-host.tsx',\n );\n const virtualRemoteComponentPagesSharedHost = join(\n process.cwd(),\n '.remote-components/shared/pages-host.tsx',\n );\n\n const appShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/navigation',\n 'next/dist/client/components/navigation',\n 'next/link',\n 'next/dist/client/app-dir/link',\n 'next/form',\n 'next/dist/client/app-dir/form',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/dist/client/script',\n 'next/dist/build/polyfills/process',\n ...(options?.shared ?? []),\n ]);\n const pagesShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/router',\n 'next/link',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/form',\n ...(options?.shared ?? []),\n ]);\n\n const vendorShared = { ...VENDOR_SHARED };\n\n // resolve using enhanced-resolve\n // named import does not work with enhanced-resolve when using cjs\n // eslint-disable-next-line import/no-named-as-default-member\n const resolve = enhancedResolve.create.sync({\n conditionNames: ['browser', 'import', 'module', 'require'],\n ...(existsSync(join(process.cwd(), 'tsconfig.json'))\n ? {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n plugins: [\n new TsConfigPathsWebpackPlugin({\n configFile: join(process.cwd(), 'tsconfig.json'),\n }) as unknown as enhancedResolve.Plugin,\n ],\n }\n : {}),\n });\n\n const packageJson = readProjectPackageJson();\n\n const generateSharedModule = ({\n sharedEntries,\n sharedManifest,\n }: {\n sharedEntries: string[];\n sharedManifest?: string;\n }) => {\n const shared = sharedEntries.join('\\n');\n\n if (packageJson.type !== 'module') {\n const exports = [`shared: {\\n${shared}\\n}`];\n if (sharedManifest) {\n exports.push(`sharedManifest: ${sharedManifest}`);\n }\n return `'use client';\\nmodule.exports = {\\n${exports.join(',\\n')}\\n};\\n`;\n }\n\n return `'use client';\\nexport const shared = {\\n${shared}\\n};\\n${\n sharedManifest ? `export const sharedManifest = ${sharedManifest};\\n` : ''\n }`;\n };\n\n const resolveSharedPath = (moduleName: string): string | undefined => {\n try {\n const resolved = resolve(process.cwd(), moduleName);\n if (resolved) {\n return relative(process.cwd(), resolved).replace(\n /^(?<relative>\\.\\.\\/)+/,\n '',\n );\n }\n } catch {\n // if module resolution using enhanced-resolve fails, fallback to require.resolve called in the shared/remote file\n }\n };\n\n const sharedKeyExpression = (moduleName: string): string => {\n const path = resolveSharedPath(moduleName);\n return (\n vendorShared[moduleName] ??\n (path ? `'${path}'` : `require.resolve('${moduleName}')`)\n );\n };\n\n const generateSharedRemote = (sharedRemote: Set<string>) => {\n const sharedEntries = Array.from(sharedRemote).reduce<string[]>(\n (acc, curr) => {\n const id = sharedKeyExpression(curr);\n // @legacy(remote-components<=0.4.x): keep emitting the historical\n // shared map until hosts on 0.4.x are outside the compatibility window.\n acc.push(`[${id}]: '${curr}',`);\n acc.push(\n `['__remote_shared_module_${curr}']: () => import('${curr}'),`,\n );\n return acc;\n },\n [],\n );\n const requirements = Array.from(sharedRemote)\n .map(\n (curr) =>\n `{ id: ${sharedKeyExpression(curr)}, specifier: '${curr}', required: true, singleton: true }`,\n )\n .join(',\\n');\n return generateSharedModule({\n sharedEntries,\n sharedManifest: `{ protocol: '${SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [\\n${requirements}\\n] }`,\n });\n };\n const generateSharedHost = (sharedHost: Set<string>) =>\n generateSharedModule({\n sharedEntries: Array.from(sharedHost).reduce<string[]>((acc, curr) => {\n acc.push(`['${curr}']: () => import('${curr}'),`);\n return acc;\n }, []),\n });\n\n const appSharedRemote = generateSharedRemote(appShared);\n const pagesSharedRemote = generateSharedRemote(pagesShared);\n\n const appSharedHost = generateSharedHost(appShared);\n const pagesSharedHost = generateSharedHost(pagesShared);\n\n const emitSharedFiles = () => {\n mkdirSync(dirname(virtualRemoteComponentAppSharedRemote), {\n recursive: true,\n });\n\n writeFileSync(\n virtualRemoteComponentAppSharedRemote,\n appSharedRemote,\n 'utf-8',\n );\n writeFileSync(\n virtualRemoteComponentPagesSharedRemote,\n pagesSharedRemote,\n 'utf-8',\n );\n writeFileSync(virtualRemoteComponentAppSharedHost, appSharedHost, 'utf-8');\n writeFileSync(\n virtualRemoteComponentPagesSharedHost,\n pagesSharedHost,\n 'utf-8',\n );\n };\n\n nextConfig.transpilePackages = [\n ...(nextConfig.transpilePackages ?? []),\n 'remote-components',\n ];\n\n nextConfig.env = {\n ...nextConfig.env,\n REMOTE_COMPONENTS_CONFIGURED: '1',\n };\n\n const alias = {\n '#remote-components/remote/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedRemote,\n )}`,\n '#remote-components/remote/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedRemote,\n )}`,\n '#remote-components/host/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedHost,\n )}`,\n '#remote-components/host/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedHost,\n )}`,\n };\n\n const projectId = resolveProjectId(packageJson.name);\n process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;\n\n if (hasPagesDirectory()) {\n // Log instead of throwing for the version check because\n // withRemoteComponentsConfig is shared by both hosts and remotes.\n // Only Pages Router hosts are broken on Next.js < 16 — remotes\n // work fine and must not have their builds blocked.\n const nextMajor = getNextMajorVersion();\n if (nextMajor !== undefined && nextMajor < 16) {\n const log =\n process.env.NODE_ENV !== 'production' ||\n process.env.VERCEL_ENV === 'preview'\n ? logWarn\n : logDebug;\n log(\n 'Config',\n `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. ` +\n 'Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.',\n );\n }\n }\n\n if (process.env.TURBOPACK) {\n const appConfigSchema = loadAppConfigSchema();\n if (\n !appConfigSchema?.safeParse({\n turbopack: {\n resolveAlias: {\n ...alias,\n },\n },\n compiler: {\n defineServer: {\n REMOTE_COMPONENTS_PROJECT_ID: projectId,\n },\n },\n }).success\n ) {\n logError(\n 'Config',\n 'Turbopack support requires a Next.js version that includes `compiler.defineServer`. ' +\n 'Upgrade Next.js to continue using Remote Components with Turbopack.',\n );\n process.exit(1);\n }\n const chunkLoadingGlobalSupported =\n appConfigSchema !== undefined &&\n isChunkLoadingGlobalSupported(appConfigSchema);\n // Next.js auto-prefixes chunkLoadingGlobal with \"TURBOPACK_\" when the value\n // doesn't already start with it. We set the prefix ourselves so the final\n // global name is predictable: TURBOPACK_remote_chunk_loading_global_<id>.\n const chunkLoadingGlobalValue = `TURBOPACK_remote_chunk_loading_global_${projectId}`;\n if (chunkLoadingGlobalSupported) {\n logDebug(\n 'Config',\n `Turbopack chunkLoadingGlobal set to \"${chunkLoadingGlobalValue}\" — ` +\n 'chunks will use a build-time scoped global (no runtime TURBOPACK rename needed).',\n );\n } else {\n logDebug(\n 'Config',\n 'Turbopack chunkLoadingGlobal not supported by this Next.js version — ' +\n 'falling back to runtime TURBOPACK global rename.',\n );\n }\n nextConfig.turbopack = {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n ...alias,\n },\n ...(chunkLoadingGlobalSupported\n ? { chunkLoadingGlobal: chunkLoadingGlobalValue }\n : {}),\n };\n nextConfig.compiler = {\n ...nextConfig.compiler,\n defineServer: {\n ...nextConfig.compiler?.defineServer,\n 'process.env.REMOTE_COMPONENTS_PROJECT_ID': projectId,\n },\n };\n emitSharedFiles();\n return nextConfig;\n }\n\n // apply the webpack transform\n return webpackTransform(nextConfig, {\n app: { name: projectId },\n alias,\n emitSharedFiles,\n });\n}\n","import { readFileSync } from 'node:fs';\nimport { findUpSync } from 'find-up';\nimport { resolveProjectIdFromEnv } from './project-id-env';\n\n/**\n * Resolves the project ID using environment variables first, then\n * falling back to `.vercel/project.json` and finally the package name.\n * Node-only — requires file system access.\n */\nexport function resolveProjectId(packageName: string): string {\n const fromEnv = resolveProjectIdFromEnv();\n if (fromEnv) return fromEnv;\n\n try {\n const projectPath = findUpSync('.vercel/project.json', {\n cwd: process.cwd(),\n });\n if (projectPath) {\n return (\n JSON.parse(readFileSync(projectPath, 'utf8')) as { projectId: string }\n ).projectId;\n }\n } catch {\n // fallback below\n }\n\n return packageName;\n}\n","/**\n * Resolves the project ID from environment variables only.\n * Safe for edge/browser contexts where file system access is unavailable.\n */\nexport function resolveProjectIdFromEnv(): string | undefined {\n return (\n process.env.REMOTE_COMPONENTS_PROJECT_ID ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n process.env.VERCEL_PROJECT_ID ||\n undefined\n );\n}\n","import { join } from 'node:path';\nimport type { NextConfig } from 'next';\nimport type { WebpackOptionsNormalized } from 'webpack';\nimport { ConditionalExecPlugin } from './plugins/conditional-exec';\nimport { ModuleIdEmbedPlugin } from './plugins/module-id-embed';\nimport { PatchRequirePlugin } from './plugins/patch-require';\nimport { RemoteWebpackRequirePlugin } from './plugins/remote-webpack-require';\n\nexport function transform(\n nextConfig: NextConfig,\n {\n app,\n alias = {},\n emitSharedFiles = () => {\n // no-op by default\n },\n }: {\n app: { name: string };\n alias?: Record<string, string>;\n emitSharedFiles?: () => void;\n },\n) {\n const webpackConfig = nextConfig.webpack;\n\n nextConfig.webpack = (\n baseConfig: WebpackOptionsNormalized,\n webpackContext,\n ) => {\n // execute the client config first, otherwise their config may accidentally\n // overwrite our required config - leading to unexpected errors.\n const config = (\n typeof webpackConfig === 'function'\n ? (webpackConfig(baseConfig, webpackContext) ?? baseConfig)\n : baseConfig\n ) as WebpackOptionsNormalized;\n\n // remote component specific plugins\n config.plugins.push(\n new RemoteWebpackRequirePlugin(app.name),\n new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),\n new ConditionalExecPlugin(app.name),\n new PatchRequirePlugin(app.name),\n );\n if (!webpackContext.isServer) {\n // change the chunk loading global to avoid conflicts with other remote components\n config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;\n }\n\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve.alias,\n ...Object.fromEntries(\n Object.entries(alias).map(([key, value]) => [\n key,\n join(process.cwd(), value),\n ]),\n ),\n },\n };\n\n emitSharedFiles();\n return config;\n };\n\n return nextConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAAS,UAAU,SAAS,QAAAC,OAAM,gBAAgB;AAClD,OAAO,qBAAqB;AAC5B,SAAS,cAAAC,mBAAkB;AAE3B,OAAO,gCAAgC;;;ACNvC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;;;ACGpB,SAAS,0BAA8C;AAC5D,SACE,QAAQ,IAAI,gCACZ,QAAQ,IAAI,uCACZ,QAAQ,IAAI,qBACZ;AAEJ;;;ADFO,SAAS,iBAAiB,aAA6B;AAC5D,QAAM,UAAU,wBAAwB;AACxC,MAAI;AAAS,WAAO;AAEpB,MAAI;AACF,UAAM,cAAc,WAAW,wBAAwB;AAAA,MACrD,KAAK,QAAQ,IAAI;AAAA,IACnB,CAAC;AACD,QAAI,aAAa;AACf,aACE,KAAK,MAAM,aAAa,aAAa,MAAM,CAAC,EAC5C;AAAA,IACJ;AAAA,EACF,QAAE;AAAA,EAEF;AAEA,SAAO;AACT;;;AE3BA,SAAS,YAAY;AAQd,SAAS,UACd,YACA;AAAA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MAEF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,UAAM,8BACJ,oBAAoB,UACpB,8BAA8B,eAAe;AAI/C,UAAM,0BAA0B,yCAAyC;AACzE,QAAI,6BAA6B;AAC/B;AAAA,QACE;AAAA,QACA,wCAAwC;AAAA,MAE1C;AAAA,IACF,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,MAEF;AAAA,IACF;AACA,eAAW,YAAY;AAAA,MACrB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,WAAW;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,MACA,GAAI,8BACA,EAAE,oBAAoB,wBAAwB,IAC9C,CAAC;AAAA,IACP;AACA,eAAW,WAAW;AAAA,MACpB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,UAAU;AAAA,QACxB,4CAA4C;AAAA,MAC9C;AAAA,IACF;AACA,oBAAgB;AAChB,WAAO;AAAA,EACT;AAGA,SAAO,UAAiB,YAAY;AAAA,IAClC,KAAK,EAAE,MAAM,UAAU;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":["readFileSync","join","findUpSync","findUpSync","readFileSync","join"]}
1
+ {"version":3,"sources":["../../src/config/nextjs/index.ts","../../src/utils/project-id.ts","../../src/utils/project-id-env.ts","../../src/config/webpack/nextjs.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { basename, dirname, join, relative } from 'node:path';\nimport enhancedResolve from 'enhanced-resolve';\nimport { findUpSync } from 'find-up';\nimport type { NextConfig } from 'next';\nimport TsConfigPathsWebpackPlugin from 'tsconfig-paths-webpack-plugin';\nimport { SHARED_MODULE_MANIFEST_PROTOCOL } from '#internal/host/shared/shared-broker';\nimport {\n CORE_REACT_SHARED_KEYS,\n VENDOR_SHARED,\n} from '#internal/host/shared/shared-module-resolver';\nimport { logDebug, logError, logWarn } from '#internal/utils/logger';\nimport { resolveProjectId } from '#internal/utils/project-id';\nimport { transform as webpackTransform } from '../webpack/nextjs';\n\nfunction getNextMajorVersion(): number | undefined {\n try {\n const nextPkgPath = findUpSync('node_modules/next/package.json', {\n cwd: process.cwd(),\n });\n if (!nextPkgPath) return undefined;\n const { version } = JSON.parse(readFileSync(nextPkgPath, 'utf8')) as {\n version: string;\n };\n const major = version.split('.')[0];\n return major ? Number.parseInt(major, 10) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hasPagesDirectory(): boolean {\n return (\n existsSync(join(process.cwd(), 'pages')) ||\n existsSync(join(process.cwd(), 'src/pages'))\n );\n}\n\ninterface ZodSchema {\n safeParse: (data: unknown) => { success: boolean };\n}\n\n/**\n * Returns true when the installed Next.js version's config schema accepts\n * `turbopack.chunkLoadingGlobal`. The turbopack schema uses `z.strictObject`\n * so unrecognised keys fail — a successful parse means the field is present.\n *\n * Exported for unit testing.\n */\nexport function isChunkLoadingGlobalSupported(schema: ZodSchema): boolean {\n return schema.safeParse({ turbopack: { chunkLoadingGlobal: '__test__' } })\n .success;\n}\n\n/**\n * Loads `next/dist/server/config-schema.js` from the consuming app's own\n * `node_modules` (resolved from `process.cwd()`), not from the location of\n * this package. This ensures the schema reflects the exact Next.js version\n * installed in the app rather than whatever is hoisted to the workspace root.\n */\nfunction loadAppConfigSchema(): ZodSchema | undefined {\n try {\n const appRequire = createRequire(join(process.cwd(), 'package.json'));\n const mod = appRequire('next/dist/server/config-schema.js') as {\n configSchema: ZodSchema;\n };\n return mod.configSchema;\n } catch {\n return undefined;\n }\n}\n\nfunction readProjectPackageJson(): { name: string; type: string } {\n const defaults = { name: basename(process.cwd()), type: 'module' };\n try {\n const packageJsonPath = findUpSync('package.json', {\n cwd: process.cwd(),\n });\n if (packageJsonPath) {\n return {\n ...defaults,\n ...(JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n name: string;\n type: string;\n }),\n };\n }\n } catch {\n // noop\n }\n return defaults;\n}\n\ninterface WithRemoteComponentsOptions {\n /**\n * An array of package names that should be shared between the host and remote components.\n * This is useful for ensuring that both the host and remote components use the same version\n * of shared libraries.\n *\n * Essential packages are included by default: `react`, `react-dom`, `next/navigation`, `next/link`, `next/form`, `next/image` (loader only), and `next/script`.\n */\n shared?: string[];\n}\n\n/**\n * This function configures Next.js to support Remote Components.\n * You need to also use the `withMicrofrontends` function to extend your Next.js configuration.\n *\n * @param nextConfig - The Next.js configuration object.\n * @param options - Optional configuration for remote components.\n * @returns The modified Next.js configuration object with remote components support.\n *\n * @example\n *\n * ```js\n * import { withMicrofrontends } from '@vercel/microfrontends/next/config';\n * import { withRemoteComponentsConfig } from 'remote-components/config/nextjs';\n *\n * const nextConfig = {\n * // your Next.js configuration\n * };\n *\n * export default withRemoteComponentsConfig(\n * withMicrofrontends(nextConfig),\n * {\n * shared: ['some-package', 'another-package'],\n * },\n * );\n * ```\n */\nexport function withRemoteComponentsConfig(\n nextConfig: NextConfig,\n options?: WithRemoteComponentsOptions,\n) {\n const virtualRemoteComponentAppSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/app-remote.tsx',\n );\n const virtualRemoteComponentPagesSharedRemote = join(\n process.cwd(),\n '.remote-components/shared/pages-remote.tsx',\n );\n const virtualRemoteComponentAppSharedHost = join(\n process.cwd(),\n '.remote-components/shared/app-host.tsx',\n );\n const virtualRemoteComponentPagesSharedHost = join(\n process.cwd(),\n '.remote-components/shared/pages-host.tsx',\n );\n\n const appShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/navigation',\n 'next/dist/client/components/navigation',\n 'next/link',\n 'next/dist/client/app-dir/link',\n 'next/form',\n 'next/dist/client/app-dir/form',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/dist/client/script',\n 'next/dist/build/polyfills/process',\n ...(options?.shared ?? []),\n ]);\n const pagesShared = new Set([\n ...CORE_REACT_SHARED_KEYS,\n 'next/router',\n 'next/link',\n 'next/dist/shared/lib/image-loader',\n 'next/script',\n 'next/form',\n ...(options?.shared ?? []),\n ]);\n\n const vendorShared = { ...VENDOR_SHARED };\n\n // resolve using enhanced-resolve\n // named import does not work with enhanced-resolve when using cjs\n // eslint-disable-next-line import/no-named-as-default-member\n const resolve = enhancedResolve.create.sync({\n conditionNames: ['browser', 'import', 'module', 'require'],\n ...(existsSync(join(process.cwd(), 'tsconfig.json'))\n ? {\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n plugins: [\n new TsConfigPathsWebpackPlugin({\n configFile: join(process.cwd(), 'tsconfig.json'),\n }) as unknown as enhancedResolve.Plugin,\n ],\n }\n : {}),\n });\n\n const packageJson = readProjectPackageJson();\n\n const generateSharedModule = ({\n sharedEntries,\n sharedManifest,\n }: {\n sharedEntries: string[];\n sharedManifest?: string;\n }) => {\n const shared = sharedEntries.join('\\n');\n\n if (packageJson.type !== 'module') {\n const exports = [`shared: {\\n${shared}\\n}`];\n if (sharedManifest) {\n exports.push(`sharedManifest: ${sharedManifest}`);\n }\n return `'use client';\\nmodule.exports = {\\n${exports.join(',\\n')}\\n};\\n`;\n }\n\n return `'use client';\\nexport const shared = {\\n${shared}\\n};\\n${\n sharedManifest ? `export const sharedManifest = ${sharedManifest};\\n` : ''\n }`;\n };\n\n const resolveSharedPath = (moduleName: string): string | undefined => {\n try {\n const resolved = resolve(process.cwd(), moduleName);\n if (resolved) {\n return relative(process.cwd(), resolved).replace(\n /^(?<relative>\\.\\.\\/)+/,\n '',\n );\n }\n } catch {\n // if module resolution using enhanced-resolve fails, fallback to require.resolve called in the shared/remote file\n }\n };\n\n const sharedKeyExpression = (moduleName: string): string => {\n const path = resolveSharedPath(moduleName);\n return (\n vendorShared[moduleName] ??\n (path ? `'${path}'` : `require.resolve('${moduleName}')`)\n );\n };\n\n const generateSharedRemote = (sharedRemote: Set<string>) => {\n const sharedEntries = Array.from(sharedRemote).reduce<string[]>(\n (acc, curr) => {\n const id = sharedKeyExpression(curr);\n // @legacy(remote-components<=0.4.x): keep emitting the historical\n // [module id]: specifier shared map until hosts on 0.4.x are outside\n // the compatibility window. The sharedManifest below is the primary\n // contract for new hosts.\n acc.push(`[${id}]: '${curr}',`);\n acc.push(\n `['__remote_shared_module_${curr}']: () => import('${curr}'),`,\n );\n return acc;\n },\n [],\n );\n const requirements = Array.from(sharedRemote)\n .map(\n (curr) =>\n `{ id: ${sharedKeyExpression(curr)}, specifier: '${curr}', required: true, singleton: true }`,\n )\n .join(',\\n');\n return generateSharedModule({\n sharedEntries,\n sharedManifest: `{ protocol: '${SHARED_MODULE_MANIFEST_PROTOCOL}', requirements: [\\n${requirements}\\n] }`,\n });\n };\n const generateSharedHost = (sharedHost: Set<string>) =>\n generateSharedModule({\n sharedEntries: Array.from(sharedHost).reduce<string[]>((acc, curr) => {\n acc.push(`['${curr}']: () => import('${curr}'),`);\n return acc;\n }, []),\n });\n\n const appSharedRemote = generateSharedRemote(appShared);\n const pagesSharedRemote = generateSharedRemote(pagesShared);\n\n const appSharedHost = generateSharedHost(appShared);\n const pagesSharedHost = generateSharedHost(pagesShared);\n\n const emitSharedFiles = () => {\n mkdirSync(dirname(virtualRemoteComponentAppSharedRemote), {\n recursive: true,\n });\n\n writeFileSync(\n virtualRemoteComponentAppSharedRemote,\n appSharedRemote,\n 'utf-8',\n );\n writeFileSync(\n virtualRemoteComponentPagesSharedRemote,\n pagesSharedRemote,\n 'utf-8',\n );\n writeFileSync(virtualRemoteComponentAppSharedHost, appSharedHost, 'utf-8');\n writeFileSync(\n virtualRemoteComponentPagesSharedHost,\n pagesSharedHost,\n 'utf-8',\n );\n };\n\n nextConfig.transpilePackages = [\n ...(nextConfig.transpilePackages ?? []),\n 'remote-components',\n ];\n\n nextConfig.env = {\n ...nextConfig.env,\n REMOTE_COMPONENTS_CONFIGURED: '1',\n };\n\n const alias = {\n '#remote-components/remote/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedRemote,\n )}`,\n '#remote-components/remote/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedRemote,\n )}`,\n '#remote-components/host/defaults/app': `./${relative(\n process.cwd(),\n virtualRemoteComponentAppSharedHost,\n )}`,\n '#remote-components/host/defaults/pages': `./${relative(\n process.cwd(),\n virtualRemoteComponentPagesSharedHost,\n )}`,\n };\n\n const projectId = resolveProjectId(packageJson.name);\n process.env.REMOTE_COMPONENTS_PROJECT_ID = projectId;\n\n if (hasPagesDirectory()) {\n // Log instead of throwing for the version check because\n // withRemoteComponentsConfig is shared by both hosts and remotes.\n // Only Pages Router hosts are broken on Next.js < 16 — remotes\n // work fine and must not have their builds blocked.\n const nextMajor = getNextMajorVersion();\n if (nextMajor !== undefined && nextMajor < 16) {\n const log =\n process.env.NODE_ENV !== 'production' ||\n process.env.VERCEL_ENV === 'preview'\n ? logWarn\n : logDebug;\n log(\n 'Config',\n `Remote Components does not support Pages Router hosts on Next.js ${nextMajor}. ` +\n 'Pages Router remotes are unaffected. Upgrade to Next.js 16+ for host support.',\n );\n }\n }\n\n if (process.env.TURBOPACK) {\n const appConfigSchema = loadAppConfigSchema();\n if (\n !appConfigSchema?.safeParse({\n turbopack: {\n resolveAlias: {\n ...alias,\n },\n },\n compiler: {\n defineServer: {\n REMOTE_COMPONENTS_PROJECT_ID: projectId,\n },\n },\n }).success\n ) {\n logError(\n 'Config',\n 'Turbopack support requires a Next.js version that includes `compiler.defineServer`. ' +\n 'Upgrade Next.js to continue using Remote Components with Turbopack.',\n );\n process.exit(1);\n }\n const chunkLoadingGlobalSupported =\n appConfigSchema !== undefined &&\n isChunkLoadingGlobalSupported(appConfigSchema);\n // Next.js auto-prefixes chunkLoadingGlobal with \"TURBOPACK_\" when the value\n // doesn't already start with it. We set the prefix ourselves so the final\n // global name is predictable: TURBOPACK_remote_chunk_loading_global_<id>.\n const chunkLoadingGlobalValue = `TURBOPACK_remote_chunk_loading_global_${projectId}`;\n if (chunkLoadingGlobalSupported) {\n logDebug(\n 'Config',\n `Turbopack chunkLoadingGlobal set to \"${chunkLoadingGlobalValue}\" — ` +\n 'chunks will use a build-time scoped global (no runtime TURBOPACK rename needed).',\n );\n } else {\n logDebug(\n 'Config',\n 'Turbopack chunkLoadingGlobal not supported by this Next.js version — ' +\n 'falling back to runtime TURBOPACK global rename.',\n );\n }\n nextConfig.turbopack = {\n ...nextConfig.turbopack,\n resolveAlias: {\n ...nextConfig.turbopack?.resolveAlias,\n ...alias,\n },\n ...(chunkLoadingGlobalSupported\n ? { chunkLoadingGlobal: chunkLoadingGlobalValue }\n : {}),\n };\n nextConfig.compiler = {\n ...nextConfig.compiler,\n defineServer: {\n ...nextConfig.compiler?.defineServer,\n 'process.env.REMOTE_COMPONENTS_PROJECT_ID': projectId,\n },\n };\n emitSharedFiles();\n return nextConfig;\n }\n\n // apply the webpack transform\n return webpackTransform(nextConfig, {\n app: { name: projectId },\n alias,\n emitSharedFiles,\n });\n}\n","import { readFileSync } from 'node:fs';\nimport { findUpSync } from 'find-up';\nimport { resolveProjectIdFromEnv } from './project-id-env';\n\n/**\n * Resolves the project ID using environment variables first, then\n * falling back to `.vercel/project.json` and finally the package name.\n * Node-only — requires file system access.\n */\nexport function resolveProjectId(packageName: string): string {\n const fromEnv = resolveProjectIdFromEnv();\n if (fromEnv) return fromEnv;\n\n try {\n const projectPath = findUpSync('.vercel/project.json', {\n cwd: process.cwd(),\n });\n if (projectPath) {\n return (\n JSON.parse(readFileSync(projectPath, 'utf8')) as { projectId: string }\n ).projectId;\n }\n } catch {\n // fallback below\n }\n\n return packageName;\n}\n","/**\n * Resolves the project ID from environment variables only.\n * Safe for edge/browser contexts where file system access is unavailable.\n */\nexport function resolveProjectIdFromEnv(): string | undefined {\n return (\n process.env.REMOTE_COMPONENTS_PROJECT_ID ||\n process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION ||\n process.env.VERCEL_PROJECT_ID ||\n undefined\n );\n}\n","import { join } from 'node:path';\nimport type { NextConfig } from 'next';\nimport type { WebpackOptionsNormalized } from 'webpack';\nimport { ConditionalExecPlugin } from './plugins/conditional-exec';\nimport { ModuleIdEmbedPlugin } from './plugins/module-id-embed';\nimport { PatchRequirePlugin } from './plugins/patch-require';\nimport { RemoteWebpackRequirePlugin } from './plugins/remote-webpack-require';\n\nexport function transform(\n nextConfig: NextConfig,\n {\n app,\n alias = {},\n emitSharedFiles = () => {\n // no-op by default\n },\n }: {\n app: { name: string };\n alias?: Record<string, string>;\n emitSharedFiles?: () => void;\n },\n) {\n const webpackConfig = nextConfig.webpack;\n\n nextConfig.webpack = (\n baseConfig: WebpackOptionsNormalized,\n webpackContext,\n ) => {\n // execute the client config first, otherwise their config may accidentally\n // overwrite our required config - leading to unexpected errors.\n const config = (\n typeof webpackConfig === 'function'\n ? (webpackConfig(baseConfig, webpackContext) ?? baseConfig)\n : baseConfig\n ) as WebpackOptionsNormalized;\n\n // remote component specific plugins\n config.plugins.push(\n new RemoteWebpackRequirePlugin(app.name),\n new ModuleIdEmbedPlugin(app.name, { isServer: webpackContext.isServer }),\n new ConditionalExecPlugin(app.name),\n new PatchRequirePlugin(app.name),\n );\n if (!webpackContext.isServer) {\n // change the chunk loading global to avoid conflicts with other remote components\n config.output.chunkLoadingGlobal = `__remote_chunk_loading_global_${app.name}__`;\n }\n\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve.alias,\n ...Object.fromEntries(\n Object.entries(alias).map(([key, value]) => [\n key,\n join(process.cwd(), value),\n ]),\n ),\n },\n };\n\n emitSharedFiles();\n return config;\n };\n\n return nextConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAAS,UAAU,SAAS,QAAAC,OAAM,gBAAgB;AAClD,OAAO,qBAAqB;AAC5B,SAAS,cAAAC,mBAAkB;AAE3B,OAAO,gCAAgC;;;ACNvC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;;;ACGpB,SAAS,0BAA8C;AAC5D,SACE,QAAQ,IAAI,gCACZ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Q,IAAI,eAAe,YACvB,UACA;AACN;AAAA,QACE;AAAA,QACA,oEAAoE;AAAA,MAEtE;AAAA,IACF;AAAA,EACF;AAEA,MAAI,QAAQ,IAAI,WAAW;AACzB,UAAM,kBAAkB,oBAAoB;AAC5C,QACE,CAAC,iBAAiB,UAAU;AAAA,MAC1B,WAAW;AAAA,QACT,cAAc;AAAA,UACZ,GAAG;AAAA,QACL;AAAA,MACF;AAAA,MACA,UAAU;AAAA,QACR,cAAc;AAAA,UACZ,8BAA8B;AAAA,QAChC;AAAA,MACF;AAAA,IACF,CAAC,EAAE,SACH;AACA;AAAA,QACE;AAAA,QACA;AAAA,MAEF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,UAAM,8BACJ,oBAAoB,UACpB,8BAA8B,eAAe;AAI/C,UAAM,0BAA0B,yCAAyC;AACzE,QAAI,6BAA6B;AAC/B;AAAA,QACE;AAAA,QACA,wCAAwC;AAAA,MAE1C;AAAA,IACF,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,MAEF;AAAA,IACF;AACA,eAAW,YAAY;AAAA,MACrB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,WAAW;AAAA,QACzB,GAAG;AAAA,MACL;AAAA,MACA,GAAI,8BACA,EAAE,oBAAoB,wBAAwB,IAC9C,CAAC;AAAA,IACP;AACA,eAAW,WAAW;AAAA,MACpB,GAAG,WAAW;AAAA,MACd,cAAc;AAAA,QACZ,GAAG,WAAW,UAAU;AAAA,QACxB,4CAA4C;AAAA,MAC9C;AAAA,IACF;AACA,oBAAgB;AAChB,WAAO;AAAA,EACT;AAGA,SAAO,UAAiB,YAAY;AAAA,IAClC,KAAK,EAAE,MAAM,UAAU;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":["readFileSync","join","findUpSync","findUpSync","readFileSync","join"]}
@@ -7,16 +7,16 @@
7
7
 
8
8
 
9
9
 
10
- var _chunk7AUERPZ6cjs = require('../chunk-7AUERPZ6.cjs');
11
- require('../chunk-4MLJE6UP.cjs');
12
- require('../chunk-YOFJE3RL.cjs');
13
- require('../chunk-W2TLJBAA.cjs');
10
+ var _chunkEZG36EB4cjs = require('../chunk-EZG36EB4.cjs');
11
+ require('../chunk-VB64GQX7.cjs');
12
+ require('../chunk-J42V6HSP.cjs');
13
+ require('../chunk-6NAV4SCF.cjs');
14
14
  require('../chunk-3AX5WLZD.cjs');
15
15
 
16
16
 
17
17
 
18
18
 
19
- var _chunkI7VKDF3Ecjs = require('../chunk-I7VKDF3E.cjs');
19
+ var _chunkSELGX4Y2cjs = require('../chunk-SELGX4Y2.cjs');
20
20
 
21
21
 
22
22
  var _chunkZ2SLBFQLcjs = require('../chunk-Z2SLBFQL.cjs');
@@ -125,10 +125,10 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
125
125
  };
126
126
  }
127
127
  if (type === "webpack") {
128
- const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-XYIZEJQX.cjs")));
128
+ const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-VTSF2B2G.cjs")));
129
129
  return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
130
130
  } else if (type === "turbopack") {
131
- const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-KFQ3A7UU.cjs")));
131
+ const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-6BXAJGS5.cjs")));
132
132
  return turbopackRuntime(
133
133
  url,
134
134
  bundle,
@@ -149,15 +149,15 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
149
149
  var _jsxruntime = require('react/jsx-runtime');
150
150
  if (typeof HTMLElement !== "undefined") {
151
151
  class RemoteComponent extends HTMLElement {constructor(...args) { super(...args); RemoteComponent.prototype.__init.call(this);RemoteComponent.prototype.__init2.call(this);RemoteComponent.prototype.__init3.call(this);RemoteComponent.prototype.__init4.call(this);RemoteComponent.prototype.__init5.call(this);RemoteComponent.prototype.__init6.call(this);RemoteComponent.prototype.__init7.call(this); }
152
- __init() {this.name = _chunkI7VKDF3Ecjs.DEFAULT_COMPONENT_NAME}
153
- __init2() {this.bundle = _chunkI7VKDF3Ecjs.DEFAULT_BUNDLE_NAME}
152
+ __init() {this.name = _chunkSELGX4Y2cjs.DEFAULT_COMPONENT_NAME}
153
+ __init2() {this.bundle = _chunkSELGX4Y2cjs.DEFAULT_BUNDLE_NAME}
154
154
 
155
155
  __init3() {this.__next = null}
156
156
  __init4() {this.fouc = null}
157
- __init5() {this.hostState = _chunk7AUERPZ6cjs.createHostState.call(void 0, )}
157
+ __init5() {this.hostState = _chunkEZG36EB4cjs.createHostState.call(void 0, )}
158
158
  __init6() {this.root = null}
159
159
 
160
- __init7() {this.emitter = _chunk7AUERPZ6cjs.makeEventEmitter.call(void 0, this)}
160
+ __init7() {this.emitter = _chunkEZG36EB4cjs.makeEventEmitter.call(void 0, this)}
161
161
 
162
162
 
163
163
 
@@ -279,10 +279,10 @@ if (typeof HTMLElement !== "undefined") {
279
279
  let url = null;
280
280
  let html = this.innerHTML;
281
281
  if (src) {
282
- url = _chunk7AUERPZ6cjs.getClientOrServerUrl.call(void 0, src, window.location.href);
283
- this.name = _chunk7AUERPZ6cjs.resolveNameFromSrc.call(void 0, src, this.name);
282
+ url = _chunkEZG36EB4cjs.getClientOrServerUrl.call(void 0, src, window.location.href);
283
+ this.name = _chunkEZG36EB4cjs.resolveNameFromSrc.call(void 0, src, this.name);
284
284
  }
285
- const resolveClientUrl = url ? _chunk7AUERPZ6cjs.bindResolveClientUrl.call(void 0, this.resolveClientUrl, url.href) : void 0;
285
+ const resolveClientUrl = url ? _chunkEZG36EB4cjs.bindResolveClientUrl.call(void 0, this.resolveClientUrl, url.href) : void 0;
286
286
  if (!remoteComponentChild && url) {
287
287
  const fetchInit = {
288
288
  credentials: this.credentials || "same-origin"
@@ -293,7 +293,7 @@ if (typeof HTMLElement !== "undefined") {
293
293
  );
294
294
  let res;
295
295
  try {
296
- res = await _chunk7AUERPZ6cjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
296
+ res = await _chunkEZG36EB4cjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
297
297
  onRequest: this.onRequest,
298
298
  onResponse: this.onResponse,
299
299
  abortController: this.hostState.abortController
@@ -320,7 +320,7 @@ if (typeof HTMLElement !== "undefined") {
320
320
  }
321
321
  }
322
322
  const effectiveUrl = _nullishCoalesce(url, () => ( new URL(window.location.href)));
323
- const { doc, parsed } = _chunk7AUERPZ6cjs.preparePipeline.call(void 0, {
323
+ const { doc, parsed } = _chunkEZG36EB4cjs.preparePipeline.call(void 0, {
324
324
  html,
325
325
  name: this.name,
326
326
  url: effectiveUrl,
@@ -553,9 +553,9 @@ if (typeof HTMLElement !== "undefined") {
553
553
  };
554
554
  if (rsc) {
555
555
  _optionalChain([rsc, 'access', _62 => _62.parentElement, 'optionalAccess', _63 => _63.removeChild, 'call', _64 => _64(rsc)]);
556
- const rscName = `__remote_component_rsc_${_chunkI7VKDF3Ecjs.escapeString.call(void 0,
556
+ const rscName = `__remote_component_rsc_${_chunkSELGX4Y2cjs.escapeString.call(void 0,
557
557
  url.href
558
- )}_${_chunkI7VKDF3Ecjs.escapeString.call(void 0, this.name)}`;
558
+ )}_${_chunkSELGX4Y2cjs.escapeString.call(void 0, this.name)}`;
559
559
  const rscClone = document.createElement("script");
560
560
  rscClone.id = `${rscName}_rsc`;
561
561
  rscClone.textContent = _nullishCoalesce(_optionalChain([rsc, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.replace, 'call', _67 => _67(
@@ -568,7 +568,7 @@ if (typeof HTMLElement !== "undefined") {
568
568
  name,
569
569
  initial
570
570
  }) => {
571
- const stream = _chunk7AUERPZ6cjs.createRSCStream.call(void 0,
571
+ const stream = _chunkEZG36EB4cjs.createRSCStream.call(void 0,
572
572
  rscName,
573
573
  _nullishCoalesce(self[rscName], () => ( [`0:[null]
574
574
  `]))
package/dist/host/html.js CHANGED
@@ -7,16 +7,16 @@ import {
7
7
  makeEventEmitter,
8
8
  preparePipeline,
9
9
  resolveNameFromSrc
10
- } from "../chunk-ZSIOEMB3.js";
11
- import "../chunk-WGSS7TJP.js";
12
- import "../chunk-VWEKLTPJ.js";
13
- import "../chunk-KTUPOJQQ.js";
10
+ } from "../chunk-4XWEMPKO.js";
11
+ import "../chunk-ZJW3GQTP.js";
12
+ import "../chunk-X6SKTJ5N.js";
13
+ import "../chunk-JYGC7T6L.js";
14
14
  import "../chunk-LEKG4YWI.js";
15
15
  import {
16
16
  DEFAULT_BUNDLE_NAME,
17
17
  DEFAULT_COMPONENT_NAME,
18
18
  escapeString
19
- } from "../chunk-JZRA6DPE.js";
19
+ } from "../chunk-6NUHDFSH.js";
20
20
  import {
21
21
  getNamespace
22
22
  } from "../chunk-D5GNZB6O.js";
@@ -125,10 +125,10 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
125
125
  };
126
126
  }
127
127
  if (type === "webpack") {
128
- const { webpackRuntime } = await import("../webpack-UYL4UYZL.js");
128
+ const { webpackRuntime } = await import("../webpack-ZYOBNVFE.js");
129
129
  return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
130
130
  } else if (type === "turbopack") {
131
- const { turbopackRuntime } = await import("../turbopack-A2TW7XKF.js");
131
+ const { turbopackRuntime } = await import("../turbopack-WAERWSWW.js");
132
132
  return turbopackRuntime(
133
133
  url,
134
134
  bundle,