remote-components 0.2.0 → 0.2.2

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 (80) 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 +93 -59
  10. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  11. package/dist/host/nextjs/app/client-only.d.ts +28 -9
  12. package/dist/host/nextjs/app/client-only.js +91 -58
  13. package/dist/host/nextjs/app/client-only.js.map +1 -1
  14. package/dist/host/nextjs/pages.cjs +4 -4
  15. package/dist/host/nextjs/pages.cjs.map +1 -1
  16. package/dist/host/nextjs/pages.js +4 -4
  17. package/dist/host/nextjs/pages.js.map +1 -1
  18. package/dist/host/react.cjs +33 -23
  19. package/dist/host/react.cjs.map +1 -1
  20. package/dist/host/react.d.ts +2 -366
  21. package/dist/host/react.js +33 -23
  22. package/dist/host/react.js.map +1 -1
  23. package/dist/index-4c65355c.d.ts +298 -0
  24. package/dist/internal/config/webpack/apply-shared-modules.cjs +6 -2
  25. package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -1
  26. package/dist/internal/config/webpack/apply-shared-modules.js +6 -2
  27. package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -1
  28. package/dist/internal/config/webpack/next-client-pages-loader.d.ts +3 -3
  29. package/dist/internal/host/nextjs/app-client.cjs +4 -3
  30. package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
  31. package/dist/internal/host/nextjs/app-client.d.ts +1 -1
  32. package/dist/internal/host/nextjs/app-client.js +4 -3
  33. package/dist/internal/host/nextjs/app-client.js.map +1 -1
  34. package/dist/internal/host/nextjs/image-impl.cjs +8 -4
  35. package/dist/internal/host/nextjs/image-impl.cjs.map +1 -1
  36. package/dist/internal/host/nextjs/image-impl.d.ts +2 -2
  37. package/dist/internal/host/nextjs/image-impl.js +8 -4
  38. package/dist/internal/host/nextjs/image-impl.js.map +1 -1
  39. package/dist/internal/host/react/context.cjs +5 -10
  40. package/dist/internal/host/react/context.cjs.map +1 -1
  41. package/dist/internal/host/react/context.d.ts +7 -18
  42. package/dist/internal/host/react/context.js +4 -9
  43. package/dist/internal/host/react/context.js.map +1 -1
  44. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs +5 -4
  45. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -1
  46. package/dist/internal/host/react/hooks/use-resolve-client-url.d.ts +4 -1
  47. package/dist/internal/host/react/hooks/use-resolve-client-url.js +5 -4
  48. package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -1
  49. package/dist/internal/host/shared/config.cjs.map +1 -1
  50. package/dist/internal/host/shared/config.d.ts +7 -0
  51. package/dist/internal/host/shared/resolved-data.d.ts +2 -2
  52. package/dist/internal/runtime/loaders/component-loader.d.ts +1 -1
  53. package/dist/internal/runtime/loaders/script-loader.cjs +1 -6
  54. package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
  55. package/dist/internal/runtime/loaders/script-loader.js +4 -9
  56. package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
  57. package/dist/internal/runtime/turbopack/chunk-loader.cjs +1 -6
  58. package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
  59. package/dist/internal/runtime/turbopack/chunk-loader.js +4 -9
  60. package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
  61. package/dist/internal/runtime/turbopack/shared-modules.cjs +3 -2
  62. package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
  63. package/dist/internal/runtime/turbopack/shared-modules.js +3 -2
  64. package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
  65. package/dist/internal/utils/error.cjs +7 -0
  66. package/dist/internal/utils/error.cjs.map +1 -1
  67. package/dist/internal/utils/error.d.ts +2 -1
  68. package/dist/internal/utils/error.js +6 -0
  69. package/dist/internal/utils/error.js.map +1 -1
  70. package/dist/internal/utils/logger.cjs +1 -1
  71. package/dist/internal/utils/logger.cjs.map +1 -1
  72. package/dist/internal/utils/logger.d.ts +1 -1
  73. package/dist/internal/utils/logger.js +1 -1
  74. package/dist/internal/utils/logger.js.map +1 -1
  75. package/dist/remote/html.cjs +1 -1
  76. package/dist/remote/html.cjs.map +1 -1
  77. package/dist/remote/html.js +1 -1
  78. package/dist/remote/html.js.map +1 -1
  79. package/dist/{server-handoff-8c89b856.d.ts → server-handoff-ce13bebc.d.ts} +2 -2
  80. package/package.json +1 -9
