remote-components 0.4.3 → 0.4.5
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-C5EYU7EQ.cjs → chunk-4MLJE6UP.cjs} +3 -3
- package/dist/{chunk-SECN7UAL.cjs → chunk-7OD5S534.cjs} +18 -18
- package/dist/{chunk-7XXO2DLF.cjs → chunk-I7VKDF3E.cjs} +115 -77
- package/dist/chunk-I7VKDF3E.cjs.map +1 -0
- package/dist/{chunk-55TEMSB5.js → chunk-JZRA6DPE.js} +116 -78
- package/dist/chunk-JZRA6DPE.js.map +1 -0
- package/dist/{chunk-HYVNEUIK.js → chunk-MJ2KYXGR.js} +3 -3
- package/dist/{chunk-KV5J7PNM.js → chunk-NZM2SI6U.js} +3 -3
- package/dist/{chunk-DGZVFKSQ.js → chunk-O4A6CJGI.js} +19 -11
- package/dist/chunk-O4A6CJGI.js.map +1 -0
- package/dist/{chunk-2W7JBTID.cjs → chunk-PNASFKWA.cjs} +39 -31
- package/dist/chunk-PNASFKWA.cjs.map +1 -0
- package/dist/{chunk-4NW46ZVD.js → chunk-PT3R275L.js} +93 -38
- package/dist/chunk-PT3R275L.js.map +1 -0
- package/dist/{chunk-4AH3KXDW.cjs → chunk-TWO3XB6H.cjs} +19 -19
- package/dist/{chunk-HMB3SIVJ.cjs → chunk-W5FSHVWU.cjs} +107 -52
- package/dist/chunk-W5FSHVWU.cjs.map +1 -0
- package/dist/{chunk-HL6BL5HY.js → chunk-WGSS7TJP.js} +2 -2
- package/dist/config/nextjs.cjs +98 -30
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.d.ts +14 -1
- package/dist/config/nextjs.js +89 -21
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +19 -19
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +7 -7
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +11 -11
- package/dist/host/nextjs/app/client-only.js +6 -6
- package/dist/host/nextjs/pages.cjs +32 -9
- package/dist/host/nextjs/pages.cjs.map +1 -1
- package/dist/host/nextjs/pages.js +39 -9
- package/dist/host/nextjs/pages.js.map +1 -1
- package/dist/host/react.cjs +7 -7
- package/dist/host/react.js +6 -6
- package/dist/internal/host/nextjs/app-client.d.ts +3 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +17 -2
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.d.ts +5 -1
- package/dist/internal/host/nextjs/dom-flight.js +18 -2
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +4 -2
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.d.ts +2 -0
- package/dist/internal/host/server/fetch-remote-component.js +4 -2
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/server/types.cjs.map +1 -1
- package/dist/internal/host/server/types.d.ts +4 -1
- package/dist/internal/host/shared/pipeline.cjs +7 -8
- package/dist/internal/host/shared/pipeline.cjs.map +1 -1
- package/dist/internal/host/shared/pipeline.d.ts +5 -3
- package/dist/internal/host/shared/pipeline.js +9 -8
- package/dist/internal/host/shared/pipeline.js.map +1 -1
- package/dist/internal/host/shared/shared-broker.cjs +51 -10
- package/dist/internal/host/shared/shared-broker.cjs.map +1 -1
- package/dist/internal/host/shared/shared-broker.d.ts +19 -3
- package/dist/internal/host/shared/shared-broker.js +48 -10
- package/dist/internal/host/shared/shared-broker.js.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.d.ts +2 -2
- package/dist/internal/host/shared/shared-module-resolver.js.map +1 -1
- package/dist/internal/remote/nextjs/app-client.cjs +28 -19
- package/dist/internal/remote/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/remote/nextjs/app-client.d.ts +6 -1
- package/dist/internal/remote/nextjs/app-client.js +20 -11
- package/dist/internal/remote/nextjs/app-client.js.map +1 -1
- package/dist/internal/runtime/html/html-spec.cjs +6 -0
- package/dist/internal/runtime/html/html-spec.cjs.map +1 -1
- package/dist/internal/runtime/html/html-spec.d.ts +3 -1
- package/dist/internal/runtime/html/html-spec.js +4 -0
- package/dist/internal/runtime/html/html-spec.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +7 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.d.ts +5 -3
- package/dist/internal/runtime/html/parse-remote-html.js +9 -1
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.d.ts +4 -2
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +39 -23
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js +39 -23
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs +15 -5
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.d.ts +10 -2
- package/dist/internal/runtime/turbopack/patterns.js +13 -4
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.cjs +39 -10
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +2 -2
- package/dist/internal/runtime/turbopack/shared-modules.js +43 -11
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/remote/defaults/app.cjs +4 -2
- package/dist/remote/defaults/app.cjs.map +1 -1
- package/dist/remote/defaults/app.d.ts +3 -1
- package/dist/remote/defaults/app.js +3 -2
- package/dist/remote/defaults/app.js.map +1 -1
- package/dist/remote/defaults/pages.cjs +4 -2
- package/dist/remote/defaults/pages.cjs.map +1 -1
- package/dist/remote/defaults/pages.d.ts +3 -1
- package/dist/remote/defaults/pages.js +3 -2
- package/dist/remote/defaults/pages.js.map +1 -1
- package/dist/remote/defaults/shared.cjs +5 -2
- package/dist/remote/defaults/shared.cjs.map +1 -1
- package/dist/remote/defaults/shared.d.ts +5 -1
- package/dist/remote/defaults/shared.js +3 -1
- package/dist/remote/defaults/shared.js.map +1 -1
- package/dist/remote/nextjs/pages.cjs +4 -1
- package/dist/remote/nextjs/pages.cjs.map +1 -1
- package/dist/remote/nextjs/pages.d.ts +5 -0
- package/dist/remote/nextjs/pages.js +8 -2
- package/dist/remote/nextjs/pages.js.map +1 -1
- package/dist/{server-handoff-8c89b856.d.ts → server-handoff-9e905049.d.ts} +2 -1
- package/dist/{turbopack-7F757Z7V.js → turbopack-55EJDSUT.js} +4 -4
- package/dist/turbopack-55EJDSUT.js.map +1 -0
- package/dist/{turbopack-DULMVTWV.cjs → turbopack-Q6KJAEOX.cjs} +11 -11
- package/dist/turbopack-Q6KJAEOX.cjs.map +1 -0
- package/dist/{webpack-WGVTKJ3W.js → webpack-AQ34DAJZ.js} +4 -4
- package/dist/webpack-AQ34DAJZ.js.map +1 -0
- package/dist/{webpack-6LXCB7WA.cjs → webpack-FWUNUWLF.cjs} +11 -11
- package/dist/webpack-FWUNUWLF.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-2W7JBTID.cjs.map +0 -1
- package/dist/chunk-4NW46ZVD.js.map +0 -1
- package/dist/chunk-55TEMSB5.js.map +0 -1
- package/dist/chunk-7XXO2DLF.cjs.map +0 -1
- package/dist/chunk-DGZVFKSQ.js.map +0 -1
- package/dist/chunk-HMB3SIVJ.cjs.map +0 -1
- package/dist/turbopack-7F757Z7V.js.map +0 -1
- package/dist/turbopack-DULMVTWV.cjs.map +0 -1
- package/dist/webpack-6LXCB7WA.cjs.map +0 -1
- package/dist/webpack-WGVTKJ3W.js.map +0 -1
- /package/dist/{chunk-C5EYU7EQ.cjs.map → chunk-4MLJE6UP.cjs.map} +0 -0
- /package/dist/{chunk-SECN7UAL.cjs.map → chunk-7OD5S534.cjs.map} +0 -0
- /package/dist/{chunk-HYVNEUIK.js.map → chunk-MJ2KYXGR.js.map} +0 -0
- /package/dist/{chunk-KV5J7PNM.js.map → chunk-NZM2SI6U.js.map} +0 -0
- /package/dist/{chunk-4AH3KXDW.cjs.map → chunk-TWO3XB6H.cjs.map} +0 -0
- /package/dist/{chunk-HL6BL5HY.js.map → chunk-WGSS7TJP.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkI7VKDF3Ecjs = require('./chunk-I7VKDF3E.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
17
17
|
return new Promise((resolve, reject) => {
|
|
18
18
|
const newSrc = new URL(
|
|
19
19
|
// remove the remote component bundle name identifier from the script src
|
|
20
|
-
script.src.replace(
|
|
20
|
+
script.src.replace(_chunkI7VKDF3Ecjs.NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
21
21
|
location.origin
|
|
22
22
|
).href;
|
|
23
23
|
const rawResolved = _nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _ => _(newSrc)]), () => ( newSrc));
|
|
@@ -55,4 +55,4 @@ async function loadScripts(scripts, resolveClientUrl) {
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
exports.loadScripts = loadScripts;
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-4MLJE6UP.cjs.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkW5FSHVWUcjs = require('./chunk-W5FSHVWU.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ var _chunkHMB3SIVJcjs = require('./chunk-HMB3SIVJ.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkI7VKDF3Ecjs = require('./chunk-I7VKDF3E.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
var _chunkZ2SLBFQLcjs = require('./chunk-Z2SLBFQL.cjs');
|
|
@@ -25,25 +25,25 @@ async function setupRemoteScope(runtime, scripts = [], url = new URL(location.hr
|
|
|
25
25
|
const self = globalThis;
|
|
26
26
|
const ns = _chunkZ2SLBFQLcjs.getNamespace.call(void 0, );
|
|
27
27
|
const bundleName = _nullishCoalesce(bundle, () => ( "default"));
|
|
28
|
-
const existingScope =
|
|
28
|
+
const existingScope = _chunkI7VKDF3Ecjs.getScope.call(void 0, bundleName);
|
|
29
29
|
if (existingScope && existingScope.url.origin === url.origin) {
|
|
30
30
|
_chunkBBXVML3Dcjs.logDebug.call(void 0,
|
|
31
31
|
"WebpackRuntime",
|
|
32
32
|
`Reusing scope "${existingScope.scopedName}" (turbopackModules=${existingScope.turbopackModules.length})`
|
|
33
33
|
);
|
|
34
34
|
existingScope.resolveClientUrl = resolveClientUrl;
|
|
35
|
-
if (runtime ===
|
|
35
|
+
if (runtime === _chunkI7VKDF3Ecjs.RUNTIME_TURBOPACK) {
|
|
36
36
|
await Promise.allSettled(
|
|
37
37
|
scripts.map(
|
|
38
|
-
(script) => script.src ?
|
|
38
|
+
(script) => script.src ? _chunkW5FSHVWUcjs.loadChunkWithScope.call(void 0, existingScope, script.src) : Promise.resolve(void 0)
|
|
39
39
|
)
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
return existingScope;
|
|
43
43
|
}
|
|
44
|
-
const scope =
|
|
45
|
-
|
|
46
|
-
if (runtime ===
|
|
44
|
+
const scope = _chunkI7VKDF3Ecjs.createScope.call(void 0, bundleName, url, runtime, resolveClientUrl);
|
|
45
|
+
_chunkI7VKDF3Ecjs.registerScope.call(void 0, scope);
|
|
46
|
+
if (runtime === _chunkI7VKDF3Ecjs.RUNTIME_WEBPACK && _optionalChain([self, 'access', _ => _.__remote_webpack_require__, 'optionalAccess', _2 => _2[bundleName]])) {
|
|
47
47
|
scope.webpackRequire = self.__remote_webpack_require__[bundleName];
|
|
48
48
|
}
|
|
49
49
|
ns.bundleUrls[bundleName] = url;
|
|
@@ -57,12 +57,12 @@ async function setupRemoteScope(runtime, scripts = [], url = new URL(location.hr
|
|
|
57
57
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
58
58
|
self.__original_webpack_require__ = self.__webpack_require__;
|
|
59
59
|
}
|
|
60
|
-
self.__webpack_chunk_load__ =
|
|
60
|
+
self.__webpack_chunk_load__ = _chunkW5FSHVWUcjs.createChunkDispatcher.call(void 0, );
|
|
61
61
|
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
62
62
|
ns.dispatcherRuntime = runtime;
|
|
63
63
|
self.__webpack_require_type__ = runtime;
|
|
64
64
|
}
|
|
65
|
-
if (runtime ===
|
|
65
|
+
if (runtime === _chunkI7VKDF3Ecjs.RUNTIME_TURBOPACK && typeof self.__webpack_require__ === "function") {
|
|
66
66
|
self.__remote_webpack_require__ ??= {};
|
|
67
67
|
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
68
68
|
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
@@ -70,11 +70,11 @@ async function setupRemoteScope(runtime, scripts = [], url = new URL(location.hr
|
|
|
70
70
|
if (_optionalChain([self, 'access', _3 => _3.__remote_webpack_require__, 'optionalAccess', _4 => _4[bundleName]]) && scope.scopedName !== bundleName) {
|
|
71
71
|
self.__remote_webpack_require__[scope.scopedName] = self.__remote_webpack_require__[bundleName];
|
|
72
72
|
}
|
|
73
|
-
if (runtime ===
|
|
73
|
+
if (runtime === _chunkI7VKDF3Ecjs.RUNTIME_TURBOPACK) {
|
|
74
74
|
const results = await Promise.allSettled(
|
|
75
75
|
scripts.map((script) => {
|
|
76
76
|
if (script.src) {
|
|
77
|
-
return
|
|
77
|
+
return _chunkW5FSHVWUcjs.loadChunkWithScope.call(void 0, scope, script.src);
|
|
78
78
|
}
|
|
79
79
|
return Promise.resolve(void 0);
|
|
80
80
|
})
|
|
@@ -93,7 +93,7 @@ async function setupRemoteScope(runtime, scripts = [], url = new URL(location.hr
|
|
|
93
93
|
function createModuleDispatcher(runtime) {
|
|
94
94
|
return (id) => {
|
|
95
95
|
const self = globalThis;
|
|
96
|
-
const { bundle, id: moduleId } = _nullishCoalesce(_optionalChain([id, 'access', _5 => _5.match, 'call', _6 => _6(
|
|
96
|
+
const { bundle, id: moduleId } = _nullishCoalesce(_optionalChain([id, 'access', _5 => _5.match, 'call', _6 => _6(_chunkI7VKDF3Ecjs.REMOTE_COMPONENT_REGEX), 'optionalAccess', _7 => _7.groups]), () => ( {
|
|
97
97
|
bundle: "default",
|
|
98
98
|
id
|
|
99
99
|
}));
|
|
@@ -104,15 +104,15 @@ function createModuleDispatcher(runtime) {
|
|
|
104
104
|
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
105
105
|
);
|
|
106
106
|
try {
|
|
107
|
-
if (remoteRuntime ===
|
|
108
|
-
const scope2 =
|
|
107
|
+
if (remoteRuntime === _chunkI7VKDF3Ecjs.RUNTIME_WEBPACK && bundle && moduleId) {
|
|
108
|
+
const scope2 = _chunkI7VKDF3Ecjs.getScope.call(void 0, bundle);
|
|
109
109
|
if (_optionalChain([scope2, 'optionalAccess', _13 => _13.webpackRequire]))
|
|
110
110
|
return scope2.webpackRequire(moduleId);
|
|
111
111
|
return _optionalChain([self, 'access', _14 => _14.__remote_webpack_require__, 'optionalAccess', _15 => _15[bundle], 'optionalCall', _16 => _16(moduleId)]);
|
|
112
112
|
}
|
|
113
|
-
const scope =
|
|
113
|
+
const scope = _chunkI7VKDF3Ecjs.getScope.call(void 0, bundleName);
|
|
114
114
|
if (scope) {
|
|
115
|
-
return
|
|
115
|
+
return _chunkW5FSHVWUcjs.requireModule.call(void 0, scope, _nullishCoalesce(moduleId, () => ( id)), id);
|
|
116
116
|
}
|
|
117
117
|
throw new Error(
|
|
118
118
|
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
@@ -149,4 +149,4 @@ function createModuleDispatcher(runtime) {
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
exports.setupRemoteScope = setupRemoteScope;
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
152
|
+
//# sourceMappingURL=chunk-7OD5S534.cjs.map
|
|
@@ -10,6 +10,116 @@ var _chunk5KTAEO52cjs = require('./chunk-5KTAEO52.cjs');
|
|
|
10
10
|
|
|
11
11
|
var _chunkBBXVML3Dcjs = require('./chunk-BBXVML3D.cjs');
|
|
12
12
|
|
|
13
|
+
// src/host/shared/shared-broker.ts
|
|
14
|
+
var SHARED_MODULE_MANIFEST_PROTOCOL = "remote-components.shared.v1";
|
|
15
|
+
function isSharedModuleManifest(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && "protocol" in value && value.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && "requirements" in value && Array.isArray(value.requirements);
|
|
17
|
+
}
|
|
18
|
+
function getMissingSharedModulesMessage(remoteShared) {
|
|
19
|
+
if (isSharedModuleManifest(remoteShared))
|
|
20
|
+
return void 0;
|
|
21
|
+
const message = remoteShared.__remote_components_missing_shared__;
|
|
22
|
+
return typeof message === "string" ? message : void 0;
|
|
23
|
+
}
|
|
24
|
+
function createSharedModulePlan({
|
|
25
|
+
bundle,
|
|
26
|
+
hostShared,
|
|
27
|
+
remoteShared,
|
|
28
|
+
scope = `remote:${bundle}`,
|
|
29
|
+
callerTag = "SharedBroker"
|
|
30
|
+
}) {
|
|
31
|
+
const protocol = isSharedModuleManifest(remoteShared) ? remoteShared.protocol : "legacy";
|
|
32
|
+
const requirements = isSharedModuleManifest(remoteShared) ? remoteShared.requirements : (
|
|
33
|
+
// @legacy(remote-components<=0.4.x): normalize the historical shared
|
|
34
|
+
// map until hosts and remotes on 0.4.x are no longer supported.
|
|
35
|
+
Object.entries(remoteShared).map(([id, specifier]) => ({
|
|
36
|
+
id,
|
|
37
|
+
specifier: String(specifier),
|
|
38
|
+
required: true,
|
|
39
|
+
singleton: true
|
|
40
|
+
}))
|
|
41
|
+
);
|
|
42
|
+
const entries = requirements.map((requirement) => {
|
|
43
|
+
const specifier = String(requirement.specifier);
|
|
44
|
+
const provider = hostShared[specifier];
|
|
45
|
+
const entry = {
|
|
46
|
+
id: String(requirement.id),
|
|
47
|
+
specifier,
|
|
48
|
+
required: _nullishCoalesce(requirement.required, () => ( true)),
|
|
49
|
+
singleton: _nullishCoalesce(requirement.singleton, () => ( true)),
|
|
50
|
+
scope: _nullishCoalesce(requirement.scope, () => ( scope)),
|
|
51
|
+
provider,
|
|
52
|
+
status: typeof provider === "undefined" ? "missing" : "resolved"
|
|
53
|
+
};
|
|
54
|
+
if (entry.status === "missing") {
|
|
55
|
+
_chunkBBXVML3Dcjs.logDebug.call(void 0,
|
|
56
|
+
callerTag,
|
|
57
|
+
`Remote "${bundle}" requests "${specifier}" for "${entry.id}" but the host does not provide it`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return entry;
|
|
61
|
+
});
|
|
62
|
+
_chunkBBXVML3Dcjs.logDebug.call(void 0,
|
|
63
|
+
callerTag,
|
|
64
|
+
`Share plan (${protocol}) for "${bundle}": ${entries.map((entry) => `${entry.id}=>${entry.specifier}:${entry.status}`).join(", ")}`
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
protocol,
|
|
68
|
+
bundle,
|
|
69
|
+
entries
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function missingRequiredSharedModuleMessage(plan, entry) {
|
|
73
|
+
return `Remote Component "${plan.bundle}" requires shared module "${entry.specifier}", but the host does not provide it. Add it to the host shared modules through \`withRemoteComponentsConfig({ shared: [...] })\` or the \`shared\` prop. This diagnostic runs when both host and remote support the shared-module manifest in remote-components >=0.5.0. The remote may load its bundled copy during the compatibility window; this will become a load error after remote-components <=0.4.x support is removed.`;
|
|
74
|
+
}
|
|
75
|
+
function logMissingRequiredSharedModule(callerTag, plan, entry) {
|
|
76
|
+
_chunkBBXVML3Dcjs.logError.call(void 0, callerTag, missingRequiredSharedModuleMessage(plan, entry));
|
|
77
|
+
}
|
|
78
|
+
async function resolveSharedModulePlan(plan) {
|
|
79
|
+
const resolved = {};
|
|
80
|
+
await Promise.all(
|
|
81
|
+
plan.entries.map(async (entry) => {
|
|
82
|
+
if (entry.status !== "resolved") {
|
|
83
|
+
if (plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && entry.required) {
|
|
84
|
+
logMissingRequiredSharedModule("SharedBroker", plan, entry);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const value = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
89
|
+
resolved[entry.id] = value;
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
return resolved;
|
|
93
|
+
}
|
|
94
|
+
async function installSharedModulePlan({
|
|
95
|
+
plan,
|
|
96
|
+
target,
|
|
97
|
+
callerTag = "SharedBroker",
|
|
98
|
+
onMissing
|
|
99
|
+
}) {
|
|
100
|
+
return Promise.all(
|
|
101
|
+
plan.entries.map(async (entry) => {
|
|
102
|
+
if (entry.status !== "resolved") {
|
|
103
|
+
if (plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && entry.required) {
|
|
104
|
+
logMissingRequiredSharedModule(callerTag, plan, entry);
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
if (onMissing) {
|
|
108
|
+
onMissing(entry);
|
|
109
|
+
} else {
|
|
110
|
+
_chunkBBXVML3Dcjs.logError.call(void 0,
|
|
111
|
+
callerTag,
|
|
112
|
+
`Shared module "${entry.specifier}" not found for "${plan.bundle}".`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
target[entry.id] = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
118
|
+
return void 0;
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
13
123
|
// src/utils/index.ts
|
|
14
124
|
function escapeString(str) {
|
|
15
125
|
return str.replace(/[^a-z0-9]/g, "_");
|
|
@@ -279,81 +389,6 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
279
389
|
return polyfill;
|
|
280
390
|
}
|
|
281
391
|
|
|
282
|
-
// src/host/shared/shared-broker.ts
|
|
283
|
-
function createSharedModulePlan({
|
|
284
|
-
bundle,
|
|
285
|
-
hostShared,
|
|
286
|
-
remoteShared,
|
|
287
|
-
scope = `remote:${bundle}`,
|
|
288
|
-
callerTag = "SharedBroker"
|
|
289
|
-
}) {
|
|
290
|
-
const entries = Object.entries(remoteShared).map(([id, rawSpecifier]) => {
|
|
291
|
-
const specifier = String(rawSpecifier);
|
|
292
|
-
const provider = hostShared[specifier];
|
|
293
|
-
const entry = {
|
|
294
|
-
id,
|
|
295
|
-
specifier,
|
|
296
|
-
required: true,
|
|
297
|
-
singleton: true,
|
|
298
|
-
scope,
|
|
299
|
-
provider,
|
|
300
|
-
status: typeof provider === "undefined" ? "missing" : "resolved"
|
|
301
|
-
};
|
|
302
|
-
if (entry.status === "missing") {
|
|
303
|
-
_chunkBBXVML3Dcjs.logDebug.call(void 0,
|
|
304
|
-
callerTag,
|
|
305
|
-
`Remote "${bundle}" requests "${specifier}" for "${id}" but the host does not provide it`
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
return entry;
|
|
309
|
-
});
|
|
310
|
-
_chunkBBXVML3Dcjs.logDebug.call(void 0,
|
|
311
|
-
callerTag,
|
|
312
|
-
`Share plan for "${bundle}": ${entries.map((entry) => `${entry.id}=>${entry.specifier}:${entry.status}`).join(", ")}`
|
|
313
|
-
);
|
|
314
|
-
return {
|
|
315
|
-
protocol: "v0",
|
|
316
|
-
bundle,
|
|
317
|
-
entries
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
async function resolveSharedModulePlan(plan) {
|
|
321
|
-
const resolved = {};
|
|
322
|
-
await Promise.all(
|
|
323
|
-
plan.entries.map(async (entry) => {
|
|
324
|
-
if (entry.status !== "resolved")
|
|
325
|
-
return;
|
|
326
|
-
const value = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
327
|
-
resolved[entry.id] = value;
|
|
328
|
-
})
|
|
329
|
-
);
|
|
330
|
-
return resolved;
|
|
331
|
-
}
|
|
332
|
-
async function installSharedModulePlan({
|
|
333
|
-
plan,
|
|
334
|
-
target,
|
|
335
|
-
callerTag = "SharedBroker",
|
|
336
|
-
onMissing
|
|
337
|
-
}) {
|
|
338
|
-
return Promise.all(
|
|
339
|
-
plan.entries.map(async (entry) => {
|
|
340
|
-
if (entry.status !== "resolved") {
|
|
341
|
-
if (onMissing) {
|
|
342
|
-
onMissing(entry);
|
|
343
|
-
} else {
|
|
344
|
-
_chunkBBXVML3Dcjs.logError.call(void 0,
|
|
345
|
-
callerTag,
|
|
346
|
-
`Shared module "${entry.specifier}" not found for "${plan.bundle}".`
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
return void 0;
|
|
350
|
-
}
|
|
351
|
-
target[entry.id] = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
352
|
-
return void 0;
|
|
353
|
-
})
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
392
|
// src/host/shared/shared-module-resolver.ts
|
|
358
393
|
var CORE_REACT_SHARED_KEYS = [
|
|
359
394
|
"react",
|
|
@@ -439,5 +474,8 @@ async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModule
|
|
|
439
474
|
|
|
440
475
|
|
|
441
476
|
|
|
442
|
-
|
|
443
|
-
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
exports.SHARED_MODULE_MANIFEST_PROTOCOL = SHARED_MODULE_MANIFEST_PROTOCOL; exports.isSharedModuleManifest = isSharedModuleManifest; exports.getMissingSharedModulesMessage = getMissingSharedModulesMessage; exports.createSharedModulePlan = createSharedModulePlan; exports.installSharedModulePlan = installSharedModulePlan; exports.escapeString = escapeString; exports.attrToProp = attrToProp; exports.DEFAULT_BUNDLE_NAME = DEFAULT_BUNDLE_NAME; exports.DEFAULT_COMPONENT_NAME = DEFAULT_COMPONENT_NAME; exports.DEFAULT_ROUTE = DEFAULT_ROUTE; exports.RUNTIME_WEBPACK = RUNTIME_WEBPACK; exports.RUNTIME_TURBOPACK = RUNTIME_TURBOPACK; exports.RUNTIME_SCRIPT = RUNTIME_SCRIPT; exports.REMOTE_COMPONENT_REGEX = REMOTE_COMPONENT_REGEX; exports.NEXT_BUNDLE_PATH_RE = NEXT_BUNDLE_PATH_RE; exports.collapseDoubleSlashes = collapseDoubleSlashes; exports.createScope = createScope; exports.registerScope = registerScope; exports.getScope = getScope; exports.formatRemoteId = formatRemoteId; exports.parseRemoteId = parseRemoteId; exports.createRemoteImageLoader = createRemoteImageLoader; exports.CORE_REACT_SHARED_KEYS = CORE_REACT_SHARED_KEYS; exports.VENDOR_SHARED = VENDOR_SHARED; exports.buildCoreShared = buildCoreShared; exports.buildHostShared = buildHostShared; exports.buildWebpackResolve = buildWebpackResolve;
|
|
481
|
+
//# sourceMappingURL=chunk-I7VKDF3E.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/shared/shared-broker.ts","../src/utils/index.ts","../src/runtime/constants.ts","../src/runtime/patterns.ts","../src/runtime/turbopack/remote-scope.ts","../src/host/shared/remote-image-loader.ts","../src/host/shared/polyfill.tsx","../src/host/shared/shared-module-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAKO,IAAM,kCACX;AAsCK,SAAS,uBACd,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,MAAM,aAAa,mCACnB,kBAAkB,SAClB,MAAM,QAAQ,MAAM,YAAY;AAEpC;AAEO,SAAS,+BACd,cACoB;AACpB,MAAI,uBAAuB,YAAY;AAAG,WAAO;AACjD,QAAM,UAAU,aAAa;AAC7B,SAAO,OAAO,YAAY,WAAW,UAAU;AACjD;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,UAAU;AAAA,EAClB,YAAY;AACd,GAMqB;AACnB,QAAM,WAAW,uBAAuB,YAAY,IAChD,aAAa,WACb;AACJ,QAAM,eACJ,uBAAuB,YAAY,IAC/B,aAAa;AAAA;AAAA;AAAA,IAGb,OAAO,QAAQ,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,SAAS,OAAO;AAAA,MACrD;AAAA,MACA,WAAW,OAAO,SAAS;AAAA,MAC3B,UAAU;AAAA,MACV,WAAW;AAAA,IACb,EAAE;AAAA;AAER,QAAM,UAAU,aAAa,IAAI,CAAC,gBAAgB;AAChD,UAAM,YAAY,OAAO,YAAY,SAAS;AAC9C,UAAM,WAAW,WAAW,SAAS;AACrC,UAAM,QAAgC;AAAA,MACpC,IAAI,OAAO,YAAY,EAAE;AAAA,MACzB;AAAA,MACA,UAAU,YAAY,YAAY;AAAA,MAClC,WAAW,YAAY,aAAa;A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ourcesContent":["import type { LogLocation } from '#internal/utils/logger';\nimport { logDebug, logError } from '#internal/utils/logger';\n\nexport type SharedModuleFactory = (bundle?: string) => Promise<unknown>;\n\nexport const SHARED_MODULE_MANIFEST_PROTOCOL =\n 'remote-components.shared.v1' as const;\n\nexport type LegacySharedModuleMap = Record<string, string | number>;\n\nexport interface SharedModuleManifestRequirement {\n id: string | number;\n specifier: string;\n required?: boolean;\n singleton?: boolean;\n scope?: string;\n}\n\nexport interface SharedModuleManifest {\n protocol: typeof SHARED_MODULE_MANIFEST_PROTOCOL;\n requirements: SharedModuleManifestRequirement[];\n}\n\nexport type RemoteSharedModules = LegacySharedModuleMap | SharedModuleManifest;\n\nexport interface SharedModuleRequirement {\n id: string;\n specifier: string;\n required: boolean;\n singleton: boolean;\n scope: string;\n}\n\nexport interface SharedModuleResolution extends SharedModuleRequirement {\n provider?: SharedModuleFactory | unknown;\n status: 'resolved' | 'missing';\n}\n\nexport interface SharedModulePlan {\n protocol: 'legacy' | typeof SHARED_MODULE_MANIFEST_PROTOCOL;\n bundle: string;\n entries: SharedModuleResolution[];\n}\n\nexport function isSharedModuleManifest(\n value: unknown,\n): value is SharedModuleManifest {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'protocol' in value &&\n value.protocol === SHARED_MODULE_MANIFEST_PROTOCOL &&\n 'requirements' in value &&\n Array.isArray(value.requirements)\n );\n}\n\nexport function getMissingSharedModulesMessage(\n remoteShared: RemoteSharedModules,\n): string | undefined {\n if (isSharedModuleManifest(remoteShared)) return undefined;\n const message = remoteShared.__remote_components_missing_shared__;\n return typeof message === 'string' ? message : undefined;\n}\n\nexport function createSharedModulePlan({\n bundle,\n hostShared,\n remoteShared,\n scope = `remote:${bundle}`,\n callerTag = 'SharedBroker',\n}: {\n bundle: string;\n hostShared: Record<string, SharedModuleFactory | unknown>;\n remoteShared: RemoteSharedModules;\n scope?: string;\n callerTag?: LogLocation;\n}): SharedModulePlan {\n const protocol = isSharedModuleManifest(remoteShared)\n ? remoteShared.protocol\n : 'legacy';\n const requirements: SharedModuleManifestRequirement[] =\n isSharedModuleManifest(remoteShared)\n ? remoteShared.requirements\n : // @legacy(remote-components<=0.4.x): normalize the historical shared\n // map until hosts and remotes on 0.4.x are no longer supported.\n Object.entries(remoteShared).map(([id, specifier]) => ({\n id,\n specifier: String(specifier),\n required: true,\n singleton: true,\n }));\n\n const entries = requirements.map((requirement) => {\n const specifier = String(requirement.specifier);\n const provider = hostShared[specifier];\n const entry: SharedModuleResolution = {\n id: String(requirement.id),\n specifier,\n required: requirement.required ?? true,\n singleton: requirement.singleton ?? true,\n scope: requirement.scope ?? scope,\n provider,\n status: typeof provider === 'undefined' ? 'missing' : 'resolved',\n };\n\n if (entry.status === 'missing') {\n logDebug(\n callerTag,\n `Remote \"${bundle}\" requests \"${specifier}\" for \"${entry.id}\" but the host does not provide it`,\n );\n }\n\n return entry;\n });\n\n logDebug(\n callerTag,\n `Share plan (${protocol}) for \"${bundle}\": ${entries\n .map((entry) => `${entry.id}=>${entry.specifier}:${entry.status}`)\n .join(', ')}`,\n );\n\n return {\n protocol,\n bundle,\n entries,\n };\n}\n\nfunction missingRequiredSharedModuleMessage(\n plan: SharedModulePlan,\n entry: SharedModuleResolution,\n): string {\n return (\n `Remote Component \"${plan.bundle}\" requires shared module \"${entry.specifier}\", but the host does not provide it. ` +\n 'Add it to the host shared modules through `withRemoteComponentsConfig({ shared: [...] })` or the `shared` prop. ' +\n 'This diagnostic runs when both host and remote support the shared-module manifest in remote-components >=0.5.0. ' +\n 'The remote may load its bundled copy during the compatibility window; this will become a load error after remote-components <=0.4.x support is removed.'\n );\n}\n\nfunction logMissingRequiredSharedModule(\n callerTag: LogLocation,\n plan: SharedModulePlan,\n entry: SharedModuleResolution,\n): void {\n logError(callerTag, missingRequiredSharedModuleMessage(plan, entry));\n}\n\nexport async function resolveSharedModulePlan(\n plan: SharedModulePlan,\n): Promise<Record<string, unknown>> {\n const resolved: Record<string, unknown> = {};\n\n await Promise.all(\n plan.entries.map(async (entry) => {\n if (entry.status !== 'resolved') {\n if (\n plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL &&\n entry.required\n ) {\n logMissingRequiredSharedModule('SharedBroker', plan, entry);\n }\n return;\n }\n const value =\n typeof entry.provider === 'function'\n ? await (entry.provider as SharedModuleFactory)(plan.bundle)\n : entry.provider;\n resolved[entry.id] = value;\n }),\n );\n\n return resolved;\n}\n\nexport async function installSharedModulePlan({\n plan,\n target,\n callerTag = 'SharedBroker',\n onMissing,\n}: {\n plan: SharedModulePlan;\n target: Record<string, unknown>;\n callerTag?: LogLocation;\n onMissing?: (entry: SharedModuleResolution) => void;\n}): Promise<undefined[]> {\n return Promise.all(\n plan.entries.map(async (entry) => {\n if (entry.status !== 'resolved') {\n if (\n plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL &&\n entry.required\n ) {\n logMissingRequiredSharedModule(callerTag, plan, entry);\n return undefined;\n }\n if (onMissing) {\n onMissing(entry);\n } else {\n logError(\n callerTag,\n `Shared module \"${entry.specifier}\" not found for \"${plan.bundle}\".`,\n );\n }\n return undefined;\n }\n\n target[entry.id] =\n typeof entry.provider === 'function'\n ? await (entry.provider as SharedModuleFactory)(plan.bundle)\n : entry.provider;\n return undefined;\n }),\n );\n}\n","export function escapeString(str: string) {\n return str.replace(/[^a-z0-9]/g, '_');\n}\n\n/**\n * Computes the origin-qualified scoped name for a bundle by appending\n * the escaped host (hostname + port). This ensures the server and client\n * always agree on the scoped name — the server's cross-origin detection\n * (based on deployment URL) can differ from the client's (based on\n * `location.origin`), so the name must not depend on that distinction.\n *\n * Used on both the server (to rewrite RSC flight data) and the client\n * (to create and look up RemoteScopes). Both sides must produce the\n * same value for a given remote.\n */\nexport function computeScopedName(\n name: string,\n options: { remoteHost: string },\n): string {\n return `${name}_${escapeString(options.remoteHost.toLowerCase())}`;\n}\n\nexport const attrToProp = {\n fetchpriority: 'fetchPriority',\n crossorigin: 'crossOrigin',\n imagesrcset: 'imageSrcSet',\n imagesizes: 'imageSizes',\n srcset: 'srcSet',\n} as Record<string, string>;\n","import { escapeString } from '#internal/utils';\n\nexport const DEFAULT_BUNDLE_NAME = '__vercel_remote_bundle';\nexport const DEFAULT_COMPONENT_NAME = '__vercel_remote_component';\nexport const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\nexport const RUNTIME_SCRIPT = 'script';\n\nexport function getBundleKey(bundle: string): string {\n return escapeString(bundle);\n}\n\nexport type Runtime =\n | typeof RUNTIME_WEBPACK\n | typeof RUNTIME_TURBOPACK\n | typeof RUNTIME_SCRIPT;\n","export const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\n// Matches Next.js bundle-prefixed paths like /_next/[bundle-name] /static/...\n// Used to strip the bundle identifier before loading scripts via the standard /_next/ path.\nexport const NEXT_BUNDLE_PATH_RE = /\\/_next\\/\\[.+\\](?:%20| )/;\n\n/** Collapse duplicate path separators (`//`) while preserving protocol (`://`). */\nconst DOUBLE_SLASH_RE = /(?<!:)\\/\\//g;\nexport function collapseDoubleSlashes(path: string): string {\n return path.replace(DOUBLE_SLASH_RE, '/');\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { getBundleKey, type Runtime } from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { REMOTE_COMPONENT_REGEX } from '#internal/runtime/patterns';\nimport { computeScopedName } from '#internal/utils';\nimport { logDebug, logWarn } from '#internal/utils/logger';\n\n/**\n * Encapsulates all per-remote state so that two remotes sharing the same\n * bundle name but served from different origins never collide.\n *\n * A scope is created once per `setupRemoteScope` call and threaded\n * directly through internal code paths (chunk loading, module resolution,\n * shared modules). Global dispatchers (`__webpack_require__`,\n * `__webpack_chunk_load__`) only exist for external callers (RSC runtime)\n * and resolve the correct scope via the registry.\n */\nexport interface RemoteScope {\n /** Plain bundle name (e.g. \"remote-component-registry\") */\n name: string;\n /** Origin-qualified key — unique even when two remotes share a name */\n scopedName: string;\n /** Escaped key used as suffix for TURBOPACK_ globals */\n globalKey: string;\n /** Base URL for resolving relative chunk paths */\n url: URL;\n /** Bundler runtime type */\n runtime: Runtime;\n /** Proxy callback for routing chunks through the host */\n resolveClientUrl?: InternalResolveClientUrl;\n /** Per-scope cache of executed Turbopack module exports */\n moduleCache: Record<string, unknown>;\n /** Per-scope shared modules provided by the host (React, etc.) */\n sharedModules: Record<string, unknown>;\n /** Per-scope globalThis substitute passed to module initializers as `g` */\n moduleGlobal: Record<string, unknown>;\n /**\n * Webpack's bundle-scoped require function, populated from\n * `__remote_webpack_require__[bundleName]` for webpack remotes.\n * Undefined for turbopack remotes.\n */\n webpackRequire?: ((id: string | number) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: string;\n };\n /**\n * Flat array of captured turbopack module entries: [scriptEl, id, factory, ...].\n * Populated by the push interceptor in handleTurbopackChunk. This is the\n * primary source of truth for getTurbopackModules — immune to the turbopack\n * runtime replacing the TURBOPACK global (canary builds use a deferred-loading\n * pattern that swaps the array for an immediate-processing dispatcher).\n */\n turbopackModules: unknown[];\n}\n\nfunction getRegistry(): Map<string, RemoteScope> {\n return getNamespace().scopes;\n}\n\nexport function createScope(\n name: string,\n url: URL,\n runtime: Runtime,\n resolveClientUrl?: InternalResolveClientUrl,\n): RemoteScope {\n const scopedName = computeScopedName(name, { remoteHost: url.host });\n const globalKey = getBundleKey(scopedName);\n return {\n name,\n scopedName,\n globalKey,\n url,\n runtime,\n resolveClientUrl,\n moduleCache: {},\n sharedModules: {},\n moduleGlobal: {},\n turbopackModules: [],\n };\n}\n\nexport function registerScope(scope: RemoteScope): void {\n const registry = getRegistry();\n registry.set(scope.scopedName, scope);\n\n // Also register under the plain name so static/HTML hosts (which don't\n // rewrite RSC chunk IDs) can look up scopes by the unrewritten bundle name.\n if (scope.scopedName !== scope.name) {\n const existing = registry.get(scope.name);\n if (existing && existing.scopedName !== scope.scopedName) {\n logWarn(\n 'RemoteScope',\n `Plain name \"${scope.name}\" already registered by scope \"${existing.scopedName}\" — ` +\n `overwriting with \"${scope.scopedName}\". Static hosts will only resolve the latest one.`,\n );\n }\n registry.set(scope.name, scope);\n }\n\n logDebug(\n 'RemoteScope',\n `Registered scope \"${scope.scopedName}\" (${registry.size} total)`,\n );\n}\n\n/**\n * Resolves a scope by name. Accepts either the scoped name (used by Next.js\n * hosts that rewrite RSC data server-side) or the plain bundle name (used by\n * static/HTML hosts where chunks arrive unrewritten).\n */\nexport function getScope(name: string): RemoteScope | undefined {\n return getRegistry().get(name);\n}\n\n/** Formats a `[scopedName] path` string for use in chunk/module IDs. */\nexport function formatRemoteId(scope: RemoteScope, path: string): string {\n return `[${scope.scopedName}] ${path}`;\n}\n\n/**\n * Parses the `[bundle] path` format used in chunk/module IDs.\n * Uses REMOTE_COMPONENT_REGEX (the same pattern used by the module dispatcher\n * and script loader) so the two parsing paths can never diverge.\n */\nexport function parseRemoteId(id: string): {\n bundle: string;\n path: string;\n prefix: string;\n} {\n const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;\n if (groups?.bundle && groups.id) {\n return {\n bundle: groups.bundle,\n path: groups.id,\n prefix: groups.prefix ?? '',\n };\n }\n return { bundle: 'default', path: id, prefix: '' };\n}\n","import { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n","import type { LinkProps } from 'next/link';\nimport {\n REMOTE_NAVIGATE_EVENT,\n type RemoteNavigateDetail,\n} from '#internal/host/shared/navigate-event';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { logWarn } from '#internal/utils/logger';\n\nfunction dispatchRemoteNavigate(detail: RemoteNavigateDetail) {\n window.dispatchEvent(\n new CustomEvent<RemoteNavigateDetail>(REMOTE_NAVIGATE_EVENT, { detail }),\n );\n}\n\n// polyfill Next.js App Router client API (minimal)\n// implementations are minimal and do not cover all use cases\n// developer can override these shared modules from configuration\nexport function sharedPolyfills(\n shared?: Record<string, () => Promise<unknown>>,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const hostShared = getNamespace().hostSharedModules;\n const polyfill = {\n 'next/dist/client/components/navigation':\n hostShared['next/navigation'] ??\n shared?.['next/navigation'] ??\n (() =>\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'push' });\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'replace' });\n },\n back: () => {\n history.back();\n },\n };\n },\n usePathname() {\n return location.pathname;\n },\n useParams() {\n return {};\n },\n useSearchParams() {\n return new URLSearchParams(location.search);\n },\n useSelectedLayoutSegment() {\n return null;\n },\n useSelectedLayoutSegments() {\n return [];\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/link':\n hostShared['next/link'] ??\n shared?.['next/link'] ??\n (() =>\n Promise.resolve({\n default: ({\n scroll: _,\n replace,\n prefetch,\n onNavigate,\n children,\n ...props\n }: React.PropsWithChildren<LinkProps>) => {\n if (prefetch) {\n logWarn(\n 'Polyfill',\n 'Next.js Link prefetch is not supported in remote components',\n );\n }\n return (\n <a\n {...props}\n href={props.href as string}\n onClick={(e) => {\n e.preventDefault();\n let preventDefaulted = false;\n e.preventDefault = () => {\n preventDefaulted = true;\n e.defaultPrevented = true;\n };\n if (typeof props.onClick === 'function') {\n props.onClick(e);\n }\n onNavigate?.(e);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (preventDefaulted) {\n return;\n }\n if (replace) {\n history.replaceState({}, '', props.href as string);\n } else {\n history.pushState({}, '', props.href as string);\n }\n dispatchRemoteNavigate({\n url: props.href as string,\n type: replace ? 'replace' : 'push',\n });\n }}\n suppressHydrationWarning\n >\n {children ?? null}\n </a>\n );\n },\n useLinkStatus() {\n return { pending: false };\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/form':\n hostShared['next/form'] ??\n shared?.['next/form'] ??\n (() =>\n Promise.resolve({\n default: () => {\n // TODO: implement <Form> component for non-Next.js host applications\n throw new Error('Next.js <Form> component not implemented');\n },\n __esModule: true,\n })),\n // Instead of replacing next/image entirely, we let the real Next.js Image\n // component load from the remote bundle and only replace its default loader.\n // This gives us full next/image fidelity (fill, priority, srcSet, blur\n // placeholders, error handling) while routing image optimization through the\n // remote app's /_next/image endpoint.\n 'next/dist/shared/lib/image-loader':\n hostShared['next/dist/shared/lib/image-loader'] ??\n shared?.['next/dist/shared/lib/image-loader'] ??\n ((bundle: string) =>\n Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n })),\n 'next/dist/client/script':\n hostShared['next/script'] ??\n shared?.['next/script'] ??\n (() =>\n Promise.resolve({\n // TODO: implement <Script> component for non-Next.js host applications\n // do not throw an error for now\n default: () => null,\n __esModule: true,\n })),\n 'next/router':\n hostShared['next/router'] ??\n shared?.['next/router'] ??\n (() =>\n // TODO: incomplete implementation\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'push' });\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n dispatchRemoteNavigate({ url: routerUrl, type: 'replace' });\n },\n back: () => {\n history.back();\n },\n };\n },\n __esModule: true,\n })),\n 'next/dist/build/polyfills/process': () =>\n Promise.resolve({\n default: {\n env: {\n NODE_ENV: 'production',\n },\n },\n __esModule: true,\n }),\n } as Record<string, () => Promise<unknown>>;\n\n polyfill['next/navigation'] = polyfill[\n 'next/dist/client/components/navigation'\n ] as () => Promise<unknown>;\n polyfill['next/link'] = polyfill[\n 'next/dist/client/app-dir/link'\n ] as () => Promise<unknown>;\n polyfill['next/form'] = polyfill[\n 'next/dist/client/app-dir/form'\n ] as () => Promise<unknown>;\n polyfill['next/dist/esm/shared/lib/image-loader'] = polyfill[\n 'next/dist/shared/lib/image-loader'\n ] as () => Promise<unknown>;\n polyfill['next/script'] = polyfill[\n 'next/dist/client/script'\n ] as () => Promise<unknown>;\n\n return polyfill;\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { sharedPolyfills } from '#internal/host/shared/polyfill';\nimport {\n createSharedModulePlan,\n type RemoteSharedModules,\n resolveSharedModulePlan,\n type SharedModuleFactory,\n} from '#internal/host/shared/shared-broker';\nimport type { LogLocation } from '#internal/utils/logger';\n\n/**\n * The core React packages that are always shared between host and remote.\n * These correspond to the `/react/*.js` and `/react-dom/*.js` path keys\n * used in the webpack module resolution map.\n */\nexport const CORE_REACT_SHARED_KEYS = [\n 'react',\n 'react/jsx-dev-runtime',\n 'react/jsx-runtime',\n 'react-dom',\n 'react-dom/client',\n] as const;\n\n/**\n * Maps each core React package to its webpack-style path key.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_PATH_MAP: Record<string, string> = {\n react: '/react/index.js',\n 'react/jsx-dev-runtime': '/react/jsx-dev-runtime.js',\n 'react/jsx-runtime': '/react/jsx-runtime.js',\n 'react-dom': '/react-dom/index.js',\n 'react-dom/client': '/react-dom/client.js',\n};\n\n/**\n * The vendorShared record used by the Next.js config to map React packages\n * to their webpack path-key string literals. Derived from CORE_REACT_PATH_MAP\n * but excludes `react-dom/client` to match the existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_PATH_MAP)\n .filter(([key]) => key !== 'react-dom/client')\n .map(([key, path]) => [key, `'${path}'`]),\n);\n\n/**\n * Builds the `coreShared` map for the Turbopack runtime's\n * `initializeSharedModules`. Each entry is an async factory that dynamically\n * imports the corresponding React package. User-provided shared modules\n * override core entries (e.g. to supply a pinned React version).\n */\nexport function buildCoreShared(\n userShared?: Record<string, SharedModuleFactory>,\n): Record<string, SharedModuleFactory> {\n return {\n react: async () => (await import('react')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom/client': async () => (await import('react-dom/client')).default,\n ...userShared,\n };\n}\n\ninterface HostSharedGlobals {\n __remote_component_host_shared_modules__?: Record<\n string,\n SharedModuleFactory\n >;\n __remote_component_shared__?: Record<string, SharedModuleFactory>;\n}\n\n/**\n * Builds the merged host shared modules map with a consistent merge priority:\n * 1. Polyfills (lowest priority — fallback implementations)\n * 2. Global host shared modules (`__remote_component_host_shared_modules__`)\n * 3. User-provided shared modules (highest priority — explicit overrides)\n *\n * Some callers also include `__remote_component_shared__` (the pages router\n * global). Pass `includeRemoteComponentShared: true` to include it at the end.\n */\nexport function buildHostShared(\n userShared?: Record<string, SharedModuleFactory>,\n resolveClientUrl?: InternalResolveClientUrl,\n options?: { includeRemoteComponentShared?: boolean },\n): Record<string, SharedModuleFactory> {\n const self = globalThis as typeof globalThis & HostSharedGlobals;\n const result: Record<string, SharedModuleFactory> = {\n ...sharedPolyfills(userShared, resolveClientUrl),\n ...self.__remote_component_host_shared_modules__,\n ...userShared,\n };\n if (options?.includeRemoteComponentShared) {\n Object.assign(result, self.__remote_component_shared__);\n }\n return result;\n}\n\n/**\n * React module instances keyed by their webpack path, e.g.\n * `{ '/react/index.js': React }`. Passed into `buildWebpackResolve` so it\n * can populate the resolve map without importing React itself.\n */\nexport interface ReactModules {\n '/react/index.js': unknown;\n '/react/jsx-dev-runtime.js': unknown;\n '/react/jsx-runtime.js': unknown;\n '/react-dom/index.js': unknown;\n '/react-dom/client.js': unknown;\n}\n\n/**\n * Builds the `resolve` map passed to `applySharedModules` for the webpack\n * runtime. Combines:\n * - Static React module path keys (`/react/index.js`, etc.)\n * - Remote shared modules matched against host shared, with `(ssr)/` prefix stripped\n *\n * After building the map, resolves any factory functions by awaiting them\n * with the given bundle name.\n */\nexport async function buildWebpackResolve(\n hostShared: Record<string, SharedModuleFactory | unknown>,\n remoteShared: RemoteSharedModules,\n bundle: string,\n reactModules: ReactModules,\n callerTag: LogLocation = 'SharedModuleResolver',\n): Promise<Record<string, unknown>> {\n const sharePlan = createSharedModulePlan({\n bundle,\n hostShared,\n remoteShared,\n callerTag,\n });\n const plannedResolve = await resolveSharedModulePlan(sharePlan);\n const resolve: Record<string, unknown> = {\n ...reactModules,\n ...Object.fromEntries(\n Object.entries(plannedResolve).map(([key, value]) => [\n key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, ''),\n value,\n ]),\n ),\n };\n return resolve;\n}\n"]}
|
|
@@ -10,6 +10,116 @@ import {
|
|
|
10
10
|
logWarn
|
|
11
11
|
} from "./chunk-ULXU6XWH.js";
|
|
12
12
|
|
|
13
|
+
// src/host/shared/shared-broker.ts
|
|
14
|
+
var SHARED_MODULE_MANIFEST_PROTOCOL = "remote-components.shared.v1";
|
|
15
|
+
function isSharedModuleManifest(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && "protocol" in value && value.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && "requirements" in value && Array.isArray(value.requirements);
|
|
17
|
+
}
|
|
18
|
+
function getMissingSharedModulesMessage(remoteShared) {
|
|
19
|
+
if (isSharedModuleManifest(remoteShared))
|
|
20
|
+
return void 0;
|
|
21
|
+
const message = remoteShared.__remote_components_missing_shared__;
|
|
22
|
+
return typeof message === "string" ? message : void 0;
|
|
23
|
+
}
|
|
24
|
+
function createSharedModulePlan({
|
|
25
|
+
bundle,
|
|
26
|
+
hostShared,
|
|
27
|
+
remoteShared,
|
|
28
|
+
scope = `remote:${bundle}`,
|
|
29
|
+
callerTag = "SharedBroker"
|
|
30
|
+
}) {
|
|
31
|
+
const protocol = isSharedModuleManifest(remoteShared) ? remoteShared.protocol : "legacy";
|
|
32
|
+
const requirements = isSharedModuleManifest(remoteShared) ? remoteShared.requirements : (
|
|
33
|
+
// @legacy(remote-components<=0.4.x): normalize the historical shared
|
|
34
|
+
// map until hosts and remotes on 0.4.x are no longer supported.
|
|
35
|
+
Object.entries(remoteShared).map(([id, specifier]) => ({
|
|
36
|
+
id,
|
|
37
|
+
specifier: String(specifier),
|
|
38
|
+
required: true,
|
|
39
|
+
singleton: true
|
|
40
|
+
}))
|
|
41
|
+
);
|
|
42
|
+
const entries = requirements.map((requirement) => {
|
|
43
|
+
const specifier = String(requirement.specifier);
|
|
44
|
+
const provider = hostShared[specifier];
|
|
45
|
+
const entry = {
|
|
46
|
+
id: String(requirement.id),
|
|
47
|
+
specifier,
|
|
48
|
+
required: requirement.required ?? true,
|
|
49
|
+
singleton: requirement.singleton ?? true,
|
|
50
|
+
scope: requirement.scope ?? scope,
|
|
51
|
+
provider,
|
|
52
|
+
status: typeof provider === "undefined" ? "missing" : "resolved"
|
|
53
|
+
};
|
|
54
|
+
if (entry.status === "missing") {
|
|
55
|
+
logDebug(
|
|
56
|
+
callerTag,
|
|
57
|
+
`Remote "${bundle}" requests "${specifier}" for "${entry.id}" but the host does not provide it`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return entry;
|
|
61
|
+
});
|
|
62
|
+
logDebug(
|
|
63
|
+
callerTag,
|
|
64
|
+
`Share plan (${protocol}) for "${bundle}": ${entries.map((entry) => `${entry.id}=>${entry.specifier}:${entry.status}`).join(", ")}`
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
protocol,
|
|
68
|
+
bundle,
|
|
69
|
+
entries
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function missingRequiredSharedModuleMessage(plan, entry) {
|
|
73
|
+
return `Remote Component "${plan.bundle}" requires shared module "${entry.specifier}", but the host does not provide it. Add it to the host shared modules through \`withRemoteComponentsConfig({ shared: [...] })\` or the \`shared\` prop. This diagnostic runs when both host and remote support the shared-module manifest in remote-components >=0.5.0. The remote may load its bundled copy during the compatibility window; this will become a load error after remote-components <=0.4.x support is removed.`;
|
|
74
|
+
}
|
|
75
|
+
function logMissingRequiredSharedModule(callerTag, plan, entry) {
|
|
76
|
+
logError(callerTag, missingRequiredSharedModuleMessage(plan, entry));
|
|
77
|
+
}
|
|
78
|
+
async function resolveSharedModulePlan(plan) {
|
|
79
|
+
const resolved = {};
|
|
80
|
+
await Promise.all(
|
|
81
|
+
plan.entries.map(async (entry) => {
|
|
82
|
+
if (entry.status !== "resolved") {
|
|
83
|
+
if (plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && entry.required) {
|
|
84
|
+
logMissingRequiredSharedModule("SharedBroker", plan, entry);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const value = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
89
|
+
resolved[entry.id] = value;
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
return resolved;
|
|
93
|
+
}
|
|
94
|
+
async function installSharedModulePlan({
|
|
95
|
+
plan,
|
|
96
|
+
target,
|
|
97
|
+
callerTag = "SharedBroker",
|
|
98
|
+
onMissing
|
|
99
|
+
}) {
|
|
100
|
+
return Promise.all(
|
|
101
|
+
plan.entries.map(async (entry) => {
|
|
102
|
+
if (entry.status !== "resolved") {
|
|
103
|
+
if (plan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && entry.required) {
|
|
104
|
+
logMissingRequiredSharedModule(callerTag, plan, entry);
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
if (onMissing) {
|
|
108
|
+
onMissing(entry);
|
|
109
|
+
} else {
|
|
110
|
+
logError(
|
|
111
|
+
callerTag,
|
|
112
|
+
`Shared module "${entry.specifier}" not found for "${plan.bundle}".`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
target[entry.id] = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
118
|
+
return void 0;
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
13
123
|
// src/utils/index.ts
|
|
14
124
|
function escapeString(str) {
|
|
15
125
|
return str.replace(/[^a-z0-9]/g, "_");
|
|
@@ -279,81 +389,6 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
279
389
|
return polyfill;
|
|
280
390
|
}
|
|
281
391
|
|
|
282
|
-
// src/host/shared/shared-broker.ts
|
|
283
|
-
function createSharedModulePlan({
|
|
284
|
-
bundle,
|
|
285
|
-
hostShared,
|
|
286
|
-
remoteShared,
|
|
287
|
-
scope = `remote:${bundle}`,
|
|
288
|
-
callerTag = "SharedBroker"
|
|
289
|
-
}) {
|
|
290
|
-
const entries = Object.entries(remoteShared).map(([id, rawSpecifier]) => {
|
|
291
|
-
const specifier = String(rawSpecifier);
|
|
292
|
-
const provider = hostShared[specifier];
|
|
293
|
-
const entry = {
|
|
294
|
-
id,
|
|
295
|
-
specifier,
|
|
296
|
-
required: true,
|
|
297
|
-
singleton: true,
|
|
298
|
-
scope,
|
|
299
|
-
provider,
|
|
300
|
-
status: typeof provider === "undefined" ? "missing" : "resolved"
|
|
301
|
-
};
|
|
302
|
-
if (entry.status === "missing") {
|
|
303
|
-
logDebug(
|
|
304
|
-
callerTag,
|
|
305
|
-
`Remote "${bundle}" requests "${specifier}" for "${id}" but the host does not provide it`
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
return entry;
|
|
309
|
-
});
|
|
310
|
-
logDebug(
|
|
311
|
-
callerTag,
|
|
312
|
-
`Share plan for "${bundle}": ${entries.map((entry) => `${entry.id}=>${entry.specifier}:${entry.status}`).join(", ")}`
|
|
313
|
-
);
|
|
314
|
-
return {
|
|
315
|
-
protocol: "v0",
|
|
316
|
-
bundle,
|
|
317
|
-
entries
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
async function resolveSharedModulePlan(plan) {
|
|
321
|
-
const resolved = {};
|
|
322
|
-
await Promise.all(
|
|
323
|
-
plan.entries.map(async (entry) => {
|
|
324
|
-
if (entry.status !== "resolved")
|
|
325
|
-
return;
|
|
326
|
-
const value = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
327
|
-
resolved[entry.id] = value;
|
|
328
|
-
})
|
|
329
|
-
);
|
|
330
|
-
return resolved;
|
|
331
|
-
}
|
|
332
|
-
async function installSharedModulePlan({
|
|
333
|
-
plan,
|
|
334
|
-
target,
|
|
335
|
-
callerTag = "SharedBroker",
|
|
336
|
-
onMissing
|
|
337
|
-
}) {
|
|
338
|
-
return Promise.all(
|
|
339
|
-
plan.entries.map(async (entry) => {
|
|
340
|
-
if (entry.status !== "resolved") {
|
|
341
|
-
if (onMissing) {
|
|
342
|
-
onMissing(entry);
|
|
343
|
-
} else {
|
|
344
|
-
logError(
|
|
345
|
-
callerTag,
|
|
346
|
-
`Shared module "${entry.specifier}" not found for "${plan.bundle}".`
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
return void 0;
|
|
350
|
-
}
|
|
351
|
-
target[entry.id] = typeof entry.provider === "function" ? await entry.provider(plan.bundle) : entry.provider;
|
|
352
|
-
return void 0;
|
|
353
|
-
})
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
392
|
// src/host/shared/shared-module-resolver.ts
|
|
358
393
|
var CORE_REACT_SHARED_KEYS = [
|
|
359
394
|
"react",
|
|
@@ -415,6 +450,11 @@ async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModule
|
|
|
415
450
|
}
|
|
416
451
|
|
|
417
452
|
export {
|
|
453
|
+
SHARED_MODULE_MANIFEST_PROTOCOL,
|
|
454
|
+
isSharedModuleManifest,
|
|
455
|
+
getMissingSharedModulesMessage,
|
|
456
|
+
createSharedModulePlan,
|
|
457
|
+
installSharedModulePlan,
|
|
418
458
|
escapeString,
|
|
419
459
|
attrToProp,
|
|
420
460
|
DEFAULT_BUNDLE_NAME,
|
|
@@ -432,12 +472,10 @@ export {
|
|
|
432
472
|
formatRemoteId,
|
|
433
473
|
parseRemoteId,
|
|
434
474
|
createRemoteImageLoader,
|
|
435
|
-
createSharedModulePlan,
|
|
436
|
-
installSharedModulePlan,
|
|
437
475
|
CORE_REACT_SHARED_KEYS,
|
|
438
476
|
VENDOR_SHARED,
|
|
439
477
|
buildCoreShared,
|
|
440
478
|
buildHostShared,
|
|
441
479
|
buildWebpackResolve
|
|
442
480
|
};
|
|
443
|
-
//# sourceMappingURL=chunk-
|
|
481
|
+
//# sourceMappingURL=chunk-JZRA6DPE.js.map
|