remote-components 0.0.40 → 0.0.42
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/html/host.cjs +429 -312
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +429 -312
- package/dist/html/host.js.map +1 -1
- package/dist/html/remote.cjs.map +1 -1
- package/dist/html/remote.js.map +1 -1
- package/dist/internal/shared/client/remote-component.cjs +404 -304
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +10 -1
- package/dist/internal/shared/client/remote-component.js +404 -304
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/internal/shared/error.cjs +4 -4
- package/dist/internal/shared/error.cjs.map +1 -1
- package/dist/internal/shared/error.d.ts +5 -2
- package/dist/internal/shared/error.js +4 -4
- package/dist/internal/shared/error.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs +22 -7
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js +22 -7
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
- package/dist/internal/webpack/shared-modules.cjs +36 -1
- package/dist/internal/webpack/shared-modules.cjs.map +1 -1
- package/dist/internal/webpack/shared-modules.js +36 -1
- package/dist/internal/webpack/shared-modules.js.map +1 -1
- package/dist/next/host/client/index.cjs +415 -314
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.js +415 -314
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/react/index.cjs +7 -6
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +7 -6
- package/dist/react/index.js.map +1 -1
- package/package.json +6 -8
|
@@ -301,14 +301,14 @@ var RemoteComponentsError = class extends Error {
|
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
303
|
function multipleRemoteComponentsError(url) {
|
|
304
|
-
return new
|
|
304
|
+
return new RemoteComponentsError(
|
|
305
305
|
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
306
306
|
);
|
|
307
307
|
}
|
|
308
|
-
function failedToFetchRemoteComponentError(url,
|
|
308
|
+
function failedToFetchRemoteComponentError(url, { status, statusText }, help = "Is the URL correct and accessible?") {
|
|
309
309
|
return new RemoteComponentsError(
|
|
310
|
-
`Failed to fetch Remote Component from "${url}".
|
|
311
|
-
{ cause:
|
|
310
|
+
`Failed to fetch Remote Component from "${url}". ${help}`,
|
|
311
|
+
{ cause: new Error(`${status} ${statusText}`) }
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
314
|
|
|
@@ -319,6 +319,18 @@ var JSXRuntime = __toESM(require("react/jsx-runtime"), 1);
|
|
|
319
319
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
320
320
|
var ReactDOMClient = __toESM(require("react-dom/client"), 1);
|
|
321
321
|
|
|
322
|
+
// src/shared/utils/logger.ts
|
|
323
|
+
var PREFIX = "remote-components";
|
|
324
|
+
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
325
|
+
function logDebug(location2, message) {
|
|
326
|
+
if (DEBUG) {
|
|
327
|
+
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function logWarn(location2, message) {
|
|
331
|
+
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
332
|
+
}
|
|
333
|
+
|
|
322
334
|
// src/shared/webpack/next-client-pages-loader.ts
|
|
323
335
|
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
324
336
|
const self = globalThis;
|
|
@@ -433,28 +445,62 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
433
445
|
|
|
434
446
|
// src/shared/webpack/shared-modules.ts
|
|
435
447
|
function applySharedModules(bundle, resolve) {
|
|
448
|
+
logDebug(
|
|
449
|
+
"SharedModules",
|
|
450
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
451
|
+
);
|
|
452
|
+
logDebug(
|
|
453
|
+
"SharedModules",
|
|
454
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
455
|
+
);
|
|
436
456
|
const self = globalThis;
|
|
437
457
|
if (self.__remote_webpack_require__?.[bundle]) {
|
|
438
458
|
const modulePaths = Object.keys(
|
|
439
459
|
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
440
460
|
);
|
|
461
|
+
logDebug(
|
|
462
|
+
"SharedModules",
|
|
463
|
+
`Available module paths in __remote_webpack_require__[${bundle}]: ${modulePaths}`
|
|
464
|
+
);
|
|
441
465
|
for (const [key, value] of Object.entries(resolve)) {
|
|
442
466
|
let ids = modulePaths.filter((p) => p === key);
|
|
443
467
|
if (ids.length === 0) {
|
|
444
468
|
ids = modulePaths.filter((p) => p.includes(key));
|
|
445
469
|
}
|
|
470
|
+
if (ids.length === 0) {
|
|
471
|
+
logDebug(
|
|
472
|
+
"SharedModules",
|
|
473
|
+
`No matching module path found for shared module "${key}"`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
446
476
|
for (let id of ids) {
|
|
447
477
|
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
448
478
|
if (webpackBundle.m) {
|
|
449
479
|
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
450
|
-
|
|
480
|
+
const mappedId = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
481
|
+
logDebug(
|
|
482
|
+
"SharedModules",
|
|
483
|
+
`Mapped module id: "${id}" -> "${mappedId}"`
|
|
484
|
+
);
|
|
485
|
+
id = mappedId;
|
|
451
486
|
}
|
|
452
487
|
webpackBundle.m[id] = (module2) => {
|
|
453
488
|
module2.exports = value;
|
|
454
489
|
};
|
|
490
|
+
} else {
|
|
491
|
+
logWarn(
|
|
492
|
+
"SharedModules",
|
|
493
|
+
`webpackBundle.m is not available for bundle "${bundle}"`
|
|
494
|
+
);
|
|
455
495
|
}
|
|
456
496
|
}
|
|
457
497
|
}
|
|
498
|
+
} else {
|
|
499
|
+
logWarn("SharedModules", `No webpack require found for bundle "${bundle}"`);
|
|
500
|
+
logDebug(
|
|
501
|
+
"SharedModules",
|
|
502
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
503
|
+
);
|
|
458
504
|
}
|
|
459
505
|
}
|
|
460
506
|
|
|
@@ -575,52 +621,7 @@ function getBundleKey(bundle) {
|
|
|
575
621
|
return escapeString(bundle);
|
|
576
622
|
}
|
|
577
623
|
|
|
578
|
-
// src/shared/client/
|
|
579
|
-
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
|
|
580
|
-
const self = globalThis;
|
|
581
|
-
if (!self.__remote_bundle_url__) {
|
|
582
|
-
self.__remote_bundle_url__ = {};
|
|
583
|
-
}
|
|
584
|
-
self.__remote_bundle_url__[bundle ?? "default"] = url;
|
|
585
|
-
self.__webpack_get_script_filename__ = () => null;
|
|
586
|
-
if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
|
|
587
|
-
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
588
|
-
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
589
|
-
self.__original_webpack_require__ = self.__webpack_require__;
|
|
590
|
-
}
|
|
591
|
-
self.__webpack_chunk_load__ = createChunkLoader(runtime);
|
|
592
|
-
self.__webpack_require__ = createModuleRequire(runtime);
|
|
593
|
-
self.__webpack_require_type__ = runtime;
|
|
594
|
-
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
595
|
-
const remoteBundle = bundle ?? "default";
|
|
596
|
-
self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
|
|
597
|
-
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
if (runtime === RUNTIME_TURBOPACK) {
|
|
601
|
-
await Promise.all(
|
|
602
|
-
scripts.map((script) => {
|
|
603
|
-
if (script.src) {
|
|
604
|
-
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
605
|
-
}
|
|
606
|
-
return Promise.resolve(void 0);
|
|
607
|
-
})
|
|
608
|
-
);
|
|
609
|
-
}
|
|
610
|
-
await initializeSharedModules(
|
|
611
|
-
bundle ?? "default",
|
|
612
|
-
// include all core modules as shared
|
|
613
|
-
{
|
|
614
|
-
react: async () => (await import("react")).default,
|
|
615
|
-
"react-dom": async () => (await import("react-dom")).default,
|
|
616
|
-
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
617
|
-
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
618
|
-
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
619
|
-
...shared
|
|
620
|
-
},
|
|
621
|
-
remoteShared
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
+
// src/shared/client/chunk-loader.ts
|
|
624
625
|
function createChunkLoader(runtime) {
|
|
625
626
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
626
627
|
const self = globalThis;
|
|
@@ -735,46 +736,232 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
735
736
|
await Promise.all(loadChunkLists);
|
|
736
737
|
}
|
|
737
738
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
739
|
+
|
|
740
|
+
// src/shared/client/turbopack-module.ts
|
|
741
|
+
function handleTurbopackModule(bundle, moduleId, id) {
|
|
742
|
+
const self = globalThis;
|
|
743
|
+
const bundleKey = getBundleKey(bundle);
|
|
744
|
+
const modules = self[`TURBOPACK_${bundleKey}`];
|
|
745
|
+
const moduleInit = findModuleInit(modules, moduleId);
|
|
746
|
+
const exports = {};
|
|
747
|
+
const moduleExports = { exports };
|
|
748
|
+
if (!self.__remote_components_turbopack_modules__) {
|
|
749
|
+
self.__remote_components_turbopack_modules__ = {};
|
|
750
|
+
}
|
|
751
|
+
if (!self.__remote_components_turbopack_modules__[bundle]) {
|
|
752
|
+
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
753
|
+
}
|
|
754
|
+
if (self.__remote_components_turbopack_modules__[bundle][moduleId]) {
|
|
755
|
+
return self.__remote_components_turbopack_modules__[bundle][moduleId];
|
|
756
|
+
}
|
|
757
|
+
if (typeof moduleInit !== "function") {
|
|
758
|
+
throw new Error(
|
|
759
|
+
`Module ${id} not found in bundle ${bundle} with id ${moduleId}`
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
|
|
763
|
+
if (!self.__remote_components_turbopack_global__) {
|
|
764
|
+
self.__remote_components_turbopack_global__ = {};
|
|
765
|
+
}
|
|
766
|
+
if (!self.__remote_components_turbopack_global__[bundle]) {
|
|
767
|
+
self.__remote_components_turbopack_global__[bundle] = {};
|
|
768
|
+
}
|
|
769
|
+
const allModules = modules?.flat() ?? [];
|
|
770
|
+
moduleInit(
|
|
771
|
+
createTurbopackContext(
|
|
772
|
+
bundle,
|
|
773
|
+
exports,
|
|
774
|
+
moduleExports,
|
|
775
|
+
allModules,
|
|
776
|
+
moduleInit,
|
|
777
|
+
id,
|
|
778
|
+
self
|
|
779
|
+
),
|
|
780
|
+
moduleExports,
|
|
781
|
+
exports
|
|
782
|
+
);
|
|
783
|
+
if (self.__remote_components_turbopack_modules__[bundle][moduleId] !== moduleExports.exports) {
|
|
784
|
+
self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
|
|
785
|
+
}
|
|
786
|
+
return moduleExports.exports;
|
|
787
|
+
}
|
|
788
|
+
function findModuleInit(modules, moduleId) {
|
|
789
|
+
const allModules = modules?.flat() ?? [];
|
|
790
|
+
if (typeof allModules[1] === "string" || typeof allModules[1] === "number") {
|
|
791
|
+
const normalizedId = /^[0-9]+$/.test(moduleId) ? Number(moduleId) : moduleId;
|
|
792
|
+
let moduleIdIndex = allModules.indexOf(normalizedId);
|
|
793
|
+
if (moduleIdIndex === -1) {
|
|
794
|
+
moduleIdIndex = allModules.findIndex(
|
|
795
|
+
(bundleEntry) => typeof bundleEntry === "string" && bundleEntry.startsWith(moduleId) || bundleEntry === normalizedId
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
if (moduleIdIndex !== -1) {
|
|
799
|
+
while (typeof allModules[moduleIdIndex] !== "function" && moduleIdIndex < allModules.length) {
|
|
800
|
+
moduleIdIndex++;
|
|
749
801
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
802
|
+
return allModules[moduleIdIndex];
|
|
803
|
+
}
|
|
804
|
+
} else {
|
|
805
|
+
return allModules.find(
|
|
806
|
+
(bundleEntry) => typeof bundleEntry === "object" && bundleEntry !== null && moduleId in bundleEntry
|
|
807
|
+
)?.[moduleId];
|
|
808
|
+
}
|
|
809
|
+
return void 0;
|
|
810
|
+
}
|
|
811
|
+
function createTurbopackContext(bundle, exports, moduleExports, allModules, moduleInit, id, self) {
|
|
812
|
+
return {
|
|
813
|
+
// HMR not implemented for Remote Components
|
|
814
|
+
k: {
|
|
815
|
+
register() {
|
|
816
|
+
},
|
|
817
|
+
registerExports() {
|
|
818
|
+
},
|
|
819
|
+
signature() {
|
|
820
|
+
return (fn) => fn;
|
|
753
821
|
}
|
|
754
|
-
|
|
755
|
-
|
|
822
|
+
},
|
|
823
|
+
// ESM exports setup
|
|
824
|
+
s(bindings, esmId) {
|
|
825
|
+
let mod = exports;
|
|
826
|
+
if (typeof esmId === "string" || typeof esmId === "number") {
|
|
827
|
+
if (!self.__remote_components_turbopack_modules__) {
|
|
828
|
+
self.__remote_components_turbopack_modules__ = {};
|
|
829
|
+
}
|
|
830
|
+
if (!self.__remote_components_turbopack_modules__[bundle]) {
|
|
831
|
+
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
832
|
+
}
|
|
833
|
+
if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {
|
|
834
|
+
self.__remote_components_turbopack_modules__[bundle][esmId] = {};
|
|
835
|
+
}
|
|
836
|
+
mod = self.__remote_components_turbopack_modules__[bundle][esmId];
|
|
756
837
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
838
|
+
Object.defineProperty(mod, "__esModule", { value: true });
|
|
839
|
+
if (Array.isArray(bindings)) {
|
|
840
|
+
let i = 0;
|
|
841
|
+
while (i < bindings.length) {
|
|
842
|
+
const propName = bindings[i++];
|
|
843
|
+
const tagOrFunc = bindings[i++];
|
|
844
|
+
if (typeof tagOrFunc === "number") {
|
|
845
|
+
Object.defineProperty(mod, propName, {
|
|
846
|
+
value: bindings[i++],
|
|
847
|
+
enumerable: true,
|
|
848
|
+
writable: false
|
|
849
|
+
});
|
|
850
|
+
} else {
|
|
851
|
+
const getterFn = tagOrFunc;
|
|
852
|
+
if (typeof bindings[i] === "function") {
|
|
853
|
+
const setterFn = bindings[i++];
|
|
854
|
+
Object.defineProperty(mod, propName, {
|
|
855
|
+
get: getterFn,
|
|
856
|
+
set: setterFn,
|
|
857
|
+
enumerable: true
|
|
858
|
+
});
|
|
859
|
+
} else {
|
|
860
|
+
Object.defineProperty(mod, propName, {
|
|
861
|
+
get: getterFn,
|
|
862
|
+
enumerable: true
|
|
863
|
+
});
|
|
864
|
+
}
|
|
764
865
|
}
|
|
765
|
-
|
|
866
|
+
}
|
|
766
867
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
868
|
+
},
|
|
869
|
+
// import
|
|
870
|
+
i(importId) {
|
|
871
|
+
let mod;
|
|
872
|
+
if (typeof importId === "string") {
|
|
873
|
+
const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
|
|
874
|
+
importId
|
|
875
|
+
)?.groups ?? {};
|
|
876
|
+
const normalizedId = importId.replace(
|
|
877
|
+
/\s+<export(?<specifier>.*)>$/,
|
|
878
|
+
""
|
|
773
879
|
);
|
|
880
|
+
mod = self.__webpack_require__?.(`[${bundle}] ${normalizedId}`);
|
|
881
|
+
if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
882
|
+
if (exportSource === "*") {
|
|
883
|
+
mod[exportName] = mod;
|
|
884
|
+
} else {
|
|
885
|
+
mod[exportName] = mod[exportSource];
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
} else {
|
|
889
|
+
mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
|
|
774
890
|
}
|
|
775
|
-
|
|
891
|
+
if (typeof mod !== "object" || mod === null) {
|
|
892
|
+
mod = { default: mod };
|
|
893
|
+
} else if (!("default" in mod) && mod.toString() !== "[object Module]") {
|
|
894
|
+
try {
|
|
895
|
+
mod.default = mod;
|
|
896
|
+
} catch {
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return mod;
|
|
900
|
+
},
|
|
901
|
+
// require
|
|
902
|
+
r(requireId) {
|
|
903
|
+
return self.__webpack_require__?.(`[${bundle}] ${requireId}`);
|
|
904
|
+
},
|
|
905
|
+
// value exports
|
|
906
|
+
v(value) {
|
|
907
|
+
if (typeof value === "function") {
|
|
908
|
+
exports.default = value((vid) => {
|
|
909
|
+
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
910
|
+
});
|
|
911
|
+
} else {
|
|
912
|
+
moduleExports.exports = value;
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
// async module initializer
|
|
916
|
+
async a(mod) {
|
|
917
|
+
let result;
|
|
918
|
+
await mod(
|
|
919
|
+
() => {
|
|
920
|
+
},
|
|
921
|
+
(value) => result = value
|
|
922
|
+
);
|
|
923
|
+
exports.default = result;
|
|
924
|
+
},
|
|
925
|
+
// async module loader
|
|
926
|
+
async A(Aid) {
|
|
927
|
+
const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`);
|
|
928
|
+
return mod.default(
|
|
929
|
+
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
930
|
+
);
|
|
931
|
+
},
|
|
932
|
+
// chunk loader
|
|
933
|
+
l(url) {
|
|
934
|
+
const moduleInitIndex = allModules.indexOf(moduleInit);
|
|
935
|
+
if (moduleInitIndex !== -1) {
|
|
936
|
+
const scriptIndex = allModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
937
|
+
if (scriptIndex !== -1) {
|
|
938
|
+
const script = allModules[scriptIndex];
|
|
939
|
+
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
940
|
+
const nextIndex = scriptSrc.indexOf("/_next");
|
|
941
|
+
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
942
|
+
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
943
|
+
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
throw new Error(
|
|
947
|
+
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
948
|
+
);
|
|
949
|
+
},
|
|
950
|
+
// global object for this bundle
|
|
951
|
+
g: self.__remote_components_turbopack_global__?.[bundle],
|
|
952
|
+
m: moduleExports,
|
|
953
|
+
e: exports
|
|
776
954
|
};
|
|
777
955
|
}
|
|
956
|
+
|
|
957
|
+
// src/shared/client/turbopack-patterns.ts
|
|
958
|
+
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
959
|
+
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|e)\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
960
|
+
var ASYNC_MODULE_LOADER_RE = /(?:__turbopack_context__|e)\.A\((?<asyncSharedModuleId>[0-9]+)\)/;
|
|
961
|
+
var ASYNC_MODULE_RESOLVE_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<inner>parentImport|e)=>Promise\.resolve\(\)\.then\(\(\)=>\k<inner>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
962
|
+
var ASYNC_MODULE_ALL_RE = /(?<ctx>__turbopack_context__|e)=>\{\k<ctx>\.v\((?<vCb>parentImport|t)=>Promise\.all\(\["[^"]+"\]\.map\((?<mapCb>chunk|t)=>\k<ctx>\.l\(\k<mapCb>\)\)\)\.then\(\(\)=>\k<vCb>\((?<sharedModuleId>[0-9]+)\)\)\)\}/;
|
|
963
|
+
|
|
964
|
+
// src/shared/client/shared-modules.ts
|
|
778
965
|
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
779
966
|
const self = globalThis;
|
|
780
967
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
@@ -791,14 +978,12 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
791
978
|
return false;
|
|
792
979
|
}
|
|
793
980
|
const funcCode = idOrFunc.toString();
|
|
794
|
-
return
|
|
981
|
+
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
795
982
|
});
|
|
796
983
|
if (sharedModuleInitializerIndex > 0) {
|
|
797
984
|
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
798
985
|
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
799
|
-
const { sharedModuleId } =
|
|
800
|
-
sharedModuleInitializerCode
|
|
801
|
-
)?.groups ?? {};
|
|
986
|
+
const { sharedModuleId } = REMOTE_SHARED_ASSIGNMENT_RE.exec(sharedModuleInitializerCode)?.groups ?? {};
|
|
802
987
|
if (sharedModuleId) {
|
|
803
988
|
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
804
989
|
bundle,
|
|
@@ -810,33 +995,11 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
810
995
|
}
|
|
811
996
|
if (sharedModuleInitializer) {
|
|
812
997
|
const { shared } = await sharedModuleInitializer;
|
|
813
|
-
const sharedModuleIds =
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
const newAllModules = self[`TURBOPACK_${bundleKey}`]?.flat() ?? [];
|
|
819
|
-
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
820
|
-
asyncSharedModuleIdNumber
|
|
821
|
-
);
|
|
822
|
-
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
823
|
-
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
824
|
-
}
|
|
825
|
-
if (asyncSharedModule) {
|
|
826
|
-
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
827
|
-
const { sharedModuleId } = /e=>{e\.v\(e=>Promise\.resolve\(\)\.then\(\(\)=>e\((?<sharedModuleId>[0-9]+)\)\)\)}/.exec(
|
|
828
|
-
asyncSharedModuleCode
|
|
829
|
-
)?.groups ?? /e=>{e\.v\(t=>Promise\.all\(\["[^"]+"\].map\(t=>e\.l\(t\)\)\)\.then\(\(\)=>t\((?<sharedModuleId>[0-9]+)\)\)\)}/.exec(
|
|
830
|
-
asyncSharedModuleCode
|
|
831
|
-
)?.groups ?? {};
|
|
832
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
833
|
-
"__remote_shared_module_",
|
|
834
|
-
""
|
|
835
|
-
);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
return acc;
|
|
839
|
-
}, {});
|
|
998
|
+
const sharedModuleIds = extractSharedModuleIds(
|
|
999
|
+
shared,
|
|
1000
|
+
bundleKey,
|
|
1001
|
+
self
|
|
1002
|
+
);
|
|
840
1003
|
return Promise.all(
|
|
841
1004
|
Object.entries(sharedModuleIds).map(async ([id, module2]) => {
|
|
842
1005
|
if (self.__remote_shared_modules__?.[bundle]) {
|
|
@@ -860,6 +1023,31 @@ async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {
|
|
|
860
1023
|
})
|
|
861
1024
|
);
|
|
862
1025
|
}
|
|
1026
|
+
function extractSharedModuleIds(shared, bundleKey, self) {
|
|
1027
|
+
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1028
|
+
const { asyncSharedModuleId } = ASYNC_MODULE_LOADER_RE.exec(value.toString())?.groups ?? {};
|
|
1029
|
+
if (asyncSharedModuleId) {
|
|
1030
|
+
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
1031
|
+
let asyncSharedModule;
|
|
1032
|
+
const newAllModules = self[`TURBOPACK_${bundleKey}`]?.flat() ?? [];
|
|
1033
|
+
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
1034
|
+
asyncSharedModuleIdNumber
|
|
1035
|
+
);
|
|
1036
|
+
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1037
|
+
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
1038
|
+
}
|
|
1039
|
+
if (asyncSharedModule) {
|
|
1040
|
+
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
1041
|
+
const { sharedModuleId } = ASYNC_MODULE_RESOLVE_RE.exec(asyncSharedModuleCode)?.groups ?? ASYNC_MODULE_ALL_RE.exec(asyncSharedModuleCode)?.groups ?? {};
|
|
1042
|
+
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1043
|
+
"__remote_shared_module_",
|
|
1044
|
+
""
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return acc;
|
|
1049
|
+
}, {});
|
|
1050
|
+
}
|
|
863
1051
|
function getSharedModule(bundle, id) {
|
|
864
1052
|
const self = globalThis;
|
|
865
1053
|
for (const [key, value] of Object.entries(
|
|
@@ -871,210 +1059,100 @@ function getSharedModule(bundle, id) {
|
|
|
871
1059
|
}
|
|
872
1060
|
return null;
|
|
873
1061
|
}
|
|
874
|
-
|
|
1062
|
+
|
|
1063
|
+
// src/shared/client/webpack-adapter.ts
|
|
1064
|
+
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
|
|
875
1065
|
const self = globalThis;
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
(bundleEntry) => typeof bundleEntry === "string" && bundleEntry.startsWith(moduleId) || bundleEntry === normalizedId
|
|
886
|
-
);
|
|
1066
|
+
if (!self.__remote_bundle_url__) {
|
|
1067
|
+
self.__remote_bundle_url__ = {};
|
|
1068
|
+
}
|
|
1069
|
+
self.__remote_bundle_url__[bundle ?? "default"] = url;
|
|
1070
|
+
self.__webpack_get_script_filename__ = () => null;
|
|
1071
|
+
if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
|
|
1072
|
+
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1073
|
+
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1074
|
+
self.__original_webpack_require__ = self.__webpack_require__;
|
|
887
1075
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1076
|
+
self.__webpack_chunk_load__ = createChunkLoader(runtime);
|
|
1077
|
+
self.__webpack_require__ = createModuleRequire(runtime);
|
|
1078
|
+
self.__webpack_require_type__ = runtime;
|
|
1079
|
+
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1080
|
+
const remoteBundle = bundle ?? "default";
|
|
1081
|
+
self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
|
|
1082
|
+
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
893
1083
|
}
|
|
894
|
-
} else {
|
|
895
|
-
moduleInit = allModules.find(
|
|
896
|
-
(bundleEntry) => typeof bundleEntry === "object" && bundleEntry !== null && moduleId in bundleEntry
|
|
897
|
-
)?.[moduleId];
|
|
898
|
-
}
|
|
899
|
-
const exports = {};
|
|
900
|
-
const moduleExports = { exports };
|
|
901
|
-
if (!self.__remote_components_turbopack_modules__) {
|
|
902
|
-
self.__remote_components_turbopack_modules__ = {};
|
|
903
|
-
}
|
|
904
|
-
if (!self.__remote_components_turbopack_modules__[bundle]) {
|
|
905
|
-
self.__remote_components_turbopack_modules__[bundle] = {};
|
|
906
1084
|
}
|
|
907
|
-
if (
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1085
|
+
if (runtime === RUNTIME_TURBOPACK) {
|
|
1086
|
+
await Promise.all(
|
|
1087
|
+
scripts.map((script) => {
|
|
1088
|
+
if (script.src) {
|
|
1089
|
+
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
1090
|
+
}
|
|
1091
|
+
return Promise.resolve(void 0);
|
|
1092
|
+
})
|
|
913
1093
|
);
|
|
914
1094
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
});
|
|
963
|
-
} else {
|
|
964
|
-
const getterFn = tagOrFunc;
|
|
965
|
-
if (typeof bindings[i] === "function") {
|
|
966
|
-
const setterFn = bindings[i++];
|
|
967
|
-
Object.defineProperty(mod, propName, {
|
|
968
|
-
get: getterFn,
|
|
969
|
-
set: setterFn,
|
|
970
|
-
enumerable: true
|
|
971
|
-
});
|
|
972
|
-
} else {
|
|
973
|
-
Object.defineProperty(mod, propName, {
|
|
974
|
-
get: getterFn,
|
|
975
|
-
enumerable: true
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
},
|
|
982
|
-
// import
|
|
983
|
-
i(importId) {
|
|
984
|
-
let mod;
|
|
985
|
-
if (typeof importId === "string") {
|
|
986
|
-
const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
|
|
987
|
-
importId
|
|
988
|
-
)?.groups ?? {};
|
|
989
|
-
const normalizedId = importId.replace(
|
|
990
|
-
/\s+<export(?<specifier>.*)>$/,
|
|
991
|
-
""
|
|
992
|
-
);
|
|
993
|
-
mod = self.__webpack_require__?.(
|
|
994
|
-
`[${bundle}] ${normalizedId}`
|
|
995
|
-
);
|
|
996
|
-
if (exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
997
|
-
if (exportSource === "*") {
|
|
998
|
-
mod[exportName] = mod;
|
|
999
|
-
} else {
|
|
1000
|
-
mod[exportName] = mod[exportSource];
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
} else {
|
|
1004
|
-
mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
|
|
1005
|
-
}
|
|
1006
|
-
if (typeof mod !== "object") {
|
|
1007
|
-
mod = { default: mod };
|
|
1008
|
-
} else if (!("default" in mod) && // eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
1009
|
-
mod.toString() !== "[object Module]") {
|
|
1010
|
-
try {
|
|
1011
|
-
mod.default = mod;
|
|
1012
|
-
} catch {
|
|
1095
|
+
const coreShared = {
|
|
1096
|
+
react: async () => (await import("react")).default,
|
|
1097
|
+
"react-dom": async () => (await import("react-dom")).default,
|
|
1098
|
+
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1099
|
+
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1100
|
+
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1101
|
+
...shared
|
|
1102
|
+
};
|
|
1103
|
+
await initializeSharedModules(
|
|
1104
|
+
bundle ?? "default",
|
|
1105
|
+
// include all core modules as shared
|
|
1106
|
+
coreShared,
|
|
1107
|
+
remoteShared
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
function createModuleRequire(runtime) {
|
|
1111
|
+
return (id) => {
|
|
1112
|
+
const self = globalThis;
|
|
1113
|
+
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1114
|
+
bundle: "default",
|
|
1115
|
+
id
|
|
1116
|
+
};
|
|
1117
|
+
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
1118
|
+
logDebug("WebpackAdapter", `remoteRuntime: "${remoteRuntime}"`);
|
|
1119
|
+
try {
|
|
1120
|
+
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1121
|
+
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1122
|
+
}
|
|
1123
|
+
const sharedModuleId = moduleId ?? id;
|
|
1124
|
+
const sharedModule = getSharedModule(bundle ?? "default", sharedModuleId);
|
|
1125
|
+
if (sharedModule) {
|
|
1126
|
+
return sharedModule;
|
|
1127
|
+
}
|
|
1128
|
+
if (bundle && moduleId) {
|
|
1129
|
+
return handleTurbopackModule(bundle, moduleId, id);
|
|
1130
|
+
}
|
|
1131
|
+
throw new Error(`Module "${id}" not found.`);
|
|
1132
|
+
} catch (requireError) {
|
|
1133
|
+
logWarn(
|
|
1134
|
+
"WebpackAdapter",
|
|
1135
|
+
`Module require failed: ${String(requireError)}`
|
|
1136
|
+
);
|
|
1137
|
+
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1138
|
+
throw new RemoteComponentsError(
|
|
1139
|
+
`Module "${id}" not found in remote component bundle "${bundle}".`,
|
|
1140
|
+
{
|
|
1141
|
+
cause: requireError instanceof Error ? requireError : void 0
|
|
1013
1142
|
}
|
|
1014
|
-
}
|
|
1015
|
-
return mod;
|
|
1016
|
-
},
|
|
1017
|
-
// require
|
|
1018
|
-
r(requireId) {
|
|
1019
|
-
return self.__webpack_require__?.(`[${bundle}] ${requireId}`);
|
|
1020
|
-
},
|
|
1021
|
-
// value exports
|
|
1022
|
-
v(value) {
|
|
1023
|
-
if (typeof value === "function") {
|
|
1024
|
-
exports.default = value((vid) => {
|
|
1025
|
-
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
1026
|
-
});
|
|
1027
|
-
} else {
|
|
1028
|
-
moduleExports.exports = value;
|
|
1029
|
-
}
|
|
1030
|
-
},
|
|
1031
|
-
// async module initializer
|
|
1032
|
-
async a(mod) {
|
|
1033
|
-
let result;
|
|
1034
|
-
await mod(
|
|
1035
|
-
() => {
|
|
1036
|
-
},
|
|
1037
|
-
(value) => result = value
|
|
1038
1143
|
);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
},
|
|
1048
|
-
// chunk loader
|
|
1049
|
-
l(url) {
|
|
1050
|
-
const moduleInitIndex = allModules.indexOf(moduleInit);
|
|
1051
|
-
if (moduleInitIndex !== -1) {
|
|
1052
|
-
const scriptIndex = allModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
1053
|
-
if (scriptIndex !== -1) {
|
|
1054
|
-
const script = allModules[scriptIndex];
|
|
1055
|
-
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1056
|
-
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1057
|
-
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1058
|
-
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
1059
|
-
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
throw new Error(
|
|
1063
|
-
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1144
|
+
}
|
|
1145
|
+
try {
|
|
1146
|
+
logDebug("WebpackAdapter", "Falling back to original webpack require");
|
|
1147
|
+
return self.__original_webpack_require__(id);
|
|
1148
|
+
} catch (originalError) {
|
|
1149
|
+
throw new RemoteComponentsError(
|
|
1150
|
+
`Module "${id}" not found in remote component bundle "${bundle}".`,
|
|
1151
|
+
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1064
1152
|
);
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
m: moduleExports,
|
|
1069
|
-
e: exports
|
|
1070
|
-
},
|
|
1071
|
-
moduleExports,
|
|
1072
|
-
exports
|
|
1073
|
-
);
|
|
1074
|
-
if (self.__remote_components_turbopack_modules__[bundle][moduleId] !== moduleExports.exports) {
|
|
1075
|
-
self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
|
|
1076
|
-
}
|
|
1077
|
-
return moduleExports.exports;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1078
1156
|
}
|
|
1079
1157
|
|
|
1080
1158
|
// src/shared/client/component-loader.ts
|
|
@@ -1102,6 +1180,18 @@ async function loadRemoteComponent({
|
|
|
1102
1180
|
await loadScripts(scripts);
|
|
1103
1181
|
}
|
|
1104
1182
|
const hostShared = await shared;
|
|
1183
|
+
logDebug(
|
|
1184
|
+
"ComponentLoader",
|
|
1185
|
+
`loadRemoteComponent: bundle="${bundle}", name="${name}"`
|
|
1186
|
+
);
|
|
1187
|
+
logDebug(
|
|
1188
|
+
"ComponentLoader",
|
|
1189
|
+
`Host shared modules available: ${Object.keys(hostShared)}`
|
|
1190
|
+
);
|
|
1191
|
+
logDebug(
|
|
1192
|
+
"ComponentLoader",
|
|
1193
|
+
`Remote shared modules requested: ${JSON.stringify(remoteShared)}`
|
|
1194
|
+
);
|
|
1105
1195
|
await setupWebpackRuntime(
|
|
1106
1196
|
runtime,
|
|
1107
1197
|
scripts,
|
|
@@ -1121,6 +1211,11 @@ async function loadRemoteComponent({
|
|
|
1121
1211
|
(acc, [key, value]) => {
|
|
1122
1212
|
if (typeof hostShared[value] !== "undefined") {
|
|
1123
1213
|
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
1214
|
+
} else {
|
|
1215
|
+
logDebug(
|
|
1216
|
+
"ComponentLoader",
|
|
1217
|
+
`Remote requests "${value}" but host doesn't provide it`
|
|
1218
|
+
);
|
|
1124
1219
|
}
|
|
1125
1220
|
return acc;
|
|
1126
1221
|
},
|
|
@@ -1136,6 +1231,11 @@ async function loadRemoteComponent({
|
|
|
1136
1231
|
})
|
|
1137
1232
|
);
|
|
1138
1233
|
applySharedModules(bundle, resolve);
|
|
1234
|
+
} else {
|
|
1235
|
+
logWarn(
|
|
1236
|
+
"ComponentLoader",
|
|
1237
|
+
"No bundle specified, skipping shared module setup"
|
|
1238
|
+
);
|
|
1139
1239
|
}
|
|
1140
1240
|
if (data.length > 0) {
|
|
1141
1241
|
return await loadRSCComponent(rscName ?? name, data);
|
|
@@ -1453,7 +1553,7 @@ function RemoteComponent({
|
|
|
1453
1553
|
});
|
|
1454
1554
|
childrenRef.current = [];
|
|
1455
1555
|
}
|
|
1456
|
-
if (isolate !== false && typeof document !== "undefined" && !shadowRoot) {
|
|
1556
|
+
if (isolate !== false && typeof document !== "undefined" && (!shadowRoot || !shadowRoot.isConnected)) {
|
|
1457
1557
|
const self = globalThis;
|
|
1458
1558
|
const shadowRootKey = `__remote_components_shadowroot_${keySuffix}`;
|
|
1459
1559
|
let shadowRootElement = null;
|
|
@@ -1483,7 +1583,7 @@ function RemoteComponent({
|
|
|
1483
1583
|
);
|
|
1484
1584
|
if (resetStyles.length > 1) {
|
|
1485
1585
|
resetStyles.forEach((style, index) => {
|
|
1486
|
-
if (index > 0) {
|
|
1586
|
+
if (index > 0 && style.getAttribute("data-remote-components-reset") !== "react") {
|
|
1487
1587
|
style.remove();
|
|
1488
1588
|
}
|
|
1489
1589
|
});
|
|
@@ -1518,9 +1618,10 @@ function RemoteComponent({
|
|
|
1518
1618
|
};
|
|
1519
1619
|
const res = await fetch(url, fetchInit);
|
|
1520
1620
|
if (!res.ok) {
|
|
1521
|
-
let error = failedToFetchRemoteComponentError(
|
|
1522
|
-
|
|
1523
|
-
|
|
1621
|
+
let error = failedToFetchRemoteComponentError(
|
|
1622
|
+
url.href,
|
|
1623
|
+
res
|
|
1624
|
+
);
|
|
1524
1625
|
try {
|
|
1525
1626
|
const body = await res.text();
|
|
1526
1627
|
const parser2 = new DOMParser();
|
|
@@ -1841,7 +1942,7 @@ function RemoteComponent({
|
|
|
1841
1942
|
route: data?.route || DEFAULT_ROUTE,
|
|
1842
1943
|
runtime: prevIsRemoteComponentRef.current ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
1843
1944
|
}) });
|
|
1844
|
-
const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { "data-remote-components-reset": "", children: `:host { all: initial; }` }) : null;
|
|
1945
|
+
const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
1845
1946
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react2.createElement)(
|
|
1846
1947
|
"link",
|
|
1847
1948
|
{
|