remote-components 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/config/nextjs.cjs +1 -1
  2. package/dist/config/nextjs.cjs.map +1 -1
  3. package/dist/config/nextjs.js +1 -1
  4. package/dist/config/nextjs.js.map +1 -1
  5. package/dist/host/html.cjs +19 -17
  6. package/dist/host/html.cjs.map +1 -1
  7. package/dist/host/html.js +19 -17
  8. package/dist/host/html.js.map +1 -1
  9. package/dist/host/nextjs/app/client-only.cjs +17 -19
  10. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  11. package/dist/host/nextjs/app/client-only.js +17 -19
  12. package/dist/host/nextjs/app/client-only.js.map +1 -1
  13. package/dist/host/react.cjs +17 -15
  14. package/dist/host/react.cjs.map +1 -1
  15. package/dist/host/react.js +17 -15
  16. package/dist/host/react.js.map +1 -1
  17. package/dist/internal/config/webpack/apply-shared-modules.cjs +6 -2
  18. package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -1
  19. package/dist/internal/config/webpack/apply-shared-modules.js +6 -2
  20. package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -1
  21. package/dist/internal/runtime/loaders/script-loader.cjs +1 -6
  22. package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
  23. package/dist/internal/runtime/loaders/script-loader.js +4 -9
  24. package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
  25. package/dist/internal/runtime/turbopack/chunk-loader.cjs +1 -6
  26. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
  27. package/dist/internal/runtime/turbopack/chunk-loader.js +4 -9
  28. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
  29. package/dist/internal/runtime/turbopack/shared-modules.cjs +3 -2
  30. package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
  31. package/dist/internal/runtime/turbopack/shared-modules.js +3 -2
  32. package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
  33. package/dist/internal/utils/error.cjs +7 -0
  34. package/dist/internal/utils/error.cjs.map +1 -1
  35. package/dist/internal/utils/error.d.ts +2 -1
  36. package/dist/internal/utils/error.js +6 -0
  37. package/dist/internal/utils/error.js.map +1 -1
  38. package/dist/internal/utils/logger.cjs +1 -1
  39. package/dist/internal/utils/logger.cjs.map +1 -1
  40. package/dist/internal/utils/logger.d.ts +1 -1
  41. package/dist/internal/utils/logger.js +1 -1
  42. package/dist/internal/utils/logger.js.map +1 -1
  43. package/dist/remote/html.cjs +1 -1
  44. package/dist/remote/html.cjs.map +1 -1
  45. package/dist/remote/html.js +1 -1
  46. package/dist/remote/html.js.map +1 -1
  47. package/package.json +1 -1
@@ -93,6 +93,11 @@ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
93
93
  }
94
94
  return fallback;
95
95
  }
96
+ function failedProxiedAssetError(kind, url, resolvedUrl) {
97
+ return new RemoteComponentsError(
98
+ `Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
99
+ );
100
+ }
96
101
  function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
97
102
  if (status === 404) {
98
103
  return new RemoteComponentsError(
@@ -144,7 +149,7 @@ function warnCrossOriginFetchError(logLocation, url) {
144
149
  }
145
150
  logWarn(
146
151
  logLocation,
147
- `Failed to fetch cross-origin resource "${parsed.href}". If this is a protected deployment, ensure withRemoteComponentsHostProxy middleware is configured in your host and that the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
152
+ `Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
148
153
  );
149
154
  } catch {
150
155
  }
@@ -657,6 +662,7 @@ import * as ReactDOM from "react-dom";
657
662
  import * as ReactDOMClient from "react-dom/client";
658
663
 
659
664
  // src/config/webpack/apply-shared-modules.ts
665
+ var DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
660
666
  function applySharedModules(bundle, resolve) {
661
667
  logDebug(
662
668
  "SharedModules",
@@ -700,13 +706,16 @@ function applySharedModules(bundle, resolve) {
700
706
  } else {
701
707
  logWarn(
702
708
  "SharedModules",
703
- `webpackBundle.m is not available for bundle "${bundle}"`
709
+ `webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
704
710
  );
705
711
  }
706
712
  }
707
713
  }
708
714
  } else {
709
- logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
715
+ logWarn(
716
+ "SharedModules",
717
+ `No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
718
+ );
710
719
  logDebug(
711
720
  "SharedModules",
712
721
  `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
@@ -960,11 +969,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
960
969
  }).then(resolve).catch((error) => {
961
970
  const isProxied = isProxiedUrl(resolvedUrl);
962
971
  if (isProxied) {
963
- reject(
964
- new RemoteComponentsError(
965
- `Failed to load chunk "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
966
- )
967
- );
972
+ reject(failedProxiedAssetError("chunk", url, resolvedUrl));
968
973
  } else {
969
974
  warnCrossOriginFetchError("ChunkLoader", url);
970
975
  reject(error);
@@ -1342,6 +1347,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
1342
1347
  }
1343
1348
 
1344
1349
  // src/runtime/turbopack/shared-modules.ts
1350
+ var DEDUPLICATION_WARNING = "This module will not be deduplicated \u2014 the remote may load its own copy, which can cause duplicate instance errors (e.g. invalid hook calls if React is loaded twice).";
1345
1351
  async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
1346
1352
  const self = globalThis;
1347
1353
  self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
@@ -1392,7 +1398,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
1392
1398
  } else {
1393
1399
  logError(
1394
1400
  "SharedModules",
1395
- `Host shared module "${module}" not found for ID ${id}`
1401
+ `Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
1396
1402
  );
1397
1403
  }
1398
1404
  }
@@ -1409,7 +1415,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
1409
1415
  } else {
1410
1416
  logError(
1411
1417
  "SharedModules",
1412
- `Shared module "${module}" not found for "${bundle}"`
1418
+ `Shared module "${module}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
1413
1419
  );
1414
1420
  }
1415
1421
  }
@@ -1572,11 +1578,7 @@ async function loadScripts(scripts, resolveClientUrl) {
1572
1578
  newScript.onerror = () => {
1573
1579
  const isProxied = isProxiedUrl(resolvedSrc);
1574
1580
  if (isProxied) {
1575
- reject(
1576
- new RemoteComponentsError(
1577
- `Failed to load script "${newSrc}" via proxy "${resolvedSrc}". Ensure withRemoteComponentsHostProxy middleware is configured and "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher. See: ${CORS_DOCS_URL}`
1578
- )
1579
- );
1581
+ reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
1580
1582
  } else {
1581
1583
  warnCrossOriginFetchError("ScriptLoader", newSrc);
1582
1584
  reject(