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.
- package/dist/config/nextjs.cjs +1 -1
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +1 -1
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +19 -17
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +19 -17
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +17 -19
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +17 -19
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/react.cjs +17 -15
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +17 -15
- package/dist/host/react.js.map +1 -1
- package/dist/internal/config/webpack/apply-shared-modules.cjs +6 -2
- package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -1
- package/dist/internal/config/webpack/apply-shared-modules.js +6 -2
- package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.cjs +1 -6
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.js +4 -9
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +1 -6
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js +4 -9
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.cjs +3 -2
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.js +3 -2
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/internal/utils/error.cjs +7 -0
- package/dist/internal/utils/error.cjs.map +1 -1
- package/dist/internal/utils/error.d.ts +2 -1
- package/dist/internal/utils/error.js +6 -0
- package/dist/internal/utils/error.js.map +1 -1
- package/dist/internal/utils/logger.cjs +1 -1
- package/dist/internal/utils/logger.cjs.map +1 -1
- package/dist/internal/utils/logger.d.ts +1 -1
- package/dist/internal/utils/logger.js +1 -1
- package/dist/internal/utils/logger.js.map +1 -1
- package/dist/remote/html.cjs +1 -1
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js +1 -1
- package/dist/remote/html.js.map +1 -1
- package/package.json +1 -1
package/dist/host/react.cjs
CHANGED
|
@@ -119,6 +119,11 @@ async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
|
119
119
|
}
|
|
120
120
|
return fallback;
|
|
121
121
|
}
|
|
122
|
+
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
123
|
+
return new RemoteComponentsError(
|
|
124
|
+
`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}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
122
127
|
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
123
128
|
if (status === 404) {
|
|
124
129
|
return new RemoteComponentsError(
|
|
@@ -170,7 +175,7 @@ function warnCrossOriginFetchError(logLocation, url) {
|
|
|
170
175
|
}
|
|
171
176
|
logWarn(
|
|
172
177
|
logLocation,
|
|
173
|
-
`Failed to fetch cross-origin resource "${parsed.href}".
|
|
178
|
+
`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}`
|
|
174
179
|
);
|
|
175
180
|
} catch {
|
|
176
181
|
}
|
|
@@ -683,6 +688,7 @@ var ReactDOM = __toESM(require("react-dom"), 1);
|
|
|
683
688
|
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
684
689
|
|
|
685
690
|
// src/config/webpack/apply-shared-modules.ts
|
|
691
|
+
var DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
686
692
|
function applySharedModules(bundle, resolve) {
|
|
687
693
|
logDebug(
|
|
688
694
|
"SharedModules",
|
|
@@ -726,13 +732,16 @@ function applySharedModules(bundle, resolve) {
|
|
|
726
732
|
} else {
|
|
727
733
|
logWarn(
|
|
728
734
|
"SharedModules",
|
|
729
|
-
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
735
|
+
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
730
736
|
);
|
|
731
737
|
}
|
|
732
738
|
}
|
|
733
739
|
}
|
|
734
740
|
} else {
|
|
735
|
-
logWarn(
|
|
741
|
+
logWarn(
|
|
742
|
+
"SharedModules",
|
|
743
|
+
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
744
|
+
);
|
|
736
745
|
logDebug(
|
|
737
746
|
"SharedModules",
|
|
738
747
|
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
@@ -986,11 +995,7 @@ function createChunkLoader(runtime, resolveClientUrl) {
|
|
|
986
995
|
}).then(resolve).catch((error) => {
|
|
987
996
|
const isProxied = isProxiedUrl(resolvedUrl);
|
|
988
997
|
if (isProxied) {
|
|
989
|
-
reject(
|
|
990
|
-
new RemoteComponentsError(
|
|
991
|
-
`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}`
|
|
992
|
-
)
|
|
993
|
-
);
|
|
998
|
+
reject(failedProxiedAssetError("chunk", url, resolvedUrl));
|
|
994
999
|
} else {
|
|
995
1000
|
warnCrossOriginFetchError("ChunkLoader", url);
|
|
996
1001
|
reject(error);
|
|
@@ -1368,6 +1373,7 @@ function createTurbopackContext(bundle, exports, moduleExports, modules, moduleI
|
|
|
1368
1373
|
}
|
|
1369
1374
|
|
|
1370
1375
|
// src/runtime/turbopack/shared-modules.ts
|
|
1376
|
+
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).";
|
|
1371
1377
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
1372
1378
|
const self = globalThis;
|
|
1373
1379
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -1418,7 +1424,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1418
1424
|
} else {
|
|
1419
1425
|
logError(
|
|
1420
1426
|
"SharedModules",
|
|
1421
|
-
`Host shared module "${module2}" not found for ID ${id}`
|
|
1427
|
+
`Host shared module "${module2}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1422
1428
|
);
|
|
1423
1429
|
}
|
|
1424
1430
|
}
|
|
@@ -1435,7 +1441,7 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
1435
1441
|
} else {
|
|
1436
1442
|
logError(
|
|
1437
1443
|
"SharedModules",
|
|
1438
|
-
`Shared module "${module2}" not found for "${bundle}"`
|
|
1444
|
+
`Shared module "${module2}" not found for "${bundle}". ${DEDUPLICATION_WARNING}`
|
|
1439
1445
|
);
|
|
1440
1446
|
}
|
|
1441
1447
|
}
|
|
@@ -1598,11 +1604,7 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
1598
1604
|
newScript.onerror = () => {
|
|
1599
1605
|
const isProxied = isProxiedUrl(resolvedSrc);
|
|
1600
1606
|
if (isProxied) {
|
|
1601
|
-
reject(
|
|
1602
|
-
new RemoteComponentsError(
|
|
1603
|
-
`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}`
|
|
1604
|
-
)
|
|
1605
|
-
);
|
|
1607
|
+
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
1606
1608
|
} else {
|
|
1607
1609
|
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
1608
1610
|
reject(
|