remote-components 0.4.7 → 0.4.9
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-ZSIOEMB3.js → chunk-4XWEMPKO.js} +6 -6
- package/dist/chunk-4XWEMPKO.js.map +1 -0
- package/dist/{chunk-W2TLJBAA.cjs → chunk-6NAV4SCF.cjs} +362 -82
- package/dist/chunk-6NAV4SCF.cjs.map +1 -0
- package/dist/{chunk-JZRA6DPE.js → chunk-6NUHDFSH.js} +6 -53
- package/dist/chunk-6NUHDFSH.js.map +1 -0
- package/dist/{chunk-7AUERPZ6.cjs → chunk-EZG36EB4.cjs} +23 -23
- package/dist/{chunk-7AUERPZ6.cjs.map → chunk-EZG36EB4.cjs.map} +1 -1
- package/dist/{chunk-YOFJE3RL.cjs → chunk-J42V6HSP.cjs} +18 -18
- package/dist/{chunk-KTUPOJQQ.js → chunk-JYGC7T6L.js} +313 -33
- package/dist/chunk-JYGC7T6L.js.map +1 -0
- package/dist/{chunk-I7VKDF3E.cjs → chunk-SELGX4Y2.cjs} +4 -51
- package/dist/chunk-SELGX4Y2.cjs.map +1 -0
- package/dist/{chunk-CFZOLSLP.js → chunk-T6E2WPAB.js} +3 -3
- package/dist/{chunk-4MLJE6UP.cjs → chunk-VB64GQX7.cjs} +3 -3
- package/dist/{chunk-VWEKLTPJ.js → chunk-X6SKTJ5N.js} +3 -3
- package/dist/{chunk-4WHSX7WW.cjs → chunk-XPMI4K3U.cjs} +19 -19
- package/dist/{chunk-WGSS7TJP.js → chunk-ZJW3GQTP.js} +2 -2
- package/dist/config/nextjs.cjs +5 -5
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +1 -1
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +19 -19
- package/dist/host/html.js +7 -7
- package/dist/host/nextjs/app/client-only.cjs +11 -11
- package/dist/host/nextjs/app/client-only.js +6 -6
- package/dist/host/react.cjs +7 -7
- package/dist/host/react.js +6 -6
- package/dist/internal/config/webpack/apply-shared-modules.cjs +8 -0
- package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -1
- package/dist/internal/config/webpack/apply-shared-modules.d.ts +6 -1
- package/dist/internal/config/webpack/apply-shared-modules.js +10 -0
- package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -1
- package/dist/internal/config/webpack/provider-adapter.cjs +85 -0
- package/dist/internal/config/webpack/provider-adapter.cjs.map +1 -0
- package/dist/internal/config/webpack/provider-adapter.d.ts +7 -0
- package/dist/internal/config/webpack/provider-adapter.js +64 -0
- package/dist/internal/config/webpack/provider-adapter.js.map +1 -0
- package/dist/internal/config/webpack/shared-module-resolver.cjs +73 -0
- package/dist/internal/config/webpack/shared-module-resolver.cjs.map +1 -0
- package/dist/internal/config/webpack/shared-module-resolver.d.ts +35 -0
- package/dist/internal/config/webpack/shared-module-resolver.js +50 -0
- package/dist/internal/config/webpack/shared-module-resolver.js.map +1 -0
- package/dist/internal/host/shared/provider.cjs +188 -0
- package/dist/internal/host/shared/provider.cjs.map +1 -0
- package/dist/internal/host/shared/provider.d.ts +71 -0
- package/dist/internal/host/shared/provider.js +161 -0
- package/dist/internal/host/shared/provider.js.map +1 -0
- package/dist/internal/host/shared/shared-broker.cjs +0 -30
- package/dist/internal/host/shared/shared-broker.cjs.map +1 -1
- package/dist/internal/host/shared/shared-broker.d.ts +1 -7
- package/dist/internal/host/shared/shared-broker.js +0 -29
- package/dist/internal/host/shared/shared-broker.js.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.cjs +6 -28
- package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.d.ts +9 -31
- package/dist/internal/host/shared/shared-module-resolver.js +4 -28
- package/dist/internal/host/shared/shared-module-resolver.js.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.cjs +3 -2
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.js +2 -4
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/module.cjs +40 -8
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/module.d.ts +7 -0
- package/dist/internal/runtime/turbopack/module.js +40 -8
- package/dist/internal/runtime/turbopack/module.js.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.cjs +22 -21
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.js +27 -24
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/{turbopack-KFQ3A7UU.cjs → turbopack-6BXAJGS5.cjs} +11 -11
- package/dist/{turbopack-A2TW7XKF.js → turbopack-WAERWSWW.js} +4 -4
- package/dist/{webpack-XYIZEJQX.cjs → webpack-VTSF2B2G.cjs} +11 -11
- package/dist/webpack-VTSF2B2G.cjs.map +1 -0
- package/dist/{webpack-UYL4UYZL.js → webpack-ZYOBNVFE.js} +6 -6
- package/dist/webpack-ZYOBNVFE.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-I7VKDF3E.cjs.map +0 -1
- package/dist/chunk-JZRA6DPE.js.map +0 -1
- package/dist/chunk-KTUPOJQQ.js.map +0 -1
- package/dist/chunk-W2TLJBAA.cjs.map +0 -1
- package/dist/chunk-ZSIOEMB3.js.map +0 -1
- package/dist/webpack-UYL4UYZL.js.map +0 -1
- package/dist/webpack-XYIZEJQX.cjs.map +0 -1
- /package/dist/{chunk-YOFJE3RL.cjs.map → chunk-J42V6HSP.cjs.map} +0 -0
- /package/dist/{chunk-CFZOLSLP.js.map → chunk-T6E2WPAB.js.map} +0 -0
- /package/dist/{chunk-4MLJE6UP.cjs.map → chunk-VB64GQX7.cjs.map} +0 -0
- /package/dist/{chunk-VWEKLTPJ.js.map → chunk-X6SKTJ5N.js.map} +0 -0
- /package/dist/{chunk-4WHSX7WW.cjs.map → chunk-XPMI4K3U.cjs.map} +0 -0
- /package/dist/{chunk-WGSS7TJP.js.map → chunk-ZJW3GQTP.js.map} +0 -0
- /package/dist/{turbopack-KFQ3A7UU.cjs.map → turbopack-6BXAJGS5.cjs.map} +0 -0
- /package/dist/{turbopack-A2TW7XKF.js.map → turbopack-WAERWSWW.js.map} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunk6NAV4SCFcjs = require('./chunk-6NAV4SCF.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ var _chunkW2TLJBAAcjs = require('./chunk-W2TLJBAA.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkSELGX4Y2cjs = require('./chunk-SELGX4Y2.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 = _chunkSELGX4Y2cjs.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 === _chunkSELGX4Y2cjs.RUNTIME_TURBOPACK) {
|
|
36
36
|
await Promise.allSettled(
|
|
37
37
|
scripts.map(
|
|
38
|
-
(script) => script.src ?
|
|
38
|
+
(script) => script.src ? _chunk6NAV4SCFcjs.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 = _chunkSELGX4Y2cjs.createScope.call(void 0, bundleName, url, runtime, resolveClientUrl);
|
|
45
|
+
_chunkSELGX4Y2cjs.registerScope.call(void 0, scope);
|
|
46
|
+
if (runtime === _chunkSELGX4Y2cjs.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__ = _chunk6NAV4SCFcjs.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 === _chunkSELGX4Y2cjs.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 === _chunkSELGX4Y2cjs.RUNTIME_TURBOPACK) {
|
|
74
74
|
const results = await Promise.allSettled(
|
|
75
75
|
scripts.map((script) => {
|
|
76
76
|
if (script.src) {
|
|
77
|
-
return
|
|
77
|
+
return _chunk6NAV4SCFcjs.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(_chunkSELGX4Y2cjs.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 === _chunkSELGX4Y2cjs.RUNTIME_WEBPACK && bundle && moduleId) {
|
|
108
|
+
const scope2 = _chunkSELGX4Y2cjs.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 = _chunkSELGX4Y2cjs.getScope.call(void 0, bundleName);
|
|
114
114
|
if (scope) {
|
|
115
|
-
return
|
|
115
|
+
return _chunk6NAV4SCFcjs.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-J42V6HSP.cjs.map
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CORE_REACT_SHARED_MODULE_IDS,
|
|
2
3
|
RUNTIME_WEBPACK,
|
|
3
4
|
SHARED_MODULE_MANIFEST_PROTOCOL,
|
|
4
5
|
collapseDoubleSlashes,
|
|
5
6
|
createSharedModulePlan,
|
|
6
7
|
formatRemoteId,
|
|
7
8
|
getScope,
|
|
8
|
-
installSharedModulePlan,
|
|
9
9
|
isSharedModuleManifest,
|
|
10
|
-
parseRemoteId
|
|
11
|
-
|
|
10
|
+
parseRemoteId,
|
|
11
|
+
resolveSharedModulePlan
|
|
12
|
+
} from "./chunk-6NUHDFSH.js";
|
|
12
13
|
import {
|
|
13
14
|
getNamespace
|
|
14
15
|
} from "./chunk-D5GNZB6O.js";
|
|
@@ -24,6 +25,247 @@ import {
|
|
|
24
25
|
isProxiedUrl
|
|
25
26
|
} from "./chunk-X6YKUJKH.js";
|
|
26
27
|
|
|
28
|
+
// src/host/shared/provider.ts
|
|
29
|
+
var DEFAULT_VERSION = "0";
|
|
30
|
+
var GLOBAL_PROVIDER_SCOPES_KEY = "__remote_components_shared_provider_scopes__";
|
|
31
|
+
function getProviderScopes() {
|
|
32
|
+
const self = globalThis;
|
|
33
|
+
self[GLOBAL_PROVIDER_SCOPES_KEY] ??= {};
|
|
34
|
+
return self[GLOBAL_PROVIDER_SCOPES_KEY];
|
|
35
|
+
}
|
|
36
|
+
function createSharedProvider({
|
|
37
|
+
value,
|
|
38
|
+
from
|
|
39
|
+
}) {
|
|
40
|
+
return {
|
|
41
|
+
get: () => value,
|
|
42
|
+
from,
|
|
43
|
+
eager: true,
|
|
44
|
+
loaded: 1
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function createSharedProviderEntry({
|
|
48
|
+
id,
|
|
49
|
+
specifier,
|
|
50
|
+
value,
|
|
51
|
+
required = true,
|
|
52
|
+
singleton = true,
|
|
53
|
+
scope,
|
|
54
|
+
from = "host"
|
|
55
|
+
}) {
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
specifier,
|
|
59
|
+
provider: createSharedProvider({ value, from }),
|
|
60
|
+
required,
|
|
61
|
+
singleton,
|
|
62
|
+
scope
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async function buildSharedProviderPlan({
|
|
66
|
+
bundle,
|
|
67
|
+
hostShared,
|
|
68
|
+
remoteShared,
|
|
69
|
+
scope = `remote:${bundle}`,
|
|
70
|
+
callerTag = "SharedBroker",
|
|
71
|
+
normalizeId = (id) => id,
|
|
72
|
+
additionalEntries = [],
|
|
73
|
+
onMissing
|
|
74
|
+
}) {
|
|
75
|
+
const sharedModulePlan = createSharedModulePlan({
|
|
76
|
+
bundle,
|
|
77
|
+
hostShared,
|
|
78
|
+
remoteShared,
|
|
79
|
+
scope,
|
|
80
|
+
callerTag
|
|
81
|
+
});
|
|
82
|
+
const resolved = await resolveSharedModulePlan(sharedModulePlan);
|
|
83
|
+
const entriesByIdAndSpecifier = /* @__PURE__ */ new Map();
|
|
84
|
+
const addEntry = (entry) => {
|
|
85
|
+
entriesByIdAndSpecifier.set(`${entry.id}\0${entry.specifier}`, entry);
|
|
86
|
+
};
|
|
87
|
+
for (const entry of additionalEntries) {
|
|
88
|
+
addEntry(
|
|
89
|
+
createSharedProviderEntry({
|
|
90
|
+
...entry,
|
|
91
|
+
scope: entry.scope ?? scope
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
for (const entry of sharedModulePlan.entries) {
|
|
96
|
+
if (entry.status !== "resolved") {
|
|
97
|
+
if (onMissing && !(sharedModulePlan.protocol === SHARED_MODULE_MANIFEST_PROTOCOL && entry.required)) {
|
|
98
|
+
onMissing(entry);
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const value = resolved[entry.id];
|
|
103
|
+
if (typeof value === "undefined")
|
|
104
|
+
continue;
|
|
105
|
+
addEntry(
|
|
106
|
+
createSharedProviderEntry({
|
|
107
|
+
id: normalizeId(entry.id),
|
|
108
|
+
specifier: entry.specifier,
|
|
109
|
+
value,
|
|
110
|
+
required: entry.required,
|
|
111
|
+
singleton: entry.singleton,
|
|
112
|
+
scope: entry.scope
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
protocol: sharedModulePlan.protocol,
|
|
118
|
+
entries: Array.from(entriesByIdAndSpecifier.values())
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function installSharedProvider({
|
|
122
|
+
scope,
|
|
123
|
+
specifier,
|
|
124
|
+
value,
|
|
125
|
+
from,
|
|
126
|
+
provider,
|
|
127
|
+
version = DEFAULT_VERSION
|
|
128
|
+
}) {
|
|
129
|
+
const scopes = getProviderScopes();
|
|
130
|
+
const providerScope = scopes[scope] ??= {};
|
|
131
|
+
const versions = providerScope[specifier] ??= {};
|
|
132
|
+
const sharedProvider = provider ?? createSharedProvider({
|
|
133
|
+
value,
|
|
134
|
+
from: from ?? "host"
|
|
135
|
+
});
|
|
136
|
+
versions[version] = sharedProvider;
|
|
137
|
+
return sharedProvider;
|
|
138
|
+
}
|
|
139
|
+
function installSharedProviderEntry(entry) {
|
|
140
|
+
return installSharedProvider({
|
|
141
|
+
scope: entry.scope,
|
|
142
|
+
specifier: entry.specifier,
|
|
143
|
+
provider: entry.provider
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function getSharedProvider({
|
|
147
|
+
scope,
|
|
148
|
+
specifier,
|
|
149
|
+
version = DEFAULT_VERSION
|
|
150
|
+
}) {
|
|
151
|
+
const versions = getProviderScopes()[scope]?.[specifier];
|
|
152
|
+
if (!versions)
|
|
153
|
+
return void 0;
|
|
154
|
+
return versions[version] ?? (version === DEFAULT_VERSION ? void 0 : versions[DEFAULT_VERSION]);
|
|
155
|
+
}
|
|
156
|
+
function getSharedProviderModule({
|
|
157
|
+
scope,
|
|
158
|
+
specifier,
|
|
159
|
+
version
|
|
160
|
+
}) {
|
|
161
|
+
const provider = getSharedProvider({ scope, specifier, version });
|
|
162
|
+
if (!provider) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
`Shared module "${specifier}" not found in provider scope "${scope}".`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
provider.loaded = 1;
|
|
168
|
+
return provider.get();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/config/webpack/shared-module-resolver.ts
|
|
172
|
+
var WEBPACK_SHARED_RESOLVE_METADATA = Symbol.for(
|
|
173
|
+
"remote-components.webpackSharedResolveMetadata"
|
|
174
|
+
);
|
|
175
|
+
function normalizeWebpackSharedId(id) {
|
|
176
|
+
return id.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "");
|
|
177
|
+
}
|
|
178
|
+
async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
|
|
179
|
+
const sharedProviderPlan = await buildSharedProviderPlan({
|
|
180
|
+
bundle,
|
|
181
|
+
hostShared,
|
|
182
|
+
remoteShared,
|
|
183
|
+
callerTag,
|
|
184
|
+
normalizeId: normalizeWebpackSharedId,
|
|
185
|
+
additionalEntries: Object.entries(CORE_REACT_SHARED_MODULE_IDS).map(
|
|
186
|
+
([specifier, id]) => ({
|
|
187
|
+
id,
|
|
188
|
+
specifier,
|
|
189
|
+
value: reactModules[id],
|
|
190
|
+
required: true,
|
|
191
|
+
singleton: true,
|
|
192
|
+
scope: `remote:${bundle}`
|
|
193
|
+
})
|
|
194
|
+
)
|
|
195
|
+
});
|
|
196
|
+
const resolve = {
|
|
197
|
+
...Object.fromEntries(
|
|
198
|
+
sharedProviderPlan.entries.map((entry) => [
|
|
199
|
+
entry.id,
|
|
200
|
+
entry.provider.get()
|
|
201
|
+
])
|
|
202
|
+
)
|
|
203
|
+
};
|
|
204
|
+
Object.defineProperty(resolve, WEBPACK_SHARED_RESOLVE_METADATA, {
|
|
205
|
+
enumerable: false,
|
|
206
|
+
value: {
|
|
207
|
+
protocol: sharedProviderPlan.protocol,
|
|
208
|
+
entries: sharedProviderPlan.entries
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return resolve;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/config/webpack/provider-adapter.ts
|
|
215
|
+
function applyWebpackSharedProviderModules(bundle, entries) {
|
|
216
|
+
logDebug(
|
|
217
|
+
"SharedModules",
|
|
218
|
+
`applyWebpackSharedProviderModules called for bundle: "${bundle}"`
|
|
219
|
+
);
|
|
220
|
+
const self = globalThis;
|
|
221
|
+
const scope = getScope(bundle);
|
|
222
|
+
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
223
|
+
if (!webpackBundle) {
|
|
224
|
+
throw new RemoteComponentsError(
|
|
225
|
+
`No Webpack require found for manifest-aware Remote Component bundle "${bundle}".`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (!webpackBundle.m) {
|
|
229
|
+
throw new RemoteComponentsError(
|
|
230
|
+
`Webpack module factories are not available for manifest-aware Remote Component bundle "${bundle}".`
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const modulePaths = Object.keys(
|
|
234
|
+
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m
|
|
235
|
+
);
|
|
236
|
+
for (const entry of entries) {
|
|
237
|
+
installSharedProviderEntry(entry);
|
|
238
|
+
const ids = resolveWebpackModuleIds(bundle, modulePaths, entry.id);
|
|
239
|
+
if (ids.length === 0) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
for (const id of ids) {
|
|
243
|
+
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
244
|
+
webpackBundle.m[resolvedId] = (module) => {
|
|
245
|
+
module.exports = getSharedProviderModule({
|
|
246
|
+
scope: entry.scope,
|
|
247
|
+
specifier: entry.specifier
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function resolveWebpackModuleIds(bundle, modulePaths, id) {
|
|
254
|
+
const exactIds = modulePaths.filter((path) => path === id);
|
|
255
|
+
if (exactIds.length > 0) {
|
|
256
|
+
return exactIds;
|
|
257
|
+
}
|
|
258
|
+
const containedIds = modulePaths.filter((path) => path.includes(id));
|
|
259
|
+
if (containedIds.length > 0) {
|
|
260
|
+
return containedIds;
|
|
261
|
+
}
|
|
262
|
+
logDebug(
|
|
263
|
+
"SharedModules",
|
|
264
|
+
`No matching module path found for manifest shared module "${id}" in bundle "${bundle}"`
|
|
265
|
+
);
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
|
|
27
269
|
// src/config/webpack/apply-shared-modules.ts
|
|
28
270
|
var DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
29
271
|
function applySharedModules(bundle, resolve) {
|
|
@@ -35,6 +277,11 @@ function applySharedModules(bundle, resolve) {
|
|
|
35
277
|
"SharedModules",
|
|
36
278
|
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
37
279
|
);
|
|
280
|
+
const metadata = resolve[WEBPACK_SHARED_RESOLVE_METADATA];
|
|
281
|
+
if (metadata?.protocol === SHARED_MODULE_MANIFEST_PROTOCOL) {
|
|
282
|
+
applyWebpackSharedProviderModules(bundle, metadata.entries);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
38
285
|
const self = globalThis;
|
|
39
286
|
const scope = getScope(bundle);
|
|
40
287
|
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
@@ -510,13 +757,17 @@ function createTurbopackContext(scope, exports, moduleExports, modules, moduleIn
|
|
|
510
757
|
r(requireId) {
|
|
511
758
|
return scopedRequire(requireId);
|
|
512
759
|
},
|
|
513
|
-
//
|
|
760
|
+
// exportValue — mirrors upstream Turbopack's `exportValue`, which sets
|
|
761
|
+
// `module.exports = value` regardless of value type. Most importantly,
|
|
762
|
+
// when Turbopack emits an async-loader module the body is
|
|
763
|
+
// ctx.v((parentImport) => Promise.all([...]).then(() => parentImport(id)))
|
|
764
|
+
// The function must be stored as-is so that the consumer's `ctx.A(id)`
|
|
765
|
+
// can invoke it with the real parent-import resolver. Calling it eagerly
|
|
766
|
+
// here (the prior remote-components behavior) ran the loader with the
|
|
767
|
+
// wrong argument and stored a `Promise` as `exports.default`, which then
|
|
768
|
+
// crashed `ctx.A` with `.default is not a function`.
|
|
514
769
|
v(value) {
|
|
515
|
-
|
|
516
|
-
exports.default = value((vid) => scopedRequire(vid));
|
|
517
|
-
} else {
|
|
518
|
-
moduleExports.exports = value;
|
|
519
|
-
}
|
|
770
|
+
moduleExports.exports = value;
|
|
520
771
|
},
|
|
521
772
|
// exportUrl — used by static asset modules (images, fonts, JSON, etc.).
|
|
522
773
|
// Turbopack emits a tiny module whose entire body is ctx.q(url), which
|
|
@@ -529,6 +780,20 @@ function createTurbopackContext(scope, exports, moduleExports, modules, moduleIn
|
|
|
529
780
|
moduleExports.exports = value;
|
|
530
781
|
}
|
|
531
782
|
},
|
|
783
|
+
// exportNamespace — Turbopack emits `ctx.n(namespace, esmId?)` when a
|
|
784
|
+
// module's exports should be replaced wholesale with a precomputed ESM
|
|
785
|
+
// namespace object (commonly at module evaluation time for re-export
|
|
786
|
+
// patterns and CJS-to-ESM interop wrappers). Mirrors upstream
|
|
787
|
+
// `exportNamespace` which sets both `module.exports` and
|
|
788
|
+
// `module.namespaceObject`; remote-components keeps a single exports
|
|
789
|
+
// record per module, so we assign to `exports` only.
|
|
790
|
+
n(namespace, esmId) {
|
|
791
|
+
if (esmId != null) {
|
|
792
|
+
scope.moduleCache[String(esmId)] = namespace;
|
|
793
|
+
} else {
|
|
794
|
+
moduleExports.exports = namespace;
|
|
795
|
+
}
|
|
796
|
+
},
|
|
532
797
|
// async module initializer
|
|
533
798
|
async a(mod) {
|
|
534
799
|
let result;
|
|
@@ -539,10 +804,24 @@ function createTurbopackContext(scope, exports, moduleExports, modules, moduleIn
|
|
|
539
804
|
);
|
|
540
805
|
exports.default = result;
|
|
541
806
|
},
|
|
542
|
-
// async module loader — resolves directly via scope
|
|
807
|
+
// async module loader — resolves directly via scope.
|
|
808
|
+
//
|
|
809
|
+
// Upstream Turbopack's `asyncLoader` treats `require(id)` itself as the
|
|
810
|
+
// loader function (see `module.exports = loaderFn` set by the factory).
|
|
811
|
+
// remote-components additionally supports `{ default: loaderFn }`, which
|
|
812
|
+
// is what a factory using `ctx.s([['default', () => fn]], ...)` produces.
|
|
813
|
+
// Both shapes must be accepted: when `ctx.n(loaderFn, esmId)` injects a
|
|
814
|
+
// function directly into the cache, the require result is the function
|
|
815
|
+
// itself and there is no `.default` to dereference.
|
|
543
816
|
async A(Aid) {
|
|
544
817
|
const mod = scopedRequire(Aid);
|
|
545
|
-
|
|
818
|
+
const loader = typeof mod === "function" ? mod : mod?.default;
|
|
819
|
+
if (typeof loader !== "function") {
|
|
820
|
+
throw new Error(
|
|
821
|
+
`Async module loader for "${Aid}" is not a function (got ${typeof loader})`
|
|
822
|
+
);
|
|
823
|
+
}
|
|
824
|
+
return loader((parentId) => scopedRequire(parentId));
|
|
546
825
|
},
|
|
547
826
|
// dynamic import tracking — no-op for remote components
|
|
548
827
|
j() {
|
|
@@ -635,12 +914,19 @@ async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}
|
|
|
635
914
|
"sharedModuleId"
|
|
636
915
|
);
|
|
637
916
|
if (sharedModuleId) {
|
|
638
|
-
const
|
|
917
|
+
const moduleExports = handleTurbopackModule(
|
|
639
918
|
scope,
|
|
640
919
|
sharedModuleId,
|
|
641
920
|
formatRemoteId(scope, String(sharedModuleInitializerId))
|
|
642
921
|
);
|
|
643
|
-
|
|
922
|
+
const loaderCandidate = typeof moduleExports === "function" ? moduleExports : moduleExports?.default;
|
|
923
|
+
if (typeof loaderCandidate === "function") {
|
|
924
|
+
sharedModuleInitializer = loaderCandidate(
|
|
925
|
+
(parentId) => requireModule(scope, parentId)
|
|
926
|
+
);
|
|
927
|
+
} else if (loaderCandidate && typeof loaderCandidate.then === "function") {
|
|
928
|
+
sharedModuleInitializer = loaderCandidate;
|
|
929
|
+
}
|
|
644
930
|
}
|
|
645
931
|
}
|
|
646
932
|
if (sharedModuleInitializer) {
|
|
@@ -758,33 +1044,26 @@ function stripQuotes2(value) {
|
|
|
758
1044
|
return value;
|
|
759
1045
|
}
|
|
760
1046
|
function installSharedModules(scope, hostShared, sharedModuleIds, missingMessage) {
|
|
761
|
-
|
|
1047
|
+
return buildSharedProviderPlan({
|
|
762
1048
|
bundle: scope.name,
|
|
763
1049
|
hostShared,
|
|
764
1050
|
remoteShared: sharedModuleIds,
|
|
765
1051
|
scope: `remote:${scope.scopedName}`,
|
|
766
|
-
callerTag: "SharedModules"
|
|
767
|
-
});
|
|
768
|
-
for (const entry of plan.entries) {
|
|
769
|
-
if (entry.status === "resolved") {
|
|
770
|
-
delete scope.moduleCache[entry.id];
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
return installSharedModulePlan({
|
|
774
|
-
plan,
|
|
775
|
-
target: scope.sharedModules,
|
|
776
1052
|
callerTag: "SharedModules",
|
|
777
1053
|
onMissing: (entry) => {
|
|
778
1054
|
logError("SharedModules", missingMessage(entry.id, entry.specifier));
|
|
779
1055
|
}
|
|
780
|
-
}).then(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
1056
|
+
}).then(
|
|
1057
|
+
(results) => results.entries.map((entry) => {
|
|
1058
|
+
installSharedProviderEntry(entry);
|
|
1059
|
+
scope.sharedModules[entry.id] = getSharedProviderModule({
|
|
1060
|
+
scope: entry.scope,
|
|
1061
|
+
specifier: entry.specifier
|
|
1062
|
+
});
|
|
1063
|
+
delete scope.moduleCache[entry.id];
|
|
1064
|
+
return void 0;
|
|
1065
|
+
})
|
|
1066
|
+
);
|
|
788
1067
|
}
|
|
789
1068
|
function preferSharedManifest(sharedModuleIds, remoteShared) {
|
|
790
1069
|
if (!isSharedModuleManifest(remoteShared))
|
|
@@ -1060,6 +1339,7 @@ function findPreviousModuleId(entries, factoryIndex) {
|
|
|
1060
1339
|
}
|
|
1061
1340
|
|
|
1062
1341
|
export {
|
|
1342
|
+
buildWebpackResolve,
|
|
1063
1343
|
applySharedModules,
|
|
1064
1344
|
loadChunkWithScope,
|
|
1065
1345
|
createChunkDispatcher,
|
|
@@ -1067,4 +1347,4 @@ export {
|
|
|
1067
1347
|
requireModule,
|
|
1068
1348
|
nextClientPagesLoader
|
|
1069
1349
|
};
|
|
1070
|
-
//# sourceMappingURL=chunk-
|
|
1350
|
+
//# sourceMappingURL=chunk-JYGC7T6L.js.map
|