remote-components 0.0.42 → 0.0.44
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/{component-loader-2ca91ad8.d.ts → component-loader-26b1f55e.d.ts} +63 -1
- package/dist/html/host.cjs +55 -19
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +55 -19
- package/dist/html/host.js.map +1 -1
- package/dist/internal/next/host/app-router-client.d.ts +30 -3
- package/dist/internal/next/remote/render-client.cjs +1 -1
- package/dist/internal/next/remote/render-client.cjs.map +1 -1
- package/dist/internal/next/remote/render-client.js +1 -1
- package/dist/internal/next/remote/render-client.js.map +1 -1
- package/dist/internal/shared/client/remote-component.cjs +29 -0
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +2 -2
- package/dist/internal/shared/client/remote-component.js +29 -0
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/dom-flight.d.ts +1 -1
- package/dist/internal/shared/ssr/fetch-headers.cjs +4 -6
- package/dist/internal/shared/ssr/fetch-headers.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-headers.d.ts +1 -1
- package/dist/internal/shared/ssr/fetch-headers.js +4 -6
- package/dist/internal/shared/ssr/fetch-headers.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs +14 -23
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.d.ts +5 -9
- package/dist/internal/shared/ssr/fetch-remote-component.js +13 -21
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs +40 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +39 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.js +16 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -0
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +1 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +1 -1
- package/dist/next/config.cjs +1 -9
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +1 -9
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/app-router-server.cjs +7 -8
- package/dist/next/host/app-router-server.cjs.map +1 -1
- package/dist/next/host/app-router-server.d.ts +13 -4
- package/dist/next/host/app-router-server.js +7 -8
- package/dist/next/host/app-router-server.js.map +1 -1
- package/dist/next/host/client/index.cjs +149 -72
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.d.ts +2 -49
- package/dist/next/host/client/index.js +144 -66
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/next/host/pages-router-client.cjs +62 -2
- package/dist/next/host/pages-router-client.cjs.map +1 -1
- package/dist/next/host/pages-router-client.d.ts +26 -1
- package/dist/next/host/pages-router-client.js +63 -3
- package/dist/next/host/pages-router-client.js.map +1 -1
- package/dist/next/host/pages-router-server.cjs +18 -22
- package/dist/next/host/pages-router-server.cjs.map +1 -1
- package/dist/next/host/pages-router-server.d.ts +36 -3
- package/dist/next/host/pages-router-server.js +18 -22
- package/dist/next/host/pages-router-server.js.map +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.cjs +1581 -87
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +13 -14
- package/dist/react/index.js +1559 -87
- package/dist/react/index.js.map +1 -1
- package/dist/shared/host/app.cjs +1 -1
- package/dist/shared/host/app.cjs.map +1 -1
- package/dist/shared/host/app.js +1 -1
- package/dist/shared/host/app.js.map +1 -1
- package/dist/shared/host/pages.cjs +1 -1
- package/dist/shared/host/pages.cjs.map +1 -1
- package/dist/shared/host/pages.js +1 -1
- package/dist/shared/host/pages.js.map +1 -1
- package/dist/shared/remote/app.cjs +1 -1
- package/dist/shared/remote/app.cjs.map +1 -1
- package/dist/shared/remote/app.js +1 -1
- package/dist/shared/remote/app.js.map +1 -1
- package/dist/shared/remote/pages.cjs +1 -1
- package/dist/shared/remote/pages.cjs.map +1 -1
- package/dist/shared/remote/pages.js +1 -1
- package/dist/shared/remote/pages.js.map +1 -1
- package/dist/types-2ab78f67.d.ts +71 -0
- package/package.json +54 -32
- package/dist/types-235b68a5.d.ts +0 -32
- package/dist/types-cbf6c34f.d.ts +0 -9
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import '
|
|
4
|
-
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { R as RemoteComponentMetadata } from '../../../types-2ab78f67.js';
|
|
4
|
+
|
|
5
|
+
interface RemoteComponentProps {
|
|
6
|
+
/** The src provided to the `<RemoteComponent>` component. May be relative or absolute URL. */
|
|
7
|
+
src: string;
|
|
8
|
+
/** The src converted to a URL object. For relative URLs, the VERCEL_URL is used as the origin. */
|
|
9
|
+
serverUrl: string;
|
|
10
|
+
name: string;
|
|
11
|
+
bundle: string;
|
|
12
|
+
route?: string;
|
|
13
|
+
runtime?: RemoteComponentMetadata['runtime'];
|
|
14
|
+
data: string[];
|
|
15
|
+
nextData?: {
|
|
16
|
+
props: {
|
|
17
|
+
pageProps: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
buildId?: string;
|
|
20
|
+
} | null;
|
|
21
|
+
scripts?: {
|
|
22
|
+
src: string;
|
|
23
|
+
}[];
|
|
24
|
+
links?: Record<string, string | boolean | undefined>[];
|
|
25
|
+
remoteShared?: Record<string, string>;
|
|
26
|
+
isolate?: boolean;
|
|
27
|
+
mode?: 'open' | 'closed';
|
|
28
|
+
reset?: boolean;
|
|
29
|
+
type?: RemoteComponentMetadata['type'];
|
|
30
|
+
children: react.ReactNode;
|
|
31
|
+
}
|
|
5
32
|
|
|
6
33
|
declare module 'react/jsx-runtime' {
|
|
7
34
|
namespace JSX {
|
|
@@ -48,7 +48,7 @@ async function tryImportShared() {
|
|
|
48
48
|
} catch {
|
|
49
49
|
return {
|
|
50
50
|
// eslint-disable-next-line camelcase
|
|
51
|
-
__remote_components_missing_shared__: "Remote Components shared
|
|
51
|
+
__remote_components_missing_shared__: "Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponents` on both host and remote?"
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/remote/render-client.tsx"],"sourcesContent":["'use client';\n\nimport { use } from 'react';\nimport { RemoteComponentsError } from '#internal/shared/client/remote-component';\n\n// try to import the shared module from the remote application\n// use an empty object as a fallback if the import fails to avoid breaking the application\nasync function tryImportShared() {\n try {\n const self = globalThis as unknown as {\n TURBOPACK_REMOTE_SHARED: { shared: Record<string, string> };\n };\n // this is a marker to find the shared module initializer in the Turbopack bundle\n // DO NOT REMOVE\n self.TURBOPACK_REMOTE_SHARED = await import(\n 'remote-components/shared/remote/app'\n );\n const { shared } = self.TURBOPACK_REMOTE_SHARED;\n return shared;\n } catch {\n return {\n // eslint-disable-next-line camelcase\n __remote_components_missing_shared__:\n 'Remote Components shared
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/remote/render-client.tsx"],"sourcesContent":["'use client';\n\nimport { use } from 'react';\nimport { RemoteComponentsError } from '#internal/shared/client/remote-component';\n\n// try to import the shared module from the remote application\n// use an empty object as a fallback if the import fails to avoid breaking the application\nasync function tryImportShared() {\n try {\n const self = globalThis as unknown as {\n TURBOPACK_REMOTE_SHARED: { shared: Record<string, string> };\n };\n // this is a marker to find the shared module initializer in the Turbopack bundle\n // DO NOT REMOVE\n self.TURBOPACK_REMOTE_SHARED = await import(\n 'remote-components/shared/remote/app'\n );\n const { shared } = self.TURBOPACK_REMOTE_SHARED;\n return shared;\n } catch {\n return {\n // eslint-disable-next-line camelcase\n __remote_components_missing_shared__:\n 'Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponents` on both host and remote?',\n };\n }\n}\n\n// create a promise singleton to import the shared module\nexport const tryImportSharedPromise = tryImportShared();\n\nexport function RemoteComponentSharedRemote({ name }: { name: string }) {\n const shared = use(tryImportSharedPromise);\n\n if ('__remote_components_missing_shared__' in shared) {\n throw new RemoteComponentsError(\n shared.__remote_components_missing_shared__,\n );\n }\n\n return (\n // render the shared module as a script tag\n <script\n data-remote-components-shared=\"\"\n id={`${name}_shared`}\n type=\"application/json\"\n >\n {JSON.stringify(shared)}\n </script>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CI;AAAA;AAAA;AAAA;AAxCJ,mBAAoB;AACpB,8BAAsC;AAItC,eAAe,kBAAkB;AAC/B,MAAI;AACF,UAAM,OAAO;AAKb,SAAK,0BAA0B,MAAM,OACnC,qCACF;AACA,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,WAAO;AAAA,EACT,QAAE;AACA,WAAO;AAAA;AAAA,MAEL,sCACE;AAAA,IACJ;AAAA,EACF;AACF;AAGO,MAAM,yBAAyB,gBAAgB;AAE/C,SAAS,4BAA4B,EAAE,KAAK,GAAqB;AACtE,QAAM,aAAS,kBAAI,sBAAsB;AAEzC,MAAI,0CAA0C,QAAQ;AACpD,UAAM,IAAI;AAAA,MACR,OAAO;AAAA,IACT;AAAA,EACF;AAEA,SAEE;AAAA,IAAC;AAAA;AAAA,MACC,iCAA8B;AAAA,MAC9B,IAAI,GAAG;AAAA,MACP,MAAK;AAAA,MAEJ,eAAK,UAAU,MAAM;AAAA;AAAA,EACxB;AAEJ;","names":[]}
|
|
@@ -11,7 +11,7 @@ async function tryImportShared() {
|
|
|
11
11
|
} catch {
|
|
12
12
|
return {
|
|
13
13
|
// eslint-disable-next-line camelcase
|
|
14
|
-
__remote_components_missing_shared__: "Remote Components shared
|
|
14
|
+
__remote_components_missing_shared__: "Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponents` on both host and remote?"
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/remote/render-client.tsx"],"sourcesContent":["'use client';\n\nimport { use } from 'react';\nimport { RemoteComponentsError } from '#internal/shared/client/remote-component';\n\n// try to import the shared module from the remote application\n// use an empty object as a fallback if the import fails to avoid breaking the application\nasync function tryImportShared() {\n try {\n const self = globalThis as unknown as {\n TURBOPACK_REMOTE_SHARED: { shared: Record<string, string> };\n };\n // this is a marker to find the shared module initializer in the Turbopack bundle\n // DO NOT REMOVE\n self.TURBOPACK_REMOTE_SHARED = await import(\n 'remote-components/shared/remote/app'\n );\n const { shared } = self.TURBOPACK_REMOTE_SHARED;\n return shared;\n } catch {\n return {\n // eslint-disable-next-line camelcase\n __remote_components_missing_shared__:\n 'Remote Components shared
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/remote/render-client.tsx"],"sourcesContent":["'use client';\n\nimport { use } from 'react';\nimport { RemoteComponentsError } from '#internal/shared/client/remote-component';\n\n// try to import the shared module from the remote application\n// use an empty object as a fallback if the import fails to avoid breaking the application\nasync function tryImportShared() {\n try {\n const self = globalThis as unknown as {\n TURBOPACK_REMOTE_SHARED: { shared: Record<string, string> };\n };\n // this is a marker to find the shared module initializer in the Turbopack bundle\n // DO NOT REMOVE\n self.TURBOPACK_REMOTE_SHARED = await import(\n 'remote-components/shared/remote/app'\n );\n const { shared } = self.TURBOPACK_REMOTE_SHARED;\n return shared;\n } catch {\n return {\n // eslint-disable-next-line camelcase\n __remote_components_missing_shared__:\n 'Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponents` on both host and remote?',\n };\n }\n}\n\n// create a promise singleton to import the shared module\nexport const tryImportSharedPromise = tryImportShared();\n\nexport function RemoteComponentSharedRemote({ name }: { name: string }) {\n const shared = use(tryImportSharedPromise);\n\n if ('__remote_components_missing_shared__' in shared) {\n throw new RemoteComponentsError(\n shared.__remote_components_missing_shared__,\n );\n }\n\n return (\n // render the shared module as a script tag\n <script\n data-remote-components-shared=\"\"\n id={`${name}_shared`}\n type=\"application/json\"\n >\n {JSON.stringify(shared)}\n </script>\n );\n}\n"],"mappings":";AA0CI;AAxCJ,SAAS,WAAW;AACpB,SAAS,6BAA6B;AAItC,eAAe,kBAAkB;AAC/B,MAAI;AACF,UAAM,OAAO;AAKb,SAAK,0BAA0B,MAAM,OACnC,qCACF;AACA,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,WAAO;AAAA,EACT,QAAE;AACA,WAAO;AAAA;AAAA,MAEL,sCACE;AAAA,IACJ;AAAA,EACF;AACF;AAGO,MAAM,yBAAyB,gBAAgB;AAE/C,SAAS,4BAA4B,EAAE,KAAK,GAAqB;AACtE,QAAM,SAAS,IAAI,sBAAsB;AAEzC,MAAI,0CAA0C,QAAQ;AACpD,UAAM,IAAI;AAAA,MACR,OAAO;AAAA,IACT;AAAA,EACF;AAEA;AAAA;AAAA,IAEE;AAAA,MAAC;AAAA;AAAA,QACC,iCAA8B;AAAA,QAC9B,IAAI,GAAG;AAAA,QACP,MAAK;AAAA,QAEJ,eAAK,UAAU,MAAM;AAAA;AAAA,IACxB;AAAA;AAEJ;","names":[]}
|
|
@@ -361,6 +361,7 @@ function getBundleKey(bundle) {
|
|
|
361
361
|
// src/shared/client/chunk-loader.ts
|
|
362
362
|
function createChunkLoader(runtime) {
|
|
363
363
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
364
|
+
logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
|
|
364
365
|
const self = globalThis;
|
|
365
366
|
const {
|
|
366
367
|
bundle,
|
|
@@ -370,8 +371,14 @@ function createChunkLoader(runtime) {
|
|
|
370
371
|
bundle: scriptBundle ?? "",
|
|
371
372
|
id: chunkId
|
|
372
373
|
};
|
|
374
|
+
logDebug(
|
|
375
|
+
"ChunkLoader",
|
|
376
|
+
`Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
|
|
377
|
+
);
|
|
373
378
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
379
|
+
logDebug("ChunkLoader", `Remote runtime: "${remoteRuntime}"`);
|
|
374
380
|
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
381
|
+
logDebug("ChunkLoader", "Skipping chunk load - webpack runtime detected");
|
|
375
382
|
return Promise.resolve(void 0);
|
|
376
383
|
}
|
|
377
384
|
const url = new URL(
|
|
@@ -382,14 +389,17 @@ function createChunkLoader(runtime) {
|
|
|
382
389
|
self.__remote_bundle_url__?.[bundle ?? "default"] ?? new URL(location.origin)
|
|
383
390
|
).href;
|
|
384
391
|
if (url.endsWith(".css")) {
|
|
392
|
+
logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
|
|
385
393
|
return;
|
|
386
394
|
}
|
|
387
395
|
if (!self.__remote_components_turbopack_chunk_loader_promise__) {
|
|
388
396
|
self.__remote_components_turbopack_chunk_loader_promise__ = {};
|
|
389
397
|
}
|
|
390
398
|
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
399
|
+
logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
|
|
391
400
|
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
392
401
|
}
|
|
402
|
+
logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
|
|
393
403
|
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
394
404
|
fetch(url).then((res) => res.text()).then((code) => {
|
|
395
405
|
if (code.includes("globalThis.TURBOPACK")) {
|
|
@@ -401,7 +411,12 @@ function createChunkLoader(runtime) {
|
|
|
401
411
|
};
|
|
402
412
|
}
|
|
403
413
|
async function handleTurbopackChunk(code, bundle, url) {
|
|
414
|
+
logDebug(
|
|
415
|
+
"ChunkLoader",
|
|
416
|
+
`Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
|
|
417
|
+
);
|
|
404
418
|
if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
|
|
419
|
+
logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
|
|
405
420
|
const preloadLinks = document.querySelectorAll(
|
|
406
421
|
`link[rel="preload"][href="${new URL(url).pathname}"]`
|
|
407
422
|
);
|
|
@@ -410,6 +425,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
410
425
|
}
|
|
411
426
|
const self = globalThis;
|
|
412
427
|
const bundleKey = getBundleKey(bundle);
|
|
428
|
+
logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
|
|
413
429
|
const transformedCode = code.replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`).replace(
|
|
414
430
|
/TURBOPACK_WORKER_LOCATION/g,
|
|
415
431
|
`TURBOPACK_WORKER_LOCATION_${bundleKey}`
|
|
@@ -429,6 +445,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
429
445
|
)
|
|
430
446
|
).href}$1$2.js.map`
|
|
431
447
|
);
|
|
448
|
+
logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
|
|
432
449
|
await new Promise((scriptResolve, scriptReject) => {
|
|
433
450
|
const blob = new Blob([transformedCode], {
|
|
434
451
|
type: "application/javascript; charset=UTF-8"
|
|
@@ -455,10 +472,18 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
455
472
|
document.head.appendChild(script);
|
|
456
473
|
});
|
|
457
474
|
const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`];
|
|
475
|
+
logDebug(
|
|
476
|
+
"ChunkLoader",
|
|
477
|
+
`Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
|
|
478
|
+
);
|
|
458
479
|
const loadChunkLists = [];
|
|
459
480
|
while (chunkLists?.length) {
|
|
460
481
|
const { chunks } = chunkLists.shift() ?? { chunks: [] };
|
|
461
482
|
if (chunks.length > 0) {
|
|
483
|
+
logDebug(
|
|
484
|
+
"ChunkLoader",
|
|
485
|
+
`Loading ${chunks.length} additional chunks for bundle "${bundle}": [${chunks.join(", ")}]`
|
|
486
|
+
);
|
|
462
487
|
chunks.forEach((id) => {
|
|
463
488
|
const chunkLoadResult = self.__webpack_chunk_load__?.(
|
|
464
489
|
`[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
|
|
@@ -470,6 +495,10 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
470
495
|
}
|
|
471
496
|
}
|
|
472
497
|
if (loadChunkLists.length > 0) {
|
|
498
|
+
logDebug(
|
|
499
|
+
"ChunkLoader",
|
|
500
|
+
`Waiting for ${loadChunkLists.length} additional chunks to load`
|
|
501
|
+
);
|
|
473
502
|
await Promise.all(loadChunkLists);
|
|
474
503
|
}
|
|
475
504
|
}
|