package/dist/host/html.js CHANGED
@@ -101,6 +101,11 @@ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
101
101
  }
102
102
  return fallback;
103
103
  }
104
+ function failedProxiedAssetError(kind, url, resolvedUrl) {
105
+ return new RemoteComponentsError(
106
+ `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}`
107
+ );
108
+ }
104
109
  function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
105
110
  if (status === 404) {
106
111
  return new RemoteComponentsError(
@@ -166,7 +171,7 @@ function warnCrossOriginFetchError(logLocation, url) {
166
171
  }
167
172
  logWarn(
168
173
  logLocation,
169
- `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}`
174
+ `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}`
170
175
  );
171
176
  } catch {
172
177
  }
@@ -254,23 +259,28 @@ function applySharedModules(bundle, resolve) {
254
259
  } else {
255
260
  logWarn(
256
261
  "SharedModules",
257
- `webpackBundle.m is not available for bundle "${bundle}"`
262
+ `webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
258
263
  );
259
264
  }
260
265
  }
261
266
  }
262
267
  } else {
263
- logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
268
+ logWarn(
269
+ "SharedModules",
270
+ `No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
271
+ );
264
272
  logDebug(
265
273
  "SharedModules",
266
274
  `Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
267
275
  );
268
276
  }
269
277
  }
278
+ var DEDUPLICATION_SKIPPED;
270
279
  var init_apply_shared_modules = __esm({
271
280
  "src/config/webpack/apply-shared-modules.ts"() {
272
281
  "use strict";
273
282
  init_logger();
283
+ DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
274
284
  }
275
285
  });
276
286
 
@@ -612,11 +622,7 @@ async function loadScripts(scripts, resolveClientUrl) {
612
622
  newScript.onerror = () => {
613
623
  const isProxied = isProxiedUrl(resolvedSrc);
614
624
  if (isProxied) {
615
- reject(
616
- new RemoteComponentsError(
617
- `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}`
618
- )
619
- );
625
+ reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
620
626
  } else {
621
627
  warnCrossOriginFetchError("ScriptLoader", newSrc);
622
628
  reject(
@@ -638,7 +644,6 @@ var init_script_loader = __esm({
638
644
  "use strict";
639
645
  init_constants2();
640
646
  init_protected_rc_fallback();
641
- init_constants();
642
647
  init_error();
643
648
  init_logger();
644
649
  }
@@ -818,11 +823,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
818
823
  }).then(resolve).catch((error) => {
819
824
  const isProxied = isProxiedUrl(resolvedUrl);
820
825
  if (isProxied) {
821
- reject(
822
- new RemoteComponentsError(
823
- `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}`
824
- )
825
- );
826
+ reject(failedProxiedAssetError("chunk", url, resolvedUrl));
826
827
  } else {
827
828
  warnCrossOriginFetchError("ChunkLoader", url);
828
829
  reject(error);
@@ -974,7 +975,6 @@ var init_chunk_loader = __esm({
974
975
  "use strict";
975
976
  init_constants2();
976
977
  init_protected_rc_fallback();
977
- init_constants();
978
978
  init_error();
979
979
  init_logger();
980
980
  init_patterns();
@@ -1268,7 +1268,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
1268
1268
  } else {
1269
1269
  logError(
1270
1270
  "SharedModules",
1271
- `Host shared module "${module}" not found for ID ${id}`
1271
+ `Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
1272
1272
  );
1273
1273
  }
1274
1274
  }
@@ -1285,7 +1285,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
1285
1285
  } else {
1286
1286
  logError(
1287
1287
  "SharedModules",
1288
- `Shared module "${module}" not found for "${bundle}"`
1288
+ `Shared module "${module}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
1289
1289
  );
1290
1290
  }
1291
1291
  }
@@ -1336,6 +1336,7 @@ function getSharedModule(bundle, id) {
1336
1336
  }
1337
1337
  return null;
1338
1338
  }
1339
+ var DEDUPLICATION_WARNING;
1339
1340
  var init_shared_modules = __esm({
1340
1341
  "src/runtime/turbopack/shared-modules.ts"() {
1341
1342
  "use strict";
@@ -1343,6 +1344,7 @@ var init_shared_modules = __esm({
1343
1344
  init_logger();
1344
1345
  init_module();
1345
1346
  init_patterns();
1347
+ 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).";
1346
1348
  }
1347
1349
  });
1348
1350