remote-components 0.4.2 → 0.4.3
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/{chunk-KVQI55BZ.cjs → chunk-2W7JBTID.cjs} +37 -36
- package/dist/chunk-2W7JBTID.cjs.map +1 -0
- package/dist/{chunk-TZT7DLO5.cjs → chunk-3AX5WLZD.cjs} +4 -4
- package/dist/{chunk-4O3EOST4.cjs → chunk-4AH3KXDW.cjs} +27 -27
- package/dist/{chunk-MTMDXJLM.js → chunk-4NW46ZVD.js} +410 -146
- package/dist/chunk-4NW46ZVD.js.map +1 -0
- package/dist/{chunk-SAGYPGIQ.js → chunk-55TEMSB5.js} +92 -23
- package/dist/chunk-55TEMSB5.js.map +1 -0
- package/dist/{chunk-RLI4YTBJ.cjs → chunk-7XXO2DLF.cjs} +96 -27
- package/dist/chunk-7XXO2DLF.cjs.map +1 -0
- package/dist/{chunk-RUWR74XQ.cjs → chunk-BBXVML3D.cjs} +1 -1
- package/dist/{chunk-RUWR74XQ.cjs.map → chunk-BBXVML3D.cjs.map} +1 -1
- package/dist/{chunk-42TVDI3G.cjs → chunk-C5EYU7EQ.cjs} +7 -7
- package/dist/{chunk-CC3WOSDO.js → chunk-DGZVFKSQ.js} +10 -9
- package/dist/chunk-DGZVFKSQ.js.map +1 -0
- package/dist/{chunk-AKOMV2UF.js → chunk-HL6BL5HY.js} +3 -3
- package/dist/chunk-HMB3SIVJ.cjs +973 -0
- package/dist/chunk-HMB3SIVJ.cjs.map +1 -0
- package/dist/{chunk-LOYJP2V2.js → chunk-HYVNEUIK.js} +5 -5
- package/dist/chunk-KV5J7PNM.js +152 -0
- package/dist/chunk-KV5J7PNM.js.map +1 -0
- package/dist/{chunk-LQ7VQ74E.js → chunk-LEKG4YWI.js} +2 -2
- package/dist/chunk-SECN7UAL.cjs +152 -0
- package/dist/chunk-SECN7UAL.cjs.map +1 -0
- package/dist/{chunk-S2A4TFLS.js → chunk-ULXU6XWH.js} +1 -1
- package/dist/{chunk-S2A4TFLS.js.map → chunk-ULXU6XWH.js.map} +1 -1
- package/dist/config/nextjs.cjs +7 -7
- package/dist/config/nextjs.js +2 -2
- package/dist/host/html.cjs +36 -36
- package/dist/host/html.js +10 -10
- package/dist/host/nextjs/app/client-only.cjs +17 -17
- package/dist/host/nextjs/app/client-only.js +8 -8
- package/dist/host/react.cjs +9 -9
- package/dist/host/react.js +8 -8
- package/dist/internal/config/webpack/next-client-pages-loader.cjs +151 -53
- package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.d.ts +8 -4
- package/dist/internal/config/webpack/next-client-pages-loader.js +153 -53
- package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -1
- package/dist/internal/host/shared/pipeline.d.ts +1 -1
- package/dist/internal/host/shared/shared-broker.cjs +106 -0
- package/dist/internal/host/shared/shared-broker.cjs.map +1 -0
- package/dist/internal/host/shared/shared-broker.d.ts +35 -0
- package/dist/internal/host/shared/shared-broker.js +80 -0
- package/dist/internal/host/shared/shared-broker.js.map +1 -0
- package/dist/internal/host/shared/shared-module-resolver.cjs +13 -22
- package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.d.ts +1 -1
- package/dist/internal/host/shared/shared-module-resolver.js +16 -22
- package/dist/internal/host/shared/shared-module-resolver.js.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.cjs +2 -1
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.d.ts +1 -1
- package/dist/internal/runtime/loaders/component-loader.js +2 -1
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/loaders/static-loader.d.ts +1 -1
- package/dist/internal/runtime/namespace.d.ts +1 -1
- package/dist/internal/runtime/turbopack/module.cjs +26 -4
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/module.d.ts +14 -7
- package/dist/internal/runtime/turbopack/module.js +27 -5
- package/dist/internal/runtime/turbopack/module.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.cjs +5 -4
- package/dist/internal/runtime/turbopack/remote-scope-setup.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.js +5 -4
- package/dist/internal/runtime/turbopack/remote-scope-setup.js.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.cjs +113 -26
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +3 -1
- package/dist/internal/runtime/turbopack/shared-modules.js +116 -26
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/internal/runtime/types.cjs.map +1 -1
- package/dist/internal/runtime/types.d.ts +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.map +1 -1
- package/dist/remote/html.cjs +6 -6
- package/dist/remote/html.js +2 -2
- package/dist/{script-VPOI7ARP.js → script-ISAHSV3X.js} +3 -3
- package/dist/{script-D5AD7HLV.cjs → script-YQCDUYDP.cjs} +4 -4
- package/dist/static-loader-EOJQHFZ6.cjs +11 -0
- package/dist/{static-loader-OHSAUD62.js → static-loader-Z24427MK.js} +3 -3
- package/dist/{turbopack-5N44NVPT.js → turbopack-7F757Z7V.js} +6 -6
- package/dist/{turbopack-EPXGK4EV.cjs → turbopack-DULMVTWV.cjs} +12 -12
- package/dist/{types-8b0edd78.d.ts → types-bd7be268.d.ts} +1 -5
- package/dist/{webpack-SIFRCBIN.cjs → webpack-6LXCB7WA.cjs} +14 -14
- package/dist/{webpack-KSDNIXMS.js → webpack-WGVTKJ3W.js} +5 -5
- package/package.json +1 -1
- package/dist/chunk-CC3WOSDO.js.map +0 -1
- package/dist/chunk-JJTCFQHE.cjs +0 -202
- package/dist/chunk-JJTCFQHE.cjs.map +0 -1
- package/dist/chunk-KVQI55BZ.cjs.map +0 -1
- package/dist/chunk-MKO52FRO.js +0 -202
- package/dist/chunk-MKO52FRO.js.map +0 -1
- package/dist/chunk-MQ2BBSL4.cjs +0 -709
- package/dist/chunk-MQ2BBSL4.cjs.map +0 -1
- package/dist/chunk-MTMDXJLM.js.map +0 -1
- package/dist/chunk-RLI4YTBJ.cjs.map +0 -1
- package/dist/chunk-SAGYPGIQ.js.map +0 -1
- package/dist/static-loader-UDIXK5MV.cjs +0 -11
- /package/dist/{chunk-TZT7DLO5.cjs.map → chunk-3AX5WLZD.cjs.map} +0 -0
- /package/dist/{chunk-4O3EOST4.cjs.map → chunk-4AH3KXDW.cjs.map} +0 -0
- /package/dist/{chunk-42TVDI3G.cjs.map → chunk-C5EYU7EQ.cjs.map} +0 -0
- /package/dist/{chunk-AKOMV2UF.js.map → chunk-HL6BL5HY.js.map} +0 -0
- /package/dist/{chunk-LOYJP2V2.js.map → chunk-HYVNEUIK.js.map} +0 -0
- /package/dist/{chunk-LQ7VQ74E.js.map → chunk-LEKG4YWI.js.map} +0 -0
- /package/dist/{script-VPOI7ARP.js.map → script-ISAHSV3X.js.map} +0 -0
- /package/dist/{script-D5AD7HLV.cjs.map → script-YQCDUYDP.cjs.map} +0 -0
- /package/dist/{static-loader-UDIXK5MV.cjs.map → static-loader-EOJQHFZ6.cjs.map} +0 -0
- /package/dist/{static-loader-OHSAUD62.js.map → static-loader-Z24427MK.js.map} +0 -0
- /package/dist/{turbopack-5N44NVPT.js.map → turbopack-7F757Z7V.js.map} +0 -0
- /package/dist/{turbopack-EPXGK4EV.cjs.map → turbopack-DULMVTWV.cjs.map} +0 -0
- /package/dist/{webpack-SIFRCBIN.cjs.map → webpack-6LXCB7WA.cjs.map} +0 -0
- /package/dist/{webpack-KSDNIXMS.js.map → webpack-WGVTKJ3W.js.map} +0 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
REMOTE_COMPONENT_REGEX,
|
|
3
|
-
RUNTIME_TURBOPACK,
|
|
4
2
|
RUNTIME_WEBPACK,
|
|
5
3
|
collapseDoubleSlashes,
|
|
6
|
-
|
|
4
|
+
createSharedModulePlan,
|
|
7
5
|
formatRemoteId,
|
|
8
6
|
getScope,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "./chunk-
|
|
7
|
+
installSharedModulePlan,
|
|
8
|
+
parseRemoteId
|
|
9
|
+
} from "./chunk-55TEMSB5.js";
|
|
12
10
|
import {
|
|
13
11
|
getNamespace
|
|
14
12
|
} from "./chunk-D5GNZB6O.js";
|
|
@@ -19,11 +17,74 @@ import {
|
|
|
19
17
|
logError,
|
|
20
18
|
logWarn,
|
|
21
19
|
warnCrossOriginFetchError
|
|
22
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ULXU6XWH.js";
|
|
23
21
|
import {
|
|
24
22
|
isProxiedUrl
|
|
25
23
|
} from "./chunk-X6YKUJKH.js";
|
|
26
24
|
|
|
25
|
+
// src/config/webpack/apply-shared-modules.ts
|
|
26
|
+
var DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
27
|
+
function applySharedModules(bundle, resolve) {
|
|
28
|
+
logDebug(
|
|
29
|
+
"SharedModules",
|
|
30
|
+
`applySharedModules called for bundle: "${bundle}"`
|
|
31
|
+
);
|
|
32
|
+
logDebug(
|
|
33
|
+
"SharedModules",
|
|
34
|
+
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
35
|
+
);
|
|
36
|
+
const self = globalThis;
|
|
37
|
+
const scope = getScope(bundle);
|
|
38
|
+
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
39
|
+
if (webpackBundle) {
|
|
40
|
+
const modulePaths = Object.keys(
|
|
41
|
+
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
42
|
+
);
|
|
43
|
+
logDebug(
|
|
44
|
+
"SharedModules",
|
|
45
|
+
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
46
|
+
);
|
|
47
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
48
|
+
const exactIds = modulePaths.filter((p) => p === key);
|
|
49
|
+
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
50
|
+
if (ids.length === 0) {
|
|
51
|
+
logDebug(
|
|
52
|
+
"SharedModules",
|
|
53
|
+
`No matching module path found for shared module "${key}"`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
for (const id of ids) {
|
|
57
|
+
if (webpackBundle.m) {
|
|
58
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
59
|
+
if (resolvedId !== id) {
|
|
60
|
+
logDebug(
|
|
61
|
+
"SharedModules",
|
|
62
|
+
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
webpackBundle.m[resolvedId] = (module) => {
|
|
66
|
+
module.exports = value;
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
logWarn(
|
|
70
|
+
"SharedModules",
|
|
71
|
+
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
logWarn(
|
|
78
|
+
"SharedModules",
|
|
79
|
+
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
80
|
+
);
|
|
81
|
+
logDebug(
|
|
82
|
+
"SharedModules",
|
|
83
|
+
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
27
88
|
// src/runtime/turbopack/patterns.ts
|
|
28
89
|
var MODULE_ID_PATTERN = '"[^"]+"|[0-9]+';
|
|
29
90
|
function stripQuotes(value) {
|
|
@@ -223,11 +284,18 @@ async function handleTurbopackChunk(code, scope, url) {
|
|
|
223
284
|
// src/runtime/turbopack/module.ts
|
|
224
285
|
function requireModule(scope, moduleId, fullId) {
|
|
225
286
|
const idStr = String(moduleId);
|
|
226
|
-
if (scope.moduleCache[idStr])
|
|
227
|
-
return scope.moduleCache[idStr];
|
|
228
287
|
const sharedModule = getSharedModule(scope, moduleId);
|
|
229
|
-
if (sharedModule)
|
|
288
|
+
if (sharedModule !== null) {
|
|
289
|
+
if (scope.moduleCache[idStr]) {
|
|
290
|
+
logDebug(
|
|
291
|
+
"TurbopackModule",
|
|
292
|
+
`Shared module "${idStr}" resolved from host and overrides a cached remote copy in "${scope.scopedName}"`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
230
295
|
return sharedModule;
|
|
296
|
+
}
|
|
297
|
+
if (scope.moduleCache[idStr])
|
|
298
|
+
return scope.moduleCache[idStr];
|
|
231
299
|
return handleTurbopackModule(
|
|
232
300
|
scope,
|
|
233
301
|
idStr,
|
|
@@ -247,7 +315,10 @@ function handleTurbopackModule(scope, moduleId, id) {
|
|
|
247
315
|
}
|
|
248
316
|
const moduleInit = findModuleInit(modules, moduleId);
|
|
249
317
|
const exports = {};
|
|
250
|
-
const moduleExports = {
|
|
318
|
+
const moduleExports = {
|
|
319
|
+
exports,
|
|
320
|
+
hot: createNoopHotModule()
|
|
321
|
+
};
|
|
251
322
|
if (typeof moduleInit !== "function") {
|
|
252
323
|
throw new Error(
|
|
253
324
|
`Module ${id} not found in bundle ${scope.name} with id ${moduleId}`
|
|
@@ -443,9 +514,22 @@ function createTurbopackContext(scope, exports, moduleExports, modules, moduleIn
|
|
|
443
514
|
e: exports
|
|
444
515
|
};
|
|
445
516
|
}
|
|
517
|
+
function createNoopHotModule() {
|
|
518
|
+
return {
|
|
519
|
+
active: true,
|
|
520
|
+
data: {},
|
|
521
|
+
accept() {
|
|
522
|
+
},
|
|
523
|
+
dispose() {
|
|
524
|
+
},
|
|
525
|
+
invalidate() {
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
446
529
|
|
|
447
530
|
// src/runtime/turbopack/shared-modules.ts
|
|
448
531
|
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).";
|
|
532
|
+
var INLINE_REMOTE_SHARED_RE = /["']?__remote_shared_module_(?<specifier>[^"':]+)["']?\s*:\s*\(\)\s*=>\s*(?:__turbopack_context__|[a-z])\.A\((?<asyncSharedModuleId>"[^"]+"|[0-9]+)\)/g;
|
|
449
533
|
function getTurbopackModules(scope) {
|
|
450
534
|
if (scope.turbopackModules.length > 0) {
|
|
451
535
|
return scope.turbopackModules;
|
|
@@ -498,17 +582,27 @@ async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}
|
|
|
498
582
|
"SharedModules",
|
|
499
583
|
`Resolved shared modules for scope="${scope.scopedName}": ${JSON.stringify(sharedModuleIds)}`
|
|
500
584
|
);
|
|
501
|
-
return
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
585
|
+
return installSharedModules(
|
|
586
|
+
scope,
|
|
587
|
+
hostShared,
|
|
588
|
+
sharedModuleIds,
|
|
589
|
+
(id, module) => `Host shared module "${module}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
const inlineSharedModuleIds = extractInlineSharedModuleIds(
|
|
593
|
+
allModules,
|
|
594
|
+
scope
|
|
595
|
+
);
|
|
596
|
+
if (Object.keys(inlineSharedModuleIds).length > 0) {
|
|
597
|
+
logDebug(
|
|
598
|
+
"SharedModules",
|
|
599
|
+
`Resolved inline shared modules for scope="${scope.scopedName}": ${JSON.stringify(inlineSharedModuleIds)}`
|
|
600
|
+
);
|
|
601
|
+
return installSharedModules(
|
|
602
|
+
scope,
|
|
603
|
+
hostShared,
|
|
604
|
+
inlineSharedModuleIds,
|
|
605
|
+
(id, module) => `Host shared module "${module}" not found for inline ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
512
606
|
);
|
|
513
607
|
}
|
|
514
608
|
logWarn(
|
|
@@ -521,20 +615,17 @@ async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}
|
|
|
521
615
|
`No TURBOPACK modules found for scope="${scope.scopedName}" (TURBOPACK_${scope.globalKey} is empty)`
|
|
522
616
|
);
|
|
523
617
|
}
|
|
524
|
-
|
|
525
|
-
Object.entries(remoteShared).map(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
})
|
|
618
|
+
const normalizedRemoteShared = Object.fromEntries(
|
|
619
|
+
Object.entries(remoteShared).map(([id, module]) => [
|
|
620
|
+
id.replace("[app-ssr]", "[app-client]"),
|
|
621
|
+
module
|
|
622
|
+
])
|
|
623
|
+
);
|
|
624
|
+
return installSharedModules(
|
|
625
|
+
scope,
|
|
626
|
+
hostShared,
|
|
627
|
+
normalizedRemoteShared,
|
|
628
|
+
(_id, module) => `Shared module "${module}" not found for "${scope.name}". ${DEDUPLICATION_WARNING}`
|
|
538
629
|
);
|
|
539
630
|
}
|
|
540
631
|
function extractSharedModuleIds(shared, scope) {
|
|
@@ -564,146 +655,319 @@ function extractSharedModuleIds(shared, scope) {
|
|
|
564
655
|
return acc;
|
|
565
656
|
}, {});
|
|
566
657
|
}
|
|
658
|
+
function extractInlineSharedModuleIds(allModules, scope) {
|
|
659
|
+
const sharedModuleIds = {};
|
|
660
|
+
for (const idOrFunc of allModules) {
|
|
661
|
+
if (typeof idOrFunc !== "function")
|
|
662
|
+
continue;
|
|
663
|
+
const funcCode = idOrFunc.toString();
|
|
664
|
+
if (!funcCode.includes("__remote_shared_module_"))
|
|
665
|
+
continue;
|
|
666
|
+
INLINE_REMOTE_SHARED_RE.lastIndex = 0;
|
|
667
|
+
for (const match of funcCode.matchAll(INLINE_REMOTE_SHARED_RE)) {
|
|
668
|
+
const specifier = match.groups?.specifier;
|
|
669
|
+
const asyncSharedModuleId = stripQuotes2(
|
|
670
|
+
match.groups?.asyncSharedModuleId
|
|
671
|
+
);
|
|
672
|
+
if (!specifier || !asyncSharedModuleId)
|
|
673
|
+
continue;
|
|
674
|
+
const asyncSharedModule = findModuleInit(
|
|
675
|
+
getTurbopackModules(scope),
|
|
676
|
+
asyncSharedModuleId
|
|
677
|
+
);
|
|
678
|
+
if (!asyncSharedModule)
|
|
679
|
+
continue;
|
|
680
|
+
const sharedModuleId = extractGroup(
|
|
681
|
+
ASYNC_MODULE_CALLBACK_RE,
|
|
682
|
+
asyncSharedModule.toString(),
|
|
683
|
+
"sharedModuleId"
|
|
684
|
+
);
|
|
685
|
+
sharedModuleIds[sharedModuleId ?? asyncSharedModuleId] = specifier;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return sharedModuleIds;
|
|
689
|
+
}
|
|
690
|
+
function stripQuotes2(value) {
|
|
691
|
+
if (value?.startsWith('"') && value.endsWith('"')) {
|
|
692
|
+
return value.slice(1, -1);
|
|
693
|
+
}
|
|
694
|
+
return value;
|
|
695
|
+
}
|
|
696
|
+
function installSharedModules(scope, hostShared, sharedModuleIds, missingMessage) {
|
|
697
|
+
const plan = createSharedModulePlan({
|
|
698
|
+
bundle: scope.name,
|
|
699
|
+
hostShared,
|
|
700
|
+
remoteShared: sharedModuleIds,
|
|
701
|
+
scope: `remote:${scope.scopedName}`,
|
|
702
|
+
callerTag: "SharedModules"
|
|
703
|
+
});
|
|
704
|
+
for (const entry of plan.entries) {
|
|
705
|
+
if (entry.status === "resolved") {
|
|
706
|
+
delete scope.moduleCache[entry.id];
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return installSharedModulePlan({
|
|
710
|
+
plan,
|
|
711
|
+
target: scope.sharedModules,
|
|
712
|
+
callerTag: "SharedModules",
|
|
713
|
+
onMissing: (entry) => {
|
|
714
|
+
logError("SharedModules", missingMessage(entry.id, entry.specifier));
|
|
715
|
+
}
|
|
716
|
+
}).then((results) => {
|
|
717
|
+
for (const entry of plan.entries) {
|
|
718
|
+
if (entry.status === "resolved") {
|
|
719
|
+
delete scope.moduleCache[entry.id];
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return results;
|
|
723
|
+
});
|
|
724
|
+
}
|
|
567
725
|
function getSharedModule(scope, id) {
|
|
568
726
|
const idStr = String(id);
|
|
569
727
|
if (scope.sharedModules[idStr] !== void 0) {
|
|
570
728
|
return scope.sharedModules[idStr];
|
|
571
729
|
}
|
|
572
730
|
for (const [key, value] of Object.entries(scope.sharedModules)) {
|
|
573
|
-
if (typeof value !== "undefined" && idStr !== key && idStr
|
|
731
|
+
if (typeof value !== "undefined" && idStr !== key && matchesSharedModuleKey(idStr, key)) {
|
|
574
732
|
return value;
|
|
575
733
|
}
|
|
576
734
|
}
|
|
577
735
|
return null;
|
|
578
736
|
}
|
|
737
|
+
function matchesSharedModuleKey(id, key) {
|
|
738
|
+
if (id.endsWith(key))
|
|
739
|
+
return true;
|
|
740
|
+
if (!key.includes("/") && !key.endsWith(".js"))
|
|
741
|
+
return false;
|
|
742
|
+
const index = id.lastIndexOf(key);
|
|
743
|
+
if (index < 0)
|
|
744
|
+
return false;
|
|
745
|
+
const afterKey = id.slice(index + key.length);
|
|
746
|
+
return /^\s+(?:\[[^\]]+\]\s*)?(?:\([^)]*\))?$/.test(afterKey);
|
|
747
|
+
}
|
|
579
748
|
|
|
580
|
-
// src/
|
|
581
|
-
|
|
749
|
+
// src/config/webpack/next-client-pages-loader.ts
|
|
750
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
582
751
|
const self = globalThis;
|
|
583
752
|
const ns = getNamespace();
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
753
|
+
ns.pageComponentCache ??= {};
|
|
754
|
+
const cacheKey = `${bundle}:${route}`;
|
|
755
|
+
const remoteRequire = self.__remote_webpack_require__?.[bundle];
|
|
756
|
+
const turbopackScope = remoteRequire?.type === "turbopack" ? getScope(bundle) : void 0;
|
|
757
|
+
const applyBundleCss = () => {
|
|
758
|
+
const elements = ns.cssCache[bundle] ?? [];
|
|
759
|
+
if (styleContainer) {
|
|
760
|
+
for (const el of elements) {
|
|
761
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
for (const el of elements) {
|
|
765
|
+
document.head.appendChild(el);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
const cachedEntry = ns.pageComponentCache[cacheKey];
|
|
770
|
+
if (cachedEntry) {
|
|
771
|
+
applyBundleCss();
|
|
772
|
+
return cachedEntry;
|
|
773
|
+
}
|
|
774
|
+
const nextCssOriginal = document.querySelector(
|
|
775
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
776
|
+
);
|
|
777
|
+
const nextCssOriginalParent = nextCssOriginal?.parentNode ?? null;
|
|
778
|
+
const nextCssOriginalNextSibling = nextCssOriginal?.nextSibling ?? null;
|
|
779
|
+
if (nextCssOriginal) {
|
|
780
|
+
nextCssOriginalParent?.removeChild(nextCssOriginal);
|
|
781
|
+
}
|
|
782
|
+
const nextCss = document.createElement("noscript");
|
|
783
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
784
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
785
|
+
nextCss.setAttribute("data-route", route);
|
|
786
|
+
const nextCssEnd = document.createElement("noscript");
|
|
787
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
788
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
789
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
790
|
+
document.head.appendChild(nextCssEnd);
|
|
791
|
+
document.head.appendChild(nextCss);
|
|
792
|
+
const componentLoaderChunk = (turbopackScope ? findTurbopackPagesLoaderId(turbopackScope, route) : void 0) ?? Object.keys(remoteRequire?.m ?? {}).find(
|
|
793
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
794
|
+
) ?? Object.keys(remoteRequire?.m ?? {}).find(
|
|
795
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
796
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
797
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
798
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
799
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
800
|
+
) ?? ""] ?? -1;
|
|
801
|
+
const appLoaderChunk = (turbopackScope ? findTurbopackPagesLoaderId(turbopackScope, "/_app") : void 0) ?? Object.keys(remoteRequire?.m ?? {}).find(
|
|
802
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
803
|
+
) ?? Object.keys(remoteRequire?.m ?? {}).find(
|
|
804
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
805
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
806
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
807
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
808
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
809
|
+
) ?? ""] ?? -1;
|
|
810
|
+
if (!isLoaderId(componentLoaderChunk) || !isLoaderId(appLoaderChunk)) {
|
|
811
|
+
throw new RemoteComponentsError(
|
|
812
|
+
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
590
813
|
);
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
814
|
+
}
|
|
815
|
+
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
816
|
+
const selfOriginal = self;
|
|
817
|
+
delete selfOriginal.__NEXT_P;
|
|
818
|
+
try {
|
|
819
|
+
loadPagesLoaderModule(bundle, componentLoaderChunk, turbopackScope);
|
|
820
|
+
if (isLoaderId(appLoaderChunk)) {
|
|
821
|
+
loadPagesLoaderModule(bundle, appLoaderChunk, turbopackScope);
|
|
822
|
+
}
|
|
823
|
+
if (self.__NEXT_P) {
|
|
824
|
+
logDebug(
|
|
825
|
+
"ComponentLoader",
|
|
826
|
+
`Next.js Pages loader registry for "${route}" in "${bundle}": ${self.__NEXT_P.map((entry) => entry?.[0] ?? "<empty>").join(", ")}`
|
|
597
827
|
);
|
|
828
|
+
const componentEntry = self.__NEXT_P.find(
|
|
829
|
+
(entry) => entry?.[0] === route
|
|
830
|
+
) ?? self.__NEXT_P[0];
|
|
831
|
+
const appEntry = self.__NEXT_P.find((entry) => entry?.[0] === "/_app") ?? self.__NEXT_P[2];
|
|
832
|
+
const [, componentLoader] = componentEntry ?? [
|
|
833
|
+
void 0,
|
|
834
|
+
() => ({ default: null })
|
|
835
|
+
];
|
|
836
|
+
const [, appLoader] = appEntry ?? [
|
|
837
|
+
void 0,
|
|
838
|
+
() => ({
|
|
839
|
+
default: null
|
|
840
|
+
})
|
|
841
|
+
];
|
|
842
|
+
const { default: Component = null } = componentLoader();
|
|
843
|
+
const { default: App = null } = appLoader();
|
|
844
|
+
const cssCache = ns.cssCache;
|
|
845
|
+
if (!cssCache[bundle]) {
|
|
846
|
+
const cssRE = /\.s?css$/;
|
|
847
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
848
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
849
|
+
});
|
|
850
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
851
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
852
|
+
if (id) {
|
|
853
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
const elements = [];
|
|
857
|
+
let node = nextCss.previousSibling;
|
|
858
|
+
while (node && node !== nextCssEnd) {
|
|
859
|
+
elements.push(node);
|
|
860
|
+
node.remove();
|
|
861
|
+
node = nextCss.previousSibling;
|
|
862
|
+
}
|
|
863
|
+
cssCache[bundle] = elements;
|
|
864
|
+
}
|
|
865
|
+
applyBundleCss();
|
|
866
|
+
const result = { Component, App };
|
|
867
|
+
ns.pageComponentCache[cacheKey] = result;
|
|
868
|
+
return result;
|
|
598
869
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
self.__webpack_get_script_filename__ = () => null;
|
|
611
|
-
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || ns.dispatcherRuntime !== "turbopack";
|
|
612
|
-
if (willCreateDispatchers) {
|
|
613
|
-
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
614
|
-
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
615
|
-
self.__original_webpack_require__ = self.__webpack_require__;
|
|
870
|
+
logDebug(
|
|
871
|
+
"ComponentLoader",
|
|
872
|
+
`Next.js Pages loaders for route "${route}" in "${bundle}" did not populate __NEXT_P`
|
|
873
|
+
);
|
|
874
|
+
return { Component: null, App: null };
|
|
875
|
+
} finally {
|
|
876
|
+
if (typeof __NEXT_P_ORIGINAL === "undefined") {
|
|
877
|
+
delete self.__NEXT_P;
|
|
878
|
+
} else {
|
|
879
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
616
880
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
self.__webpack_require_type__ = runtime;
|
|
621
|
-
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
622
|
-
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
623
|
-
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
881
|
+
if (nextCssOriginal && nextCssOriginalParent) {
|
|
882
|
+
const restoreBefore = nextCssOriginalNextSibling?.parentNode === nextCssOriginalParent ? nextCssOriginalNextSibling : null;
|
|
883
|
+
nextCssOriginalParent.insertBefore(nextCssOriginal, restoreBefore);
|
|
624
884
|
}
|
|
885
|
+
nextCss.remove();
|
|
886
|
+
nextCssEnd.remove();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function isLoaderId(id) {
|
|
890
|
+
return typeof id === "string" && id.length > 0 || typeof id === "number" && id !== -1;
|
|
891
|
+
}
|
|
892
|
+
function loadPagesLoaderModule(bundle, id, turbopackScope) {
|
|
893
|
+
const self = globalThis;
|
|
894
|
+
if (turbopackScope) {
|
|
895
|
+
delete turbopackScope.moduleCache[String(id)];
|
|
896
|
+
requireModule(turbopackScope, id);
|
|
897
|
+
return;
|
|
625
898
|
}
|
|
626
|
-
|
|
627
|
-
|
|
899
|
+
const remoteRequire = self.__remote_webpack_require__?.[bundle];
|
|
900
|
+
if (remoteRequire?.c) {
|
|
901
|
+
delete remoteRequire.c[id];
|
|
628
902
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
903
|
+
remoteRequire?.(id);
|
|
904
|
+
}
|
|
905
|
+
function findTurbopackPagesLoaderId(scope, route) {
|
|
906
|
+
const modules = getTurbopackModules(scope);
|
|
907
|
+
if (!modules)
|
|
908
|
+
return void 0;
|
|
909
|
+
const routeLiteral = JSON.stringify(route);
|
|
910
|
+
const singleQuotedRouteLiteral = `'${route.replaceAll("'", "\\'")}'`;
|
|
911
|
+
const flat = modules.flat();
|
|
912
|
+
for (let index = 0; index < flat.length; index++) {
|
|
913
|
+
const entry = flat[index];
|
|
914
|
+
if (typeof entry === "function") {
|
|
915
|
+
const code = entry.toString();
|
|
916
|
+
if (code.includes("__NEXT_P") && (code.includes(routeLiteral) || code.includes(singleQuotedRouteLiteral))) {
|
|
917
|
+
const id = findPreviousModuleId(flat, index);
|
|
918
|
+
if (isLoaderId(id) && isTurbopackPagesLoaderId(id)) {
|
|
919
|
+
logDebug(
|
|
920
|
+
"SharedModules",
|
|
921
|
+
`Resolved Turbopack Pages loader for route "${route}" in "${scope.scopedName}" as "${id}"`
|
|
922
|
+
);
|
|
923
|
+
return id;
|
|
634
924
|
}
|
|
635
|
-
return Promise.resolve(void 0);
|
|
636
|
-
})
|
|
637
|
-
);
|
|
638
|
-
for (const result of results) {
|
|
639
|
-
if (result.status === "rejected") {
|
|
640
|
-
logWarn(
|
|
641
|
-
"WebpackRuntime",
|
|
642
|
-
`Initial chunk load failed: ${String(result.reason)}`
|
|
643
|
-
);
|
|
644
925
|
}
|
|
926
|
+
continue;
|
|
645
927
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
const remoteRuntime = self.__remote_webpack_require__?.[bundleName] ? self.__remote_webpack_require__[bundleName]?.type || "webpack" : runtime;
|
|
658
|
-
logDebug(
|
|
659
|
-
"ModuleDispatcher",
|
|
660
|
-
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
661
|
-
);
|
|
662
|
-
try {
|
|
663
|
-
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
664
|
-
const scope2 = getScope(bundle);
|
|
665
|
-
if (scope2?.webpackRequire)
|
|
666
|
-
return scope2.webpackRequire(moduleId);
|
|
667
|
-
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
668
|
-
}
|
|
669
|
-
const scope = getScope(bundleName);
|
|
670
|
-
if (scope) {
|
|
671
|
-
return requireModule(scope, moduleId ?? id, id);
|
|
672
|
-
}
|
|
673
|
-
throw new Error(
|
|
674
|
-
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
675
|
-
);
|
|
676
|
-
} catch (requireError) {
|
|
677
|
-
logWarn(
|
|
678
|
-
"ModuleDispatcher",
|
|
679
|
-
`Module require failed: ${String(requireError)}`
|
|
680
|
-
);
|
|
681
|
-
if (typeof self.__original_webpack_require__ !== "function") {
|
|
682
|
-
throw new RemoteComponentsError(
|
|
683
|
-
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
684
|
-
{
|
|
685
|
-
cause: requireError instanceof Error ? requireError : void 0
|
|
686
|
-
}
|
|
687
|
-
);
|
|
688
|
-
}
|
|
689
|
-
try {
|
|
928
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
929
|
+
continue;
|
|
930
|
+
if (typeof Element !== "undefined" && entry instanceof Element)
|
|
931
|
+
continue;
|
|
932
|
+
for (const [id, moduleInit] of Object.entries(
|
|
933
|
+
entry
|
|
934
|
+
)) {
|
|
935
|
+
if (typeof moduleInit !== "function")
|
|
936
|
+
continue;
|
|
937
|
+
const code = moduleInit.toString();
|
|
938
|
+
if (code.includes("__NEXT_P") && (code.includes(routeLiteral) || code.includes(singleQuotedRouteLiteral)) && isTurbopackPagesLoaderId(id)) {
|
|
690
939
|
logDebug(
|
|
691
|
-
"
|
|
692
|
-
|
|
693
|
-
);
|
|
694
|
-
return self.__original_webpack_require__(id);
|
|
695
|
-
} catch (originalError) {
|
|
696
|
-
throw new RemoteComponentsError(
|
|
697
|
-
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
698
|
-
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
940
|
+
"SharedModules",
|
|
941
|
+
`Resolved Turbopack Pages loader for route "${route}" in "${scope.scopedName}" as "${id}"`
|
|
699
942
|
);
|
|
943
|
+
return id;
|
|
700
944
|
}
|
|
701
945
|
}
|
|
702
|
-
}
|
|
946
|
+
}
|
|
947
|
+
return void 0;
|
|
948
|
+
}
|
|
949
|
+
function isTurbopackPagesLoaderId(id) {
|
|
950
|
+
if (typeof id === "number")
|
|
951
|
+
return true;
|
|
952
|
+
return id.includes("[next]/entry/page-loader.ts") || id.includes("/next/dist/client/page-loader.js");
|
|
953
|
+
}
|
|
954
|
+
function findPreviousModuleId(entries, factoryIndex) {
|
|
955
|
+
for (let index = factoryIndex - 1; index >= 0; index--) {
|
|
956
|
+
const entry = entries[index];
|
|
957
|
+
if (isLoaderId(entry))
|
|
958
|
+
return entry;
|
|
959
|
+
if (typeof entry === "function")
|
|
960
|
+
return void 0;
|
|
961
|
+
}
|
|
962
|
+
return void 0;
|
|
703
963
|
}
|
|
704
964
|
|
|
705
965
|
export {
|
|
966
|
+
applySharedModules,
|
|
967
|
+
loadChunkWithScope,
|
|
968
|
+
createChunkDispatcher,
|
|
706
969
|
initializeSharedModules,
|
|
707
|
-
|
|
970
|
+
requireModule,
|
|
971
|
+
nextClientPagesLoader
|
|
708
972
|
};
|
|
709
|
-
//# sourceMappingURL=chunk-
|
|
973
|
+
//# sourceMappingURL=chunk-4NW46ZVD.js.map
|