every-plugin 3.0.0-rc.12 → 3.0.0-rc.14
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/runtime/mf-config.cjs +1 -1
- package/dist/runtime/mf-config.mjs +1 -1
- package/dist/shared-deps-spec.cjs +13 -4
- package/dist/shared-deps-spec.cjs.map +1 -1
- package/dist/shared-deps-spec.d.cts +10 -2
- package/dist/shared-deps-spec.d.cts.map +1 -1
- package/dist/shared-deps-spec.d.mts +10 -2
- package/dist/shared-deps-spec.d.mts.map +1 -1
- package/dist/shared-deps-spec.mjs +13 -4
- package/dist/shared-deps-spec.mjs.map +1 -1
- package/package.json +1 -1
- package/src/shared-deps-spec.ts +23 -6
|
@@ -3,7 +3,7 @@ const require_shared_deps_spec = require('../shared-deps-spec.cjs');
|
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/mf-config.ts
|
|
6
|
-
const PLUGIN_VERSION = "3.0.0-rc.
|
|
6
|
+
const PLUGIN_VERSION = "3.0.0-rc.14";
|
|
7
7
|
const MF_CORE_SHARED_DEPS = require_shared_deps_spec.buildMfCoreSharedDependencies({ ownVersion: PLUGIN_VERSION });
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import { buildMfCoreSharedDependencies } from "../shared-deps-spec.mjs";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
|
|
4
4
|
//#region src/runtime/mf-config.ts
|
|
5
|
-
const PLUGIN_VERSION = "3.0.0-rc.
|
|
5
|
+
const PLUGIN_VERSION = "3.0.0-rc.14";
|
|
6
6
|
const MF_CORE_SHARED_DEPS = buildMfCoreSharedDependencies({ ownVersion: PLUGIN_VERSION });
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
@@ -24,8 +24,11 @@ let node_url = require("node:url");
|
|
|
24
24
|
* runtime/services/shared-identity.ts relies on it.
|
|
25
25
|
* - ui: shared by the core ui provider and ui remotes (react, react-dom,
|
|
26
26
|
* @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev
|
|
27
|
-
* session/i18n subpath modules).
|
|
28
|
-
* `import: false`.
|
|
27
|
+
* session/i18n subpath modules). Strict singletons; consumers add
|
|
28
|
+
* `import: false`. Tolerant outliers (`critical: false` — sonner today)
|
|
29
|
+
* keep a bundled fallback copy in consumers and waive requiredVersion, so
|
|
30
|
+
* an old provider / new remote mix degrades to per-remote copies instead
|
|
31
|
+
* of failing a share negotiation.
|
|
29
32
|
*/
|
|
30
33
|
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
31
34
|
var SharedDependencyResolutionError = class extends effect.Data.TaggedError("SharedDependencyResolutionError") {
|
|
@@ -145,6 +148,12 @@ const UI_SHARED_DEPS = [
|
|
|
145
148
|
singleton: true,
|
|
146
149
|
critical: true,
|
|
147
150
|
resolution: "subpath"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "sonner",
|
|
154
|
+
singleton: true,
|
|
155
|
+
critical: false,
|
|
156
|
+
resolution: "package"
|
|
148
157
|
}
|
|
149
158
|
];
|
|
150
159
|
const SHARED_DEP_SPECS = (() => {
|
|
@@ -303,7 +312,7 @@ function createUiSharedDeps(options = {}) {
|
|
|
303
312
|
workspaceRoot: options.workspaceRoot,
|
|
304
313
|
resolution: spec.resolution === "subpath" ? "subpath" : "package"
|
|
305
314
|
});
|
|
306
|
-
const strict = options.strictVersion !== false;
|
|
315
|
+
const strict = spec.critical !== false && options.strictVersion !== false;
|
|
307
316
|
deps[spec.name] = {
|
|
308
317
|
version,
|
|
309
318
|
requiredVersion: strict ? version : false,
|
|
@@ -311,7 +320,7 @@ function createUiSharedDeps(options = {}) {
|
|
|
311
320
|
strictVersion: strict,
|
|
312
321
|
eager: false,
|
|
313
322
|
shareScope: "default",
|
|
314
|
-
...options.role === "consumer" ? { import: false } : {}
|
|
323
|
+
...options.role === "consumer" && strict ? { import: false } : {}
|
|
315
324
|
};
|
|
316
325
|
}
|
|
317
326
|
return deps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps-spec.cjs","names":["require","createRequire","Data","join","existsSync","readFileSync","dirname","resolve","fileURLToPath"],"sources":["../src/shared-deps-spec.ts"],"sourcesContent":["/**\n * SharedDependencySpec: the one module owning shared-dependency names,\n * criticality, version resolution, and fallback policy across the Module\n * Federation graph. Four consumers derive from it — the rspack config\n * factory (plugin builds), the rsbuild config factory (ui remotes), the\n * runtime mf-config (the every-plugin MF instance), and the host's shared\n * pre-registration — so a name or criticality can never disagree between\n * them, and an unresolved version fails the build loudly instead of\n * silently degrading to \"*\"/\"latest\" (which disables the strict-singleton\n * guard).\n *\n * Lists:\n * - core: shared by the host and server-side plugin remotes (every-plugin,\n * effect, zod, @orpc/*). Effect-critical entries pin the exact installed\n * version (strictVersion) — the version-check machinery in\n * runtime/services/shared-identity.ts relies on it.\n * - ui: shared by the core ui provider and ui remotes (react, react-dom,\n * @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev\n * session/i18n subpath modules). All strict singletons; consumers add\n * `import: false`.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { Data } from \"effect\";\n\nconst require = createRequire(import.meta.url);\n\nexport class SharedDependencyResolutionError extends Data.TaggedError(\n \"SharedDependencyResolutionError\",\n)<{\n readonly packageName: string;\n readonly searched: string[];\n}> {\n constructor(packageName: string, searched: string[]) {\n super({\n packageName,\n searched,\n });\n }\n\n override get message() {\n return (\n `Could not resolve shared dependency \"${this.packageName}\". Looked in:\\n` +\n this.searched.map((location) => ` - ${location}`).join(\"\\n\") +\n `\\nUnresolved shared dependencies fail loudly (no \"*\", no \"latest\" fallback) — ` +\n `install the package in the resolving workspace or pin a resolvable version.`\n );\n }\n}\n\nexport type SharedDependencyResolution = \"self\" | \"package\" | \"subpath\";\n\nexport interface SharedDependencySpec {\n name: string;\n singleton: true;\n /** exact-version pin (requiredVersion = resolved version, strictVersion = true) */\n critical: boolean;\n resolution: SharedDependencyResolution;\n}\n\nexport const CORE_SHARED_DEPS = [\n { name: \"every-plugin\", singleton: true, critical: true, resolution: \"self\" },\n { name: \"effect\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"zod\", singleton: true, critical: false, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/server\", singleton: true, critical: true, resolution: \"package\" },\n // v1's proven sharing set, restored: @orpc/openapi, @orpc/experimental-effect,\n // and @orpc/publisher joined this list in the v2 fleet-spec pass and their\n // share-scope consumption broke plugin loading at runtime\n // (__webpack_modules__[r] is not a function — the runtime's import()-based\n // provides hand the consumer an ESM namespace where a module factory is\n // expected). They stay declared in each workspace's package.json and are\n // bundled per workspace instead.\n] as const satisfies readonly SharedDependencySpec[];\n\nexport type CoreSharedDepName = (typeof CORE_SHARED_DEPS)[number][\"name\"];\n\nconst coreCriticalNames = CORE_SHARED_DEPS.flatMap((spec) => (spec.critical ? [spec.name] : []));\n\n/**\n * Effect-critical shared names, derived from the core list's `critical: true`\n * entries — the one source of criticality (`strictVersion` pinning in the\n * runtime's version-check machinery keys off this list).\n */\nexport const EFFECT_CRITICAL_SHARED_DEPS: readonly EffectCriticalSharedDepName[] =\n coreCriticalNames;\n\nexport type EffectCriticalSharedDepName = (typeof coreCriticalNames)[number];\n\nexport const isEffectCriticalSharedDep = (name: string): boolean =>\n (EFFECT_CRITICAL_SHARED_DEPS as readonly string[]).includes(name);\n\nexport const UI_SHARED_DEPS = [\n { name: \"react\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"react-dom\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-query\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-router\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/core\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/react\", singleton: true, critical: true, resolution: \"package\" },\n {\n name: \"everything-dev/ui/auth\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n {\n name: \"everything-dev/ui/i18n\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n] as const satisfies readonly SharedDependencySpec[];\n\nexport const SHARED_DEP_SPECS: readonly SharedDependencySpec[] = (() => {\n const byName = new Map<string, SharedDependencySpec>();\n for (const spec of [...CORE_SHARED_DEPS, ...UI_SHARED_DEPS]) {\n const existing = byName.get(spec.name);\n if (existing) {\n if (existing.critical !== spec.critical) {\n throw new Error(\n `Shared dependency spec conflict for \"${spec.name}\": criticality disagrees between the core and ui lists`,\n );\n }\n continue;\n }\n byName.set(spec.name, spec);\n }\n return [...byName.values()];\n})();\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nexport type SharedConfigInput = {\n version: string;\n requiredVersion?: string | false;\n singleton?: boolean;\n strictVersion?: boolean;\n eager?: boolean;\n shareScope?: string;\n};\n\nexport interface SharedDependencyResolutionOptions {\n /** the building workspace to resolve from; default is this module's own location */\n workspaceRoot?: string;\n resolution?: \"package\" | \"subpath\";\n}\n\nfunction searchedNote(target: string): string {\n return `require.resolve(\"${target}\")`;\n}\n\nfunction findPackageJsonVersion(startDir: string, searched: string[]): string | null {\n let currentDir = startDir;\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n searched.push(packageJsonPath);\n if (existsSync(packageJsonPath)) {\n try {\n const version = (JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n const parent = dirname(currentDir);\n if (parent === currentDir) break;\n currentDir = parent;\n }\n return null;\n}\n\nfunction resolveSubpathVersion(\n request: string,\n workspaceRoot: string | undefined,\n searched: string[],\n): string | null {\n if (request.startsWith(\"@\")) {\n throw new Error(\n `Scoped-package subpath \"${request}\" is not supported — subpath version resolution ` +\n `handles unscoped specifiers only (the known subpath specs, everything-dev/ui/*, are unscoped).`,\n );\n }\n const packageName = request.split(\"/\")[0] ?? request;\n const subpath = request.split(\"/\").slice(1).join(\"/\");\n const candidates: string[] = [];\n if (workspaceRoot) {\n candidates.push(join(workspaceRoot, \"node_modules\", packageName, \"package.json\"));\n }\n const resolveRequests: Array<{ request: string; paths?: string[] }> = [\n { request: `${packageName}/${subpath}`, ...(workspaceRoot ? { paths: [workspaceRoot] } : {}) },\n { request: `${packageName}/${subpath}` },\n {\n request: `${packageName}/package.json`,\n ...(workspaceRoot ? { paths: [workspaceRoot] } : {}),\n },\n { request: `${packageName}/package.json` },\n ];\n for (const { request: target, paths } of resolveRequests) {\n try {\n const resolved = require.resolve(target, paths ? { paths } : undefined);\n searched.push(resolved);\n candidates.push(\n resolved.endsWith(\"package.json\")\n ? resolved\n : resolve(dirname(resolved), \"..\", \"..\", \"package.json\"),\n );\n } catch {\n searched.push(searchedNote(target));\n }\n }\n for (const candidate of candidates) {\n if (!existsSync(candidate)) continue;\n try {\n const version = (JSON.parse(readFileSync(candidate, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {}\n }\n return null;\n}\n\nexport function resolveSharedVersion(\n name: string,\n options: SharedDependencyResolutionOptions = {},\n): string {\n const searched: string[] = [];\n const { workspaceRoot, resolution = \"package\" } = options;\n\n if (resolution === \"subpath\") {\n const version = resolveSubpathVersion(name, workspaceRoot, searched);\n if (version) return version;\n throw new SharedDependencyResolutionError(name, searched);\n }\n\n const roots: Array<string | undefined> = workspaceRoot ? [workspaceRoot, undefined] : [undefined];\n for (const root of roots) {\n try {\n const resolved = root ? require.resolve(name, { paths: [root] }) : require.resolve(name);\n searched.push(resolved);\n const version = findPackageJsonVersion(dirname(resolved), searched);\n if (version) return version;\n } catch {\n searched.push(searchedNote(name));\n }\n }\n throw new SharedDependencyResolutionError(name, searched);\n}\n\nfunction resolveOwnVersion(searched: string[]): string {\n const localPackageJson = join(dirname(fileURLToPath(import.meta.url)), \"..\", \"package.json\");\n searched.push(localPackageJson);\n if (existsSync(localPackageJson)) {\n try {\n const version = (JSON.parse(readFileSync(localPackageJson, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n try {\n const resolved = require.resolve(\"every-plugin/package.json\");\n searched.push(resolved);\n const version = (JSON.parse(readFileSync(resolved, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {\n searched.push(searchedNote(\"every-plugin/package.json\"));\n }\n throw new SharedDependencyResolutionError(\"every-plugin\", searched);\n}\n\nexport function shareConfigFor(\n spec: SharedDependencySpec,\n version: string,\n): Omit<SharedDependencyConfig, \"version\"> {\n return spec.critical\n ? {\n requiredVersion: version,\n singleton: true,\n strictVersion: true,\n eager: false,\n shareScope: \"default\",\n }\n : {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n };\n}\n\nexport interface SharedDepsBuildOptions {\n /** the every-plugin share version; default resolves the installed package.json */\n ownVersion?: string;\n}\n\nfunction specVersion(spec: SharedDependencySpec, options: SharedDepsBuildOptions): string {\n if (spec.resolution === \"self\") {\n return options.ownVersion ?? resolveOwnVersion([`own package.json of \"${spec.name}\"`]);\n }\n return resolveSharedVersion(spec.name, {\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n}\n\nexport function getPluginSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): SharedDependencies {\n return Object.fromEntries(\n CORE_SHARED_DEPS.map((spec) => {\n const version = specVersion(spec, options);\n return [spec.name, { version, ...shareConfigFor(spec, version) }];\n }),\n );\n}\n\nexport interface HostSharedEntry {\n version: string;\n shareScope: string;\n shareConfig: {\n singleton: boolean;\n requiredVersion: string | false;\n strictVersion: boolean;\n eager: boolean;\n };\n}\n\nexport function toHostSharedEntry(name: string, config: SharedConfigInput): HostSharedEntry {\n const normalized = normalizeSharedConfig(config, name);\n return {\n version: normalized.version,\n shareScope: normalized.shareScope,\n shareConfig: {\n singleton: normalized.singleton,\n requiredVersion: normalized.requiredVersion,\n strictVersion: normalized.strictVersion,\n eager: normalized.eager,\n },\n };\n}\n\n/**\n * The runtime mf-config's core shared map: the same entries\n * `getPluginSharedDependencies` assembles, shaped through the one host mapper\n * (`toHostSharedEntry`) so both consumers derive from a single entry type.\n */\nexport function buildMfCoreSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): Record<string, HostSharedEntry> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies(options)).map(([name, config]) => [\n name,\n toHostSharedEntry(name, config),\n ]),\n );\n}\n\nexport interface UiSharedDepEntry {\n version: string;\n requiredVersion: string | false;\n singleton: true;\n strictVersion: boolean;\n eager: false;\n shareScope: \"default\";\n /** consumer role only: no bundled fallback copy — the provider provides */\n import?: false;\n}\n\nexport interface UiSharedDepsOptions {\n /** explicit core-shell parity opt-out; default is the strict singleton */\n strictVersion?: boolean;\n role?: \"provider\" | \"consumer\";\n workspaceRoot?: string;\n}\n\nexport function createUiSharedDeps(\n options: UiSharedDepsOptions = {},\n): Record<string, UiSharedDepEntry> {\n const deps: Record<string, UiSharedDepEntry> = {};\n for (const spec of UI_SHARED_DEPS) {\n const version = resolveSharedVersion(spec.name, {\n workspaceRoot: options.workspaceRoot,\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n const strict = options.strictVersion !== false;\n deps[spec.name] = {\n version,\n requiredVersion: strict ? version : false,\n singleton: true,\n strictVersion: strict,\n eager: false,\n shareScope: \"default\",\n ...(options.role === \"consumer\" ? { import: false as const } : {}),\n };\n }\n return deps;\n}\n\nconst UNRESOLVED_VERSIONS = new Set([\"*\", \"latest\", \"\"]);\n\nexport function assertResolvedSharedVersion(name: string, version: unknown): string {\n if (typeof version !== \"string\" || UNRESOLVED_VERSIONS.has(version.trim())) {\n throw new SharedDependencyResolutionError(name, [\n `declared version ${JSON.stringify(version ?? null)} is not resolvable — \"*\", \"latest\", and empty fail loudly instead of disabling the strict-singleton guard`,\n ]);\n }\n return version;\n}\n\nexport function normalizeSharedConfig(\n config: SharedConfigInput,\n name: string,\n): SharedDependencyConfig {\n const version = assertResolvedSharedVersion(name, config.version);\n return {\n version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nfunction comparableSharedConfig(config: SharedConfigInput) {\n return {\n version: config.version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nexport function isSameSharedConfig(a: SharedConfigInput, b: SharedConfigInput): boolean {\n const left = comparableSharedConfig(a);\n const right = comparableSharedConfig(b);\n return (\n left.version === right.version &&\n left.requiredVersion === right.requiredVersion &&\n left.singleton === right.singleton &&\n left.strictVersion === right.strictVersion &&\n left.eager === right.eager &&\n left.shareScope === right.shareScope\n );\n}\n\nexport function mergeSharedMaps(\n ...maps: Array<Record<string, SharedConfigInput> | undefined>\n): Record<string, SharedDependencyConfig> {\n const merged: Record<string, SharedDependencyConfig> = {};\n for (const map of maps) {\n if (!map) continue;\n for (const [name, config] of Object.entries(map)) {\n const normalized = normalizeSharedConfig(config, name);\n const existing = merged[name];\n if (existing && !isSameSharedConfig(existing, normalized)) {\n throw new Error(\n `Conflicting shared dependency \"${name}\" in shared dependency configuration`,\n );\n }\n merged[name] = normalized;\n }\n }\n return merged;\n}\n\nexport interface SharedVersionRecordEntry {\n version: string;\n singleton?: boolean;\n}\n\n/**\n * The `name → version` record of a build's shared-singleton map, for the\n * build report (and from there the version manifest's `shared` field) —\n * #546: a slot's pin must carry shared-dep semantics so consumers can detect\n * a build skew before loading. Singletons only — non-singletons never take\n * part in the negotiation a skew breaks.\n */\nexport function sharedVersionRecord(\n shared: Record<string, SharedVersionRecordEntry>,\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [name, config] of Object.entries(shared)) {\n if (config.singleton !== false && config.version) {\n out[name] = config.version;\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,gBAAUC,wEAA6B;AAE7C,IAAa,kCAAb,cAAqDC,YAAK,YACxD,iCACF,CAAC,CAGE;CACD,YAAY,aAAqB,UAAoB;EACnD,MAAM;GACJ;GACA;EACF,CAAC;CACH;CAEA,IAAa,UAAU;EACrB,OACE,wCAAwC,KAAK,YAAY,mBACzD,KAAK,SAAS,KAAK,aAAa,OAAO,UAAU,CAAC,CAAC,KAAK,IAAI,IAC5D;CAGJ;AACF;AAYA,MAAa,mBAAmB;CAC9B;EAAE,MAAM;EAAgB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAO;CAC5E;EAAE,MAAM;EAAU,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CACzE;EAAE,MAAM;EAAO,WAAW;EAAM,UAAU;EAAO,YAAY;CAAU;CACvE;EAAE,MAAM;EAAkB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CACjF;EAAE,MAAM;EAAgB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CAC/E;EAAE,MAAM;EAAgB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;AAQjF;AAIA,MAAM,oBAAoB,iBAAiB,SAAS,SAAU,KAAK,WAAW,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE;;;;;;AAO/F,MAAa,8BACX;AAIF,MAAa,6BAA6B,SACvC,4BAAkD,SAAS,IAAI;AAElE,MAAa,iBAAiB;CAC5B;EAAE,MAAM;EAAS,WAAW;EAAM,UAAU;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K,kBAAkB,MAAM,iBAC7B,KAAK,UAAU,MAAM,SACrB,KAAK,eAAe,MAAM;AAE9B;AAEA,SAAgB,gBACd,GAAG,MACqC;CACxC,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,CAAC,KAAK;EACV,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,GAAG,GAAG;GAChD,MAAM,aAAa,sBAAsB,QAAQ,IAAI;GACrD,MAAM,WAAW,OAAO;GACxB,IAAI,YAAY,CAAC,mBAAmB,UAAU,UAAU,GACtD,MAAM,IAAI,MACR,kCAAkC,KAAK,qCACzC;GAEF,OAAO,QAAQ;EACjB;CACF;CACA,OAAO;AACT;;;;;;;;AAcA,SAAgB,oBACd,QACwB;CACxB,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GAChD,IAAI,OAAO,cAAc,SAAS,OAAO,SACvC,IAAI,QAAQ,OAAO;CAGvB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"shared-deps-spec.cjs","names":["require","createRequire","Data","join","existsSync","readFileSync","dirname","resolve","fileURLToPath"],"sources":["../src/shared-deps-spec.ts"],"sourcesContent":["/**\n * SharedDependencySpec: the one module owning shared-dependency names,\n * criticality, version resolution, and fallback policy across the Module\n * Federation graph. Four consumers derive from it — the rspack config\n * factory (plugin builds), the rsbuild config factory (ui remotes), the\n * runtime mf-config (the every-plugin MF instance), and the host's shared\n * pre-registration — so a name or criticality can never disagree between\n * them, and an unresolved version fails the build loudly instead of\n * silently degrading to \"*\"/\"latest\" (which disables the strict-singleton\n * guard).\n *\n * Lists:\n * - core: shared by the host and server-side plugin remotes (every-plugin,\n * effect, zod, @orpc/*). Effect-critical entries pin the exact installed\n * version (strictVersion) — the version-check machinery in\n * runtime/services/shared-identity.ts relies on it.\n * - ui: shared by the core ui provider and ui remotes (react, react-dom,\n * @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev\n * session/i18n subpath modules). Strict singletons; consumers add\n * `import: false`. Tolerant outliers (`critical: false` — sonner today)\n * keep a bundled fallback copy in consumers and waive requiredVersion, so\n * an old provider / new remote mix degrades to per-remote copies instead\n * of failing a share negotiation.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { Data } from \"effect\";\n\nconst require = createRequire(import.meta.url);\n\nexport class SharedDependencyResolutionError extends Data.TaggedError(\n \"SharedDependencyResolutionError\",\n)<{\n readonly packageName: string;\n readonly searched: string[];\n}> {\n constructor(packageName: string, searched: string[]) {\n super({\n packageName,\n searched,\n });\n }\n\n override get message() {\n return (\n `Could not resolve shared dependency \"${this.packageName}\". Looked in:\\n` +\n this.searched.map((location) => ` - ${location}`).join(\"\\n\") +\n `\\nUnresolved shared dependencies fail loudly (no \"*\", no \"latest\" fallback) — ` +\n `install the package in the resolving workspace or pin a resolvable version.`\n );\n }\n}\n\nexport type SharedDependencyResolution = \"self\" | \"package\" | \"subpath\";\n\nexport interface SharedDependencySpec {\n name: string;\n singleton: true;\n /** exact-version pin (requiredVersion = resolved version, strictVersion = true) */\n critical: boolean;\n resolution: SharedDependencyResolution;\n}\n\nexport const CORE_SHARED_DEPS = [\n { name: \"every-plugin\", singleton: true, critical: true, resolution: \"self\" },\n { name: \"effect\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"zod\", singleton: true, critical: false, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/server\", singleton: true, critical: true, resolution: \"package\" },\n // v1's proven sharing set, restored: @orpc/openapi, @orpc/experimental-effect,\n // and @orpc/publisher joined this list in the v2 fleet-spec pass and their\n // share-scope consumption broke plugin loading at runtime\n // (__webpack_modules__[r] is not a function — the runtime's import()-based\n // provides hand the consumer an ESM namespace where a module factory is\n // expected). They stay declared in each workspace's package.json and are\n // bundled per workspace instead.\n] as const satisfies readonly SharedDependencySpec[];\n\nexport type CoreSharedDepName = (typeof CORE_SHARED_DEPS)[number][\"name\"];\n\nconst coreCriticalNames = CORE_SHARED_DEPS.flatMap((spec) => (spec.critical ? [spec.name] : []));\n\n/**\n * Effect-critical shared names, derived from the core list's `critical: true`\n * entries — the one source of criticality (`strictVersion` pinning in the\n * runtime's version-check machinery keys off this list).\n */\nexport const EFFECT_CRITICAL_SHARED_DEPS: readonly EffectCriticalSharedDepName[] =\n coreCriticalNames;\n\nexport type EffectCriticalSharedDepName = (typeof coreCriticalNames)[number];\n\nexport const isEffectCriticalSharedDep = (name: string): boolean =>\n (EFFECT_CRITICAL_SHARED_DEPS as readonly string[]).includes(name);\n\nexport const UI_SHARED_DEPS = [\n { name: \"react\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"react-dom\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-query\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-router\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/core\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/react\", singleton: true, critical: true, resolution: \"package\" },\n {\n name: \"everything-dev/ui/auth\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n {\n name: \"everything-dev/ui/i18n\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n // Tolerant singleton: the mounted Toaster lives in the core ui's sonner\n // instance, so plugins must resolve the same module for their toast() calls\n // to render. critical:false keeps a bundled fallback copy in remotes — a\n // share negotiation against an old provider degrades to per-remote copies\n // instead of failing the import.\n {\n name: \"sonner\",\n singleton: true,\n critical: false,\n resolution: \"package\",\n },\n] as const satisfies readonly SharedDependencySpec[];\n\nexport const SHARED_DEP_SPECS: readonly SharedDependencySpec[] = (() => {\n const byName = new Map<string, SharedDependencySpec>();\n for (const spec of [...CORE_SHARED_DEPS, ...UI_SHARED_DEPS]) {\n const existing = byName.get(spec.name);\n if (existing) {\n if (existing.critical !== spec.critical) {\n throw new Error(\n `Shared dependency spec conflict for \"${spec.name}\": criticality disagrees between the core and ui lists`,\n );\n }\n continue;\n }\n byName.set(spec.name, spec);\n }\n return [...byName.values()];\n})();\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nexport type SharedConfigInput = {\n version: string;\n requiredVersion?: string | false;\n singleton?: boolean;\n strictVersion?: boolean;\n eager?: boolean;\n shareScope?: string;\n};\n\nexport interface SharedDependencyResolutionOptions {\n /** the building workspace to resolve from; default is this module's own location */\n workspaceRoot?: string;\n resolution?: \"package\" | \"subpath\";\n}\n\nfunction searchedNote(target: string): string {\n return `require.resolve(\"${target}\")`;\n}\n\nfunction findPackageJsonVersion(startDir: string, searched: string[]): string | null {\n let currentDir = startDir;\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n searched.push(packageJsonPath);\n if (existsSync(packageJsonPath)) {\n try {\n const version = (JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n const parent = dirname(currentDir);\n if (parent === currentDir) break;\n currentDir = parent;\n }\n return null;\n}\n\nfunction resolveSubpathVersion(\n request: string,\n workspaceRoot: string | undefined,\n searched: string[],\n): string | null {\n if (request.startsWith(\"@\")) {\n throw new Error(\n `Scoped-package subpath \"${request}\" is not supported — subpath version resolution ` +\n `handles unscoped specifiers only (the known subpath specs, everything-dev/ui/*, are unscoped).`,\n );\n }\n const packageName = request.split(\"/\")[0] ?? request;\n const subpath = request.split(\"/\").slice(1).join(\"/\");\n const candidates: string[] = [];\n if (workspaceRoot) {\n candidates.push(join(workspaceRoot, \"node_modules\", packageName, \"package.json\"));\n }\n const resolveRequests: Array<{ request: string; paths?: string[] }> = [\n { request: `${packageName}/${subpath}`, ...(workspaceRoot ? { paths: [workspaceRoot] } : {}) },\n { request: `${packageName}/${subpath}` },\n {\n request: `${packageName}/package.json`,\n ...(workspaceRoot ? { paths: [workspaceRoot] } : {}),\n },\n { request: `${packageName}/package.json` },\n ];\n for (const { request: target, paths } of resolveRequests) {\n try {\n const resolved = require.resolve(target, paths ? { paths } : undefined);\n searched.push(resolved);\n candidates.push(\n resolved.endsWith(\"package.json\")\n ? resolved\n : resolve(dirname(resolved), \"..\", \"..\", \"package.json\"),\n );\n } catch {\n searched.push(searchedNote(target));\n }\n }\n for (const candidate of candidates) {\n if (!existsSync(candidate)) continue;\n try {\n const version = (JSON.parse(readFileSync(candidate, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {}\n }\n return null;\n}\n\nexport function resolveSharedVersion(\n name: string,\n options: SharedDependencyResolutionOptions = {},\n): string {\n const searched: string[] = [];\n const { workspaceRoot, resolution = \"package\" } = options;\n\n if (resolution === \"subpath\") {\n const version = resolveSubpathVersion(name, workspaceRoot, searched);\n if (version) return version;\n throw new SharedDependencyResolutionError(name, searched);\n }\n\n const roots: Array<string | undefined> = workspaceRoot ? [workspaceRoot, undefined] : [undefined];\n for (const root of roots) {\n try {\n const resolved = root ? require.resolve(name, { paths: [root] }) : require.resolve(name);\n searched.push(resolved);\n const version = findPackageJsonVersion(dirname(resolved), searched);\n if (version) return version;\n } catch {\n searched.push(searchedNote(name));\n }\n }\n throw new SharedDependencyResolutionError(name, searched);\n}\n\nfunction resolveOwnVersion(searched: string[]): string {\n const localPackageJson = join(dirname(fileURLToPath(import.meta.url)), \"..\", \"package.json\");\n searched.push(localPackageJson);\n if (existsSync(localPackageJson)) {\n try {\n const version = (JSON.parse(readFileSync(localPackageJson, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n try {\n const resolved = require.resolve(\"every-plugin/package.json\");\n searched.push(resolved);\n const version = (JSON.parse(readFileSync(resolved, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {\n searched.push(searchedNote(\"every-plugin/package.json\"));\n }\n throw new SharedDependencyResolutionError(\"every-plugin\", searched);\n}\n\nexport function shareConfigFor(\n spec: SharedDependencySpec,\n version: string,\n): Omit<SharedDependencyConfig, \"version\"> {\n return spec.critical\n ? {\n requiredVersion: version,\n singleton: true,\n strictVersion: true,\n eager: false,\n shareScope: \"default\",\n }\n : {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n };\n}\n\nexport interface SharedDepsBuildOptions {\n /** the every-plugin share version; default resolves the installed package.json */\n ownVersion?: string;\n}\n\nfunction specVersion(spec: SharedDependencySpec, options: SharedDepsBuildOptions): string {\n if (spec.resolution === \"self\") {\n return options.ownVersion ?? resolveOwnVersion([`own package.json of \"${spec.name}\"`]);\n }\n return resolveSharedVersion(spec.name, {\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n}\n\nexport function getPluginSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): SharedDependencies {\n return Object.fromEntries(\n CORE_SHARED_DEPS.map((spec) => {\n const version = specVersion(spec, options);\n return [spec.name, { version, ...shareConfigFor(spec, version) }];\n }),\n );\n}\n\nexport interface HostSharedEntry {\n version: string;\n shareScope: string;\n shareConfig: {\n singleton: boolean;\n requiredVersion: string | false;\n strictVersion: boolean;\n eager: boolean;\n };\n}\n\nexport function toHostSharedEntry(name: string, config: SharedConfigInput): HostSharedEntry {\n const normalized = normalizeSharedConfig(config, name);\n return {\n version: normalized.version,\n shareScope: normalized.shareScope,\n shareConfig: {\n singleton: normalized.singleton,\n requiredVersion: normalized.requiredVersion,\n strictVersion: normalized.strictVersion,\n eager: normalized.eager,\n },\n };\n}\n\n/**\n * The runtime mf-config's core shared map: the same entries\n * `getPluginSharedDependencies` assembles, shaped through the one host mapper\n * (`toHostSharedEntry`) so both consumers derive from a single entry type.\n */\nexport function buildMfCoreSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): Record<string, HostSharedEntry> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies(options)).map(([name, config]) => [\n name,\n toHostSharedEntry(name, config),\n ]),\n );\n}\n\nexport interface UiSharedDepEntry {\n version: string;\n requiredVersion: string | false;\n singleton: true;\n strictVersion: boolean;\n eager: false;\n shareScope: \"default\";\n /** critical entries in consumer role only: no bundled fallback copy — the\n * provider provides; tolerant entries keep their own bundled copy so a\n * share negotiation against an old provider still imports */\n import?: false;\n}\n\nexport interface UiSharedDepsOptions {\n /** explicit core-shell parity opt-out for critical entries; default is the\n * strict singleton. Tolerant (`critical: false`) entries are never strict. */\n strictVersion?: boolean;\n role?: \"provider\" | \"consumer\";\n workspaceRoot?: string;\n}\n\nexport function createUiSharedDeps(\n options: UiSharedDepsOptions = {},\n): Record<string, UiSharedDepEntry> {\n const deps: Record<string, UiSharedDepEntry> = {};\n for (const spec of UI_SHARED_DEPS) {\n const version = resolveSharedVersion(spec.name, {\n workspaceRoot: options.workspaceRoot,\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n const strict = spec.critical !== false && options.strictVersion !== false;\n deps[spec.name] = {\n version,\n requiredVersion: strict ? version : false,\n singleton: true,\n strictVersion: strict,\n eager: false,\n shareScope: \"default\",\n ...(options.role === \"consumer\" && strict ? { import: false as const } : {}),\n };\n }\n return deps;\n}\n\nconst UNRESOLVED_VERSIONS = new Set([\"*\", \"latest\", \"\"]);\n\nexport function assertResolvedSharedVersion(name: string, version: unknown): string {\n if (typeof version !== \"string\" || UNRESOLVED_VERSIONS.has(version.trim())) {\n throw new SharedDependencyResolutionError(name, [\n `declared version ${JSON.stringify(version ?? null)} is not resolvable — \"*\", \"latest\", and empty fail loudly instead of disabling the strict-singleton guard`,\n ]);\n }\n return version;\n}\n\nexport function normalizeSharedConfig(\n config: SharedConfigInput,\n name: string,\n): SharedDependencyConfig {\n const version = assertResolvedSharedVersion(name, config.version);\n return {\n version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nfunction comparableSharedConfig(config: SharedConfigInput) {\n return {\n version: config.version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nexport function isSameSharedConfig(a: SharedConfigInput, b: SharedConfigInput): boolean {\n const left = comparableSharedConfig(a);\n const right = comparableSharedConfig(b);\n return (\n left.version === right.version &&\n left.requiredVersion === right.requiredVersion &&\n left.singleton === right.singleton &&\n left.strictVersion === right.strictVersion &&\n left.eager === right.eager &&\n left.shareScope === right.shareScope\n );\n}\n\nexport function mergeSharedMaps(\n ...maps: Array<Record<string, SharedConfigInput> | undefined>\n): Record<string, SharedDependencyConfig> {\n const merged: Record<string, SharedDependencyConfig> = {};\n for (const map of maps) {\n if (!map) continue;\n for (const [name, config] of Object.entries(map)) {\n const normalized = normalizeSharedConfig(config, name);\n const existing = merged[name];\n if (existing && !isSameSharedConfig(existing, normalized)) {\n throw new Error(\n `Conflicting shared dependency \"${name}\" in shared dependency configuration`,\n );\n }\n merged[name] = normalized;\n }\n }\n return merged;\n}\n\nexport interface SharedVersionRecordEntry {\n version: string;\n singleton?: boolean;\n}\n\n/**\n * The `name → version` record of a build's shared-singleton map, for the\n * build report (and from there the version manifest's `shared` field) —\n * #546: a slot's pin must carry shared-dep semantics so consumers can detect\n * a build skew before loading. Singletons only — non-singletons never take\n * part in the negotiation a skew breaks.\n */\nexport function sharedVersionRecord(\n shared: Record<string, SharedVersionRecordEntry>,\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [name, config] of Object.entries(shared)) {\n if (config.singleton !== false && config.version) {\n out[name] = config.version;\n }\n }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AK;EACV,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,GAAG,GAAG;GAChD,MAAM,aAAa,sBAAsB,QAAQ,IAAI;GACrD,MAAM,WAAW,OAAO;GACxB,IAAI,YAAY,CAAC,mBAAmB,UAAU,UAAU,GACtD,MAAM,IAAI,MACR,kCAAkC,KAAK,qCACzC;GAEF,OAAO,QAAQ;EACjB;CACF;CACA,OAAO;AACT;;;;;;;;AAcA,SAAgB,oBACd,QACwB;CACxB,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GAChD,IAAI,OAAO,cAAc,SAAS,OAAO,SACvC,IAAI,QAAQ,OAAO;CAGvB,OAAO;AACT"}
|
|
@@ -108,6 +108,11 @@ declare const UI_SHARED_DEPS: readonly [{
|
|
|
108
108
|
readonly singleton: true;
|
|
109
109
|
readonly critical: true;
|
|
110
110
|
readonly resolution: "subpath";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "sonner";
|
|
113
|
+
readonly singleton: true;
|
|
114
|
+
readonly critical: false;
|
|
115
|
+
readonly resolution: "package";
|
|
111
116
|
}];
|
|
112
117
|
declare const SHARED_DEP_SPECS: readonly SharedDependencySpec[];
|
|
113
118
|
interface SharedDependencyConfig {
|
|
@@ -163,11 +168,14 @@ interface UiSharedDepEntry {
|
|
|
163
168
|
strictVersion: boolean;
|
|
164
169
|
eager: false;
|
|
165
170
|
shareScope: "default";
|
|
166
|
-
/** consumer role only: no bundled fallback copy — the
|
|
171
|
+
/** critical entries in consumer role only: no bundled fallback copy — the
|
|
172
|
+
* provider provides; tolerant entries keep their own bundled copy so a
|
|
173
|
+
* share negotiation against an old provider still imports */
|
|
167
174
|
import?: false;
|
|
168
175
|
}
|
|
169
176
|
interface UiSharedDepsOptions {
|
|
170
|
-
/** explicit core-shell parity opt-out; default is the
|
|
177
|
+
/** explicit core-shell parity opt-out for critical entries; default is the
|
|
178
|
+
* strict singleton. Tolerant (`critical: false`) entries are never strict. */
|
|
171
179
|
strictVersion?: boolean;
|
|
172
180
|
role?: "provider" | "consumer";
|
|
173
181
|
workspaceRoot?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps-spec.d.cts","names":[],"sources":["../src/shared-deps-spec.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"shared-deps-spec.d.cts","names":[],"sources":["../src/shared-deps-spec.ts"],"mappings":";;;;cAgCa,wCAAwC;WAG1C;WACA;;EAET,YAAY,qBAAqB;MAOpB;;KAUH;UAEK;EACf;EACA;;EAEA;EACA,YAAY;;cAGD;WACH;;;WAA6D;;WAC7D;;;WAAuD;;WACvD;;;WAAqD;;WACrD;;;WAA+D;;WAC/D;;;WAA6D;;WAC7D;;;WAA6D;;KAU3D,4BAA4B;cAElC;;;;;;cAOO,sCAAsC;KAGvC,sCAAsC;cAErC,4BAAyB;cAGzB;WACH;;;WAAsD;;WACtD;;;WAA0D;;WAC1D;;;WAA6D;;WAC7D;;;WAA+D;;WAC/D;;;WAAsE;;WACtE;;;WAAuE;;WACvE;;;WAA6D;;WAC7D;;;WAA8D;;WAE9D;;;WAGM;;WAGN;;;WAGM;;WAQN;;;WAGM;;cAIH,2BAA2B;UAiBvB;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU,qBAAqB,eAAe;KAEpC;EACV;EACA;EACA;EACA;EACA;EACA;;UAGe;;EAEf;EACA;;iBA2Ec,qBACd,cACA,UAAS;iBA8CK,eACd,MAAM,sBACN,kBACC,KAAK;UAkBS;;EAEf;;iBAYc,4BACd,UAAS,yBACR;UASc;EACf;EACA;EACA;IACE;IACA;IACA;IACA;;;iBAIY,kBAAkB,cAAc,QAAQ,oBAAoB;;;;;;iBAmB5D,8BACd,UAAS,yBACR,eAAe;UASD;EACf;EACA;EACA;EACA;EACA;EACA;;;;EAIA;;UAGe;;;EAGf;EACA;EACA;;iBAGc,mBACd,UAAS,sBACR,eAAe;iBAuBF,4BAA4B,cAAc;iBAS1C,sBACd,QAAQ,mBACR,eACC;iBAuBa,mBAAmB,GAAG,mBAAmB,GAAG;iBAa5C,mBACX,MAAM,MAAM,eAAe,kCAC7B,eAAe;UAkBD;EACf;EACA;;;;;;;;;iBAUc,oBACd,QAAQ,eAAe,4BACtB"}
|
|
@@ -108,6 +108,11 @@ declare const UI_SHARED_DEPS: readonly [{
|
|
|
108
108
|
readonly singleton: true;
|
|
109
109
|
readonly critical: true;
|
|
110
110
|
readonly resolution: "subpath";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "sonner";
|
|
113
|
+
readonly singleton: true;
|
|
114
|
+
readonly critical: false;
|
|
115
|
+
readonly resolution: "package";
|
|
111
116
|
}];
|
|
112
117
|
declare const SHARED_DEP_SPECS: readonly SharedDependencySpec[];
|
|
113
118
|
interface SharedDependencyConfig {
|
|
@@ -163,11 +168,14 @@ interface UiSharedDepEntry {
|
|
|
163
168
|
strictVersion: boolean;
|
|
164
169
|
eager: false;
|
|
165
170
|
shareScope: "default";
|
|
166
|
-
/** consumer role only: no bundled fallback copy — the
|
|
171
|
+
/** critical entries in consumer role only: no bundled fallback copy — the
|
|
172
|
+
* provider provides; tolerant entries keep their own bundled copy so a
|
|
173
|
+
* share negotiation against an old provider still imports */
|
|
167
174
|
import?: false;
|
|
168
175
|
}
|
|
169
176
|
interface UiSharedDepsOptions {
|
|
170
|
-
/** explicit core-shell parity opt-out; default is the
|
|
177
|
+
/** explicit core-shell parity opt-out for critical entries; default is the
|
|
178
|
+
* strict singleton. Tolerant (`critical: false`) entries are never strict. */
|
|
171
179
|
strictVersion?: boolean;
|
|
172
180
|
role?: "provider" | "consumer";
|
|
173
181
|
workspaceRoot?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps-spec.d.mts","names":[],"sources":["../src/shared-deps-spec.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"shared-deps-spec.d.mts","names":[],"sources":["../src/shared-deps-spec.ts"],"mappings":";;;;cAgCa,wCAAwC;WAG1C;WACA;;EAET,YAAY,qBAAqB;MAOpB;;KAUH;UAEK;EACf;EACA;;EAEA;EACA,YAAY;;cAGD;WACH;;;WAA6D;;WAC7D;;;WAAuD;;WACvD;;;WAAqD;;WACrD;;;WAA+D;;WAC/D;;;WAA6D;;WAC7D;;;WAA6D;;KAU3D,4BAA4B;cAElC;;;;;;cAOO,sCAAsC;KAGvC,sCAAsC;cAErC,4BAAyB;cAGzB;WACH;;;WAAsD;;WACtD;;;WAA0D;;WAC1D;;;WAA6D;;WAC7D;;;WAA+D;;WAC/D;;;WAAsE;;WACtE;;;WAAuE;;WACvE;;;WAA6D;;WAC7D;;;WAA8D;;WAE9D;;;WAGM;;WAGN;;;WAGM;;WAQN;;;WAGM;;cAIH,2BAA2B;UAiBvB;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU,qBAAqB,eAAe;KAEpC;EACV;EACA;EACA;EACA;EACA;EACA;;UAGe;;EAEf;EACA;;iBA2Ec,qBACd,cACA,UAAS;iBA8CK,eACd,MAAM,sBACN,kBACC,KAAK;UAkBS;;EAEf;;iBAYc,4BACd,UAAS,yBACR;UASc;EACf;EACA;EACA;IACE;IACA;IACA;IACA;;;iBAIY,kBAAkB,cAAc,QAAQ,oBAAoB;;;;;;iBAmB5D,8BACd,UAAS,yBACR,eAAe;UASD;EACf;EACA;EACA;EACA;EACA;EACA;;;;EAIA;;UAGe;;;EAGf;EACA;EACA;;iBAGc,mBACd,UAAS,sBACR,eAAe;iBAuBF,4BAA4B,cAAc;iBAS1C,sBACd,QAAQ,mBACR,eACC;iBAuBa,mBAAmB,GAAG,mBAAmB,GAAG;iBAa5C,mBACX,MAAM,MAAM,eAAe,kCAC7B,eAAe;UAkBD;EACf;EACA;;;;;;;;;iBAUc,oBACd,QAAQ,eAAe,4BACtB"}
|
|
@@ -23,8 +23,11 @@ import { fileURLToPath } from "node:url";
|
|
|
23
23
|
* runtime/services/shared-identity.ts relies on it.
|
|
24
24
|
* - ui: shared by the core ui provider and ui remotes (react, react-dom,
|
|
25
25
|
* @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev
|
|
26
|
-
* session/i18n subpath modules).
|
|
27
|
-
* `import: false`.
|
|
26
|
+
* session/i18n subpath modules). Strict singletons; consumers add
|
|
27
|
+
* `import: false`. Tolerant outliers (`critical: false` — sonner today)
|
|
28
|
+
* keep a bundled fallback copy in consumers and waive requiredVersion, so
|
|
29
|
+
* an old provider / new remote mix degrades to per-remote copies instead
|
|
30
|
+
* of failing a share negotiation.
|
|
28
31
|
*/
|
|
29
32
|
const require = createRequire(import.meta.url);
|
|
30
33
|
var SharedDependencyResolutionError = class extends Data.TaggedError("SharedDependencyResolutionError") {
|
|
@@ -144,6 +147,12 @@ const UI_SHARED_DEPS = [
|
|
|
144
147
|
singleton: true,
|
|
145
148
|
critical: true,
|
|
146
149
|
resolution: "subpath"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "sonner",
|
|
153
|
+
singleton: true,
|
|
154
|
+
critical: false,
|
|
155
|
+
resolution: "package"
|
|
147
156
|
}
|
|
148
157
|
];
|
|
149
158
|
const SHARED_DEP_SPECS = (() => {
|
|
@@ -302,7 +311,7 @@ function createUiSharedDeps(options = {}) {
|
|
|
302
311
|
workspaceRoot: options.workspaceRoot,
|
|
303
312
|
resolution: spec.resolution === "subpath" ? "subpath" : "package"
|
|
304
313
|
});
|
|
305
|
-
const strict = options.strictVersion !== false;
|
|
314
|
+
const strict = spec.critical !== false && options.strictVersion !== false;
|
|
306
315
|
deps[spec.name] = {
|
|
307
316
|
version,
|
|
308
317
|
requiredVersion: strict ? version : false,
|
|
@@ -310,7 +319,7 @@ function createUiSharedDeps(options = {}) {
|
|
|
310
319
|
strictVersion: strict,
|
|
311
320
|
eager: false,
|
|
312
321
|
shareScope: "default",
|
|
313
|
-
...options.role === "consumer" ? { import: false } : {}
|
|
322
|
+
...options.role === "consumer" && strict ? { import: false } : {}
|
|
314
323
|
};
|
|
315
324
|
}
|
|
316
325
|
return deps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-deps-spec.mjs","names":[],"sources":["../src/shared-deps-spec.ts"],"sourcesContent":["/**\n * SharedDependencySpec: the one module owning shared-dependency names,\n * criticality, version resolution, and fallback policy across the Module\n * Federation graph. Four consumers derive from it — the rspack config\n * factory (plugin builds), the rsbuild config factory (ui remotes), the\n * runtime mf-config (the every-plugin MF instance), and the host's shared\n * pre-registration — so a name or criticality can never disagree between\n * them, and an unresolved version fails the build loudly instead of\n * silently degrading to \"*\"/\"latest\" (which disables the strict-singleton\n * guard).\n *\n * Lists:\n * - core: shared by the host and server-side plugin remotes (every-plugin,\n * effect, zod, @orpc/*). Effect-critical entries pin the exact installed\n * version (strictVersion) — the version-check machinery in\n * runtime/services/shared-identity.ts relies on it.\n * - ui: shared by the core ui provider and ui remotes (react, react-dom,\n * @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev\n * session/i18n subpath modules). All strict singletons; consumers add\n * `import: false`.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { Data } from \"effect\";\n\nconst require = createRequire(import.meta.url);\n\nexport class SharedDependencyResolutionError extends Data.TaggedError(\n \"SharedDependencyResolutionError\",\n)<{\n readonly packageName: string;\n readonly searched: string[];\n}> {\n constructor(packageName: string, searched: string[]) {\n super({\n packageName,\n searched,\n });\n }\n\n override get message() {\n return (\n `Could not resolve shared dependency \"${this.packageName}\". Looked in:\\n` +\n this.searched.map((location) => ` - ${location}`).join(\"\\n\") +\n `\\nUnresolved shared dependencies fail loudly (no \"*\", no \"latest\" fallback) — ` +\n `install the package in the resolving workspace or pin a resolvable version.`\n );\n }\n}\n\nexport type SharedDependencyResolution = \"self\" | \"package\" | \"subpath\";\n\nexport interface SharedDependencySpec {\n name: string;\n singleton: true;\n /** exact-version pin (requiredVersion = resolved version, strictVersion = true) */\n critical: boolean;\n resolution: SharedDependencyResolution;\n}\n\nexport const CORE_SHARED_DEPS = [\n { name: \"every-plugin\", singleton: true, critical: true, resolution: \"self\" },\n { name: \"effect\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"zod\", singleton: true, critical: false, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/server\", singleton: true, critical: true, resolution: \"package\" },\n // v1's proven sharing set, restored: @orpc/openapi, @orpc/experimental-effect,\n // and @orpc/publisher joined this list in the v2 fleet-spec pass and their\n // share-scope consumption broke plugin loading at runtime\n // (__webpack_modules__[r] is not a function — the runtime's import()-based\n // provides hand the consumer an ESM namespace where a module factory is\n // expected). They stay declared in each workspace's package.json and are\n // bundled per workspace instead.\n] as const satisfies readonly SharedDependencySpec[];\n\nexport type CoreSharedDepName = (typeof CORE_SHARED_DEPS)[number][\"name\"];\n\nconst coreCriticalNames = CORE_SHARED_DEPS.flatMap((spec) => (spec.critical ? [spec.name] : []));\n\n/**\n * Effect-critical shared names, derived from the core list's `critical: true`\n * entries — the one source of criticality (`strictVersion` pinning in the\n * runtime's version-check machinery keys off this list).\n */\nexport const EFFECT_CRITICAL_SHARED_DEPS: readonly EffectCriticalSharedDepName[] =\n coreCriticalNames;\n\nexport type EffectCriticalSharedDepName = (typeof coreCriticalNames)[number];\n\nexport const isEffectCriticalSharedDep = (name: string): boolean =>\n (EFFECT_CRITICAL_SHARED_DEPS as readonly string[]).includes(name);\n\nexport const UI_SHARED_DEPS = [\n { name: \"react\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"react-dom\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-query\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-router\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/core\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/react\", singleton: true, critical: true, resolution: \"package\" },\n {\n name: \"everything-dev/ui/auth\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n {\n name: \"everything-dev/ui/i18n\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n] as const satisfies readonly SharedDependencySpec[];\n\nexport const SHARED_DEP_SPECS: readonly SharedDependencySpec[] = (() => {\n const byName = new Map<string, SharedDependencySpec>();\n for (const spec of [...CORE_SHARED_DEPS, ...UI_SHARED_DEPS]) {\n const existing = byName.get(spec.name);\n if (existing) {\n if (existing.critical !== spec.critical) {\n throw new Error(\n `Shared dependency spec conflict for \"${spec.name}\": criticality disagrees between the core and ui lists`,\n );\n }\n continue;\n }\n byName.set(spec.name, spec);\n }\n return [...byName.values()];\n})();\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nexport type SharedConfigInput = {\n version: string;\n requiredVersion?: string | false;\n singleton?: boolean;\n strictVersion?: boolean;\n eager?: boolean;\n shareScope?: string;\n};\n\nexport interface SharedDependencyResolutionOptions {\n /** the building workspace to resolve from; default is this module's own location */\n workspaceRoot?: string;\n resolution?: \"package\" | \"subpath\";\n}\n\nfunction searchedNote(target: string): string {\n return `require.resolve(\"${target}\")`;\n}\n\nfunction findPackageJsonVersion(startDir: string, searched: string[]): string | null {\n let currentDir = startDir;\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n searched.push(packageJsonPath);\n if (existsSync(packageJsonPath)) {\n try {\n const version = (JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n const parent = dirname(currentDir);\n if (parent === currentDir) break;\n currentDir = parent;\n }\n return null;\n}\n\nfunction resolveSubpathVersion(\n request: string,\n workspaceRoot: string | undefined,\n searched: string[],\n): string | null {\n if (request.startsWith(\"@\")) {\n throw new Error(\n `Scoped-package subpath \"${request}\" is not supported — subpath version resolution ` +\n `handles unscoped specifiers only (the known subpath specs, everything-dev/ui/*, are unscoped).`,\n );\n }\n const packageName = request.split(\"/\")[0] ?? request;\n const subpath = request.split(\"/\").slice(1).join(\"/\");\n const candidates: string[] = [];\n if (workspaceRoot) {\n candidates.push(join(workspaceRoot, \"node_modules\", packageName, \"package.json\"));\n }\n const resolveRequests: Array<{ request: string; paths?: string[] }> = [\n { request: `${packageName}/${subpath}`, ...(workspaceRoot ? { paths: [workspaceRoot] } : {}) },\n { request: `${packageName}/${subpath}` },\n {\n request: `${packageName}/package.json`,\n ...(workspaceRoot ? { paths: [workspaceRoot] } : {}),\n },\n { request: `${packageName}/package.json` },\n ];\n for (const { request: target, paths } of resolveRequests) {\n try {\n const resolved = require.resolve(target, paths ? { paths } : undefined);\n searched.push(resolved);\n candidates.push(\n resolved.endsWith(\"package.json\")\n ? resolved\n : resolve(dirname(resolved), \"..\", \"..\", \"package.json\"),\n );\n } catch {\n searched.push(searchedNote(target));\n }\n }\n for (const candidate of candidates) {\n if (!existsSync(candidate)) continue;\n try {\n const version = (JSON.parse(readFileSync(candidate, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {}\n }\n return null;\n}\n\nexport function resolveSharedVersion(\n name: string,\n options: SharedDependencyResolutionOptions = {},\n): string {\n const searched: string[] = [];\n const { workspaceRoot, resolution = \"package\" } = options;\n\n if (resolution === \"subpath\") {\n const version = resolveSubpathVersion(name, workspaceRoot, searched);\n if (version) return version;\n throw new SharedDependencyResolutionError(name, searched);\n }\n\n const roots: Array<string | undefined> = workspaceRoot ? [workspaceRoot, undefined] : [undefined];\n for (const root of roots) {\n try {\n const resolved = root ? require.resolve(name, { paths: [root] }) : require.resolve(name);\n searched.push(resolved);\n const version = findPackageJsonVersion(dirname(resolved), searched);\n if (version) return version;\n } catch {\n searched.push(searchedNote(name));\n }\n }\n throw new SharedDependencyResolutionError(name, searched);\n}\n\nfunction resolveOwnVersion(searched: string[]): string {\n const localPackageJson = join(dirname(fileURLToPath(import.meta.url)), \"..\", \"package.json\");\n searched.push(localPackageJson);\n if (existsSync(localPackageJson)) {\n try {\n const version = (JSON.parse(readFileSync(localPackageJson, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n try {\n const resolved = require.resolve(\"every-plugin/package.json\");\n searched.push(resolved);\n const version = (JSON.parse(readFileSync(resolved, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {\n searched.push(searchedNote(\"every-plugin/package.json\"));\n }\n throw new SharedDependencyResolutionError(\"every-plugin\", searched);\n}\n\nexport function shareConfigFor(\n spec: SharedDependencySpec,\n version: string,\n): Omit<SharedDependencyConfig, \"version\"> {\n return spec.critical\n ? {\n requiredVersion: version,\n singleton: true,\n strictVersion: true,\n eager: false,\n shareScope: \"default\",\n }\n : {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n };\n}\n\nexport interface SharedDepsBuildOptions {\n /** the every-plugin share version; default resolves the installed package.json */\n ownVersion?: string;\n}\n\nfunction specVersion(spec: SharedDependencySpec, options: SharedDepsBuildOptions): string {\n if (spec.resolution === \"self\") {\n return options.ownVersion ?? resolveOwnVersion([`own package.json of \"${spec.name}\"`]);\n }\n return resolveSharedVersion(spec.name, {\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n}\n\nexport function getPluginSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): SharedDependencies {\n return Object.fromEntries(\n CORE_SHARED_DEPS.map((spec) => {\n const version = specVersion(spec, options);\n return [spec.name, { version, ...shareConfigFor(spec, version) }];\n }),\n );\n}\n\nexport interface HostSharedEntry {\n version: string;\n shareScope: string;\n shareConfig: {\n singleton: boolean;\n requiredVersion: string | false;\n strictVersion: boolean;\n eager: boolean;\n };\n}\n\nexport function toHostSharedEntry(name: string, config: SharedConfigInput): HostSharedEntry {\n const normalized = normalizeSharedConfig(config, name);\n return {\n version: normalized.version,\n shareScope: normalized.shareScope,\n shareConfig: {\n singleton: normalized.singleton,\n requiredVersion: normalized.requiredVersion,\n strictVersion: normalized.strictVersion,\n eager: normalized.eager,\n },\n };\n}\n\n/**\n * The runtime mf-config's core shared map: the same entries\n * `getPluginSharedDependencies` assembles, shaped through the one host mapper\n * (`toHostSharedEntry`) so both consumers derive from a single entry type.\n */\nexport function buildMfCoreSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): Record<string, HostSharedEntry> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies(options)).map(([name, config]) => [\n name,\n toHostSharedEntry(name, config),\n ]),\n );\n}\n\nexport interface UiSharedDepEntry {\n version: string;\n requiredVersion: string | false;\n singleton: true;\n strictVersion: boolean;\n eager: false;\n shareScope: \"default\";\n /** consumer role only: no bundled fallback copy — the provider provides */\n import?: false;\n}\n\nexport interface UiSharedDepsOptions {\n /** explicit core-shell parity opt-out; default is the strict singleton */\n strictVersion?: boolean;\n role?: \"provider\" | \"consumer\";\n workspaceRoot?: string;\n}\n\nexport function createUiSharedDeps(\n options: UiSharedDepsOptions = {},\n): Record<string, UiSharedDepEntry> {\n const deps: Record<string, UiSharedDepEntry> = {};\n for (const spec of UI_SHARED_DEPS) {\n const version = resolveSharedVersion(spec.name, {\n workspaceRoot: options.workspaceRoot,\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n const strict = options.strictVersion !== false;\n deps[spec.name] = {\n version,\n requiredVersion: strict ? version : false,\n singleton: true,\n strictVersion: strict,\n eager: false,\n shareScope: \"default\",\n ...(options.role === \"consumer\" ? { import: false as const } : {}),\n };\n }\n return deps;\n}\n\nconst UNRESOLVED_VERSIONS = new Set([\"*\", \"latest\", \"\"]);\n\nexport function assertResolvedSharedVersion(name: string, version: unknown): string {\n if (typeof version !== \"string\" || UNRESOLVED_VERSIONS.has(version.trim())) {\n throw new SharedDependencyResolutionError(name, [\n `declared version ${JSON.stringify(version ?? null)} is not resolvable — \"*\", \"latest\", and empty fail loudly instead of disabling the strict-singleton guard`,\n ]);\n }\n return version;\n}\n\nexport function normalizeSharedConfig(\n config: SharedConfigInput,\n name: string,\n): SharedDependencyConfig {\n const version = assertResolvedSharedVersion(name, config.version);\n return {\n version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nfunction comparableSharedConfig(config: SharedConfigInput) {\n return {\n version: config.version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nexport function isSameSharedConfig(a: SharedConfigInput, b: SharedConfigInput): boolean {\n const left = comparableSharedConfig(a);\n const right = comparableSharedConfig(b);\n return (\n left.version === right.version &&\n left.requiredVersion === right.requiredVersion &&\n left.singleton === right.singleton &&\n left.strictVersion === right.strictVersion &&\n left.eager === right.eager &&\n left.shareScope === right.shareScope\n );\n}\n\nexport function mergeSharedMaps(\n ...maps: Array<Record<string, SharedConfigInput> | undefined>\n): Record<string, SharedDependencyConfig> {\n const merged: Record<string, SharedDependencyConfig> = {};\n for (const map of maps) {\n if (!map) continue;\n for (const [name, config] of Object.entries(map)) {\n const normalized = normalizeSharedConfig(config, name);\n const existing = merged[name];\n if (existing && !isSameSharedConfig(existing, normalized)) {\n throw new Error(\n `Conflicting shared dependency \"${name}\" in shared dependency configuration`,\n );\n }\n merged[name] = normalized;\n }\n }\n return merged;\n}\n\nexport interface SharedVersionRecordEntry {\n version: string;\n singleton?: boolean;\n}\n\n/**\n * The `name → version` record of a build's shared-singleton map, for the\n * build report (and from there the version manifest's `shared` field) —\n * #546: a slot's pin must carry shared-dep semantics so consumers can detect\n * a build skew before loading. Singletons only — non-singletons never take\n * part in the negotiation a skew breaks.\n */\nexport function sharedVersionRecord(\n shared: Record<string, SharedVersionRecordEntry>,\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [name, config] of Object.entries(shared)) {\n if (config.singleton !== false && config.version) {\n out[name] = config.version;\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,IAAa,kCAAb,cAAqD,KAAK,YACxD,iCACF,CAAC,CAGE;CACD,YAAY,aAAqB,UAAoB;EACnD,MAAM;GACJ;GACA;EACF,CAAC;CACH;CAEA,IAAa,UAAU;EACrB,OACE,wCAAwC,KAAK,YAAY,mBACzD,KAAK,SAAS,KAAK,aAAa,OAAO,UAAU,CAAC,CAAC,KAAK,IAAI,IAC5D;CAGJ;AACF;AAYA,MAAa,mBAAmB;CAC9B;EAAE,MAAM;EAAgB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAO;CAC5E;EAAE,MAAM;EAAU,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CACzE;EAAE,MAAM;EAAO,WAAW;EAAM,UAAU;EAAO,YAAY;CAAU;CACvE;EAAE,MAAM;EAAkB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CACjF;EAAE,MAAM;EAAgB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CAC/E;EAAE,MAAM;EAAgB,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;AAQjF;AAIA,MAAM,oBAAoB,iBAAiB,SAAS,SAAU,KAAK,WAAW,CAAC,KAAK,IAAI,IAAI,CAAC,CAAE;;;;;;AAO/F,MAAa,8BACX;AAIF,MAAa,6BAA6B,SACvC,4BAAkD,SAAS,IAAI;AAElE,MAAa,iBAAiB;CAC5B;EAAE,MAAM;EAAS,WAAW;EAAM,UAAU;EAAM,YAAY;CAAU;CACxE;EAAE,MAAM;EAAa,WAAW;EAAM,UAAU;EAAM,YAAY;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ACqC;CACxC,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,CAAC,KAAK;EACV,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,GAAG,GAAG;GAChD,MAAM,aAAa,sBAAsB,QAAQ,IAAI;GACrD,MAAM,WAAW,OAAO;GACxB,IAAI,YAAY,CAAC,mBAAmB,UAAU,UAAU,GACtD,MAAM,IAAI,MACR,kCAAkC,KAAK,qCACzC;GAEF,OAAO,QAAQ;EACjB;CACF;CACA,OAAO;AACT;;;;;;;;AAcA,SAAgB,oBACd,QACwB;CACxB,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GAChD,IAAI,OAAO,cAAc,SAAS,OAAO,SACvC,IAAI,QAAQ,OAAO;CAGvB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"shared-deps-spec.mjs","names":[],"sources":["../src/shared-deps-spec.ts"],"sourcesContent":["/**\n * SharedDependencySpec: the one module owning shared-dependency names,\n * criticality, version resolution, and fallback policy across the Module\n * Federation graph. Four consumers derive from it — the rspack config\n * factory (plugin builds), the rsbuild config factory (ui remotes), the\n * runtime mf-config (the every-plugin MF instance), and the host's shared\n * pre-registration — so a name or criticality can never disagree between\n * them, and an unresolved version fails the build loudly instead of\n * silently degrading to \"*\"/\"latest\" (which disables the strict-singleton\n * guard).\n *\n * Lists:\n * - core: shared by the host and server-side plugin remotes (every-plugin,\n * effect, zod, @orpc/*). Effect-critical entries pin the exact installed\n * version (strictVersion) — the version-check machinery in\n * runtime/services/shared-identity.ts relies on it.\n * - ui: shared by the core ui provider and ui remotes (react, react-dom,\n * @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev\n * session/i18n subpath modules). Strict singletons; consumers add\n * `import: false`. Tolerant outliers (`critical: false` — sonner today)\n * keep a bundled fallback copy in consumers and waive requiredVersion, so\n * an old provider / new remote mix degrades to per-remote copies instead\n * of failing a share negotiation.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { Data } from \"effect\";\n\nconst require = createRequire(import.meta.url);\n\nexport class SharedDependencyResolutionError extends Data.TaggedError(\n \"SharedDependencyResolutionError\",\n)<{\n readonly packageName: string;\n readonly searched: string[];\n}> {\n constructor(packageName: string, searched: string[]) {\n super({\n packageName,\n searched,\n });\n }\n\n override get message() {\n return (\n `Could not resolve shared dependency \"${this.packageName}\". Looked in:\\n` +\n this.searched.map((location) => ` - ${location}`).join(\"\\n\") +\n `\\nUnresolved shared dependencies fail loudly (no \"*\", no \"latest\" fallback) — ` +\n `install the package in the resolving workspace or pin a resolvable version.`\n );\n }\n}\n\nexport type SharedDependencyResolution = \"self\" | \"package\" | \"subpath\";\n\nexport interface SharedDependencySpec {\n name: string;\n singleton: true;\n /** exact-version pin (requiredVersion = resolved version, strictVersion = true) */\n critical: boolean;\n resolution: SharedDependencyResolution;\n}\n\nexport const CORE_SHARED_DEPS = [\n { name: \"every-plugin\", singleton: true, critical: true, resolution: \"self\" },\n { name: \"effect\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"zod\", singleton: true, critical: false, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/server\", singleton: true, critical: true, resolution: \"package\" },\n // v1's proven sharing set, restored: @orpc/openapi, @orpc/experimental-effect,\n // and @orpc/publisher joined this list in the v2 fleet-spec pass and their\n // share-scope consumption broke plugin loading at runtime\n // (__webpack_modules__[r] is not a function — the runtime's import()-based\n // provides hand the consumer an ESM namespace where a module factory is\n // expected). They stay declared in each workspace's package.json and are\n // bundled per workspace instead.\n] as const satisfies readonly SharedDependencySpec[];\n\nexport type CoreSharedDepName = (typeof CORE_SHARED_DEPS)[number][\"name\"];\n\nconst coreCriticalNames = CORE_SHARED_DEPS.flatMap((spec) => (spec.critical ? [spec.name] : []));\n\n/**\n * Effect-critical shared names, derived from the core list's `critical: true`\n * entries — the one source of criticality (`strictVersion` pinning in the\n * runtime's version-check machinery keys off this list).\n */\nexport const EFFECT_CRITICAL_SHARED_DEPS: readonly EffectCriticalSharedDepName[] =\n coreCriticalNames;\n\nexport type EffectCriticalSharedDepName = (typeof coreCriticalNames)[number];\n\nexport const isEffectCriticalSharedDep = (name: string): boolean =>\n (EFFECT_CRITICAL_SHARED_DEPS as readonly string[]).includes(name);\n\nexport const UI_SHARED_DEPS = [\n { name: \"react\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"react-dom\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/client\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@orpc/contract\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-query\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@tanstack/react-router\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/core\", singleton: true, critical: true, resolution: \"package\" },\n { name: \"@lingui/react\", singleton: true, critical: true, resolution: \"package\" },\n {\n name: \"everything-dev/ui/auth\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n {\n name: \"everything-dev/ui/i18n\",\n singleton: true,\n critical: true,\n resolution: \"subpath\",\n },\n // Tolerant singleton: the mounted Toaster lives in the core ui's sonner\n // instance, so plugins must resolve the same module for their toast() calls\n // to render. critical:false keeps a bundled fallback copy in remotes — a\n // share negotiation against an old provider degrades to per-remote copies\n // instead of failing the import.\n {\n name: \"sonner\",\n singleton: true,\n critical: false,\n resolution: \"package\",\n },\n] as const satisfies readonly SharedDependencySpec[];\n\nexport const SHARED_DEP_SPECS: readonly SharedDependencySpec[] = (() => {\n const byName = new Map<string, SharedDependencySpec>();\n for (const spec of [...CORE_SHARED_DEPS, ...UI_SHARED_DEPS]) {\n const existing = byName.get(spec.name);\n if (existing) {\n if (existing.critical !== spec.critical) {\n throw new Error(\n `Shared dependency spec conflict for \"${spec.name}\": criticality disagrees between the core and ui lists`,\n );\n }\n continue;\n }\n byName.set(spec.name, spec);\n }\n return [...byName.values()];\n})();\n\nexport interface SharedDependencyConfig {\n version: string;\n requiredVersion: string | false;\n singleton: boolean;\n strictVersion: boolean;\n eager: boolean;\n shareScope: string;\n}\n\nexport type SharedDependencies = Record<string, SharedDependencyConfig>;\n\nexport type SharedConfigInput = {\n version: string;\n requiredVersion?: string | false;\n singleton?: boolean;\n strictVersion?: boolean;\n eager?: boolean;\n shareScope?: string;\n};\n\nexport interface SharedDependencyResolutionOptions {\n /** the building workspace to resolve from; default is this module's own location */\n workspaceRoot?: string;\n resolution?: \"package\" | \"subpath\";\n}\n\nfunction searchedNote(target: string): string {\n return `require.resolve(\"${target}\")`;\n}\n\nfunction findPackageJsonVersion(startDir: string, searched: string[]): string | null {\n let currentDir = startDir;\n for (let i = 0; i < 5; i += 1) {\n const packageJsonPath = join(currentDir, \"package.json\");\n searched.push(packageJsonPath);\n if (existsSync(packageJsonPath)) {\n try {\n const version = (JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n const parent = dirname(currentDir);\n if (parent === currentDir) break;\n currentDir = parent;\n }\n return null;\n}\n\nfunction resolveSubpathVersion(\n request: string,\n workspaceRoot: string | undefined,\n searched: string[],\n): string | null {\n if (request.startsWith(\"@\")) {\n throw new Error(\n `Scoped-package subpath \"${request}\" is not supported — subpath version resolution ` +\n `handles unscoped specifiers only (the known subpath specs, everything-dev/ui/*, are unscoped).`,\n );\n }\n const packageName = request.split(\"/\")[0] ?? request;\n const subpath = request.split(\"/\").slice(1).join(\"/\");\n const candidates: string[] = [];\n if (workspaceRoot) {\n candidates.push(join(workspaceRoot, \"node_modules\", packageName, \"package.json\"));\n }\n const resolveRequests: Array<{ request: string; paths?: string[] }> = [\n { request: `${packageName}/${subpath}`, ...(workspaceRoot ? { paths: [workspaceRoot] } : {}) },\n { request: `${packageName}/${subpath}` },\n {\n request: `${packageName}/package.json`,\n ...(workspaceRoot ? { paths: [workspaceRoot] } : {}),\n },\n { request: `${packageName}/package.json` },\n ];\n for (const { request: target, paths } of resolveRequests) {\n try {\n const resolved = require.resolve(target, paths ? { paths } : undefined);\n searched.push(resolved);\n candidates.push(\n resolved.endsWith(\"package.json\")\n ? resolved\n : resolve(dirname(resolved), \"..\", \"..\", \"package.json\"),\n );\n } catch {\n searched.push(searchedNote(target));\n }\n }\n for (const candidate of candidates) {\n if (!existsSync(candidate)) continue;\n try {\n const version = (JSON.parse(readFileSync(candidate, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {}\n }\n return null;\n}\n\nexport function resolveSharedVersion(\n name: string,\n options: SharedDependencyResolutionOptions = {},\n): string {\n const searched: string[] = [];\n const { workspaceRoot, resolution = \"package\" } = options;\n\n if (resolution === \"subpath\") {\n const version = resolveSubpathVersion(name, workspaceRoot, searched);\n if (version) return version;\n throw new SharedDependencyResolutionError(name, searched);\n }\n\n const roots: Array<string | undefined> = workspaceRoot ? [workspaceRoot, undefined] : [undefined];\n for (const root of roots) {\n try {\n const resolved = root ? require.resolve(name, { paths: [root] }) : require.resolve(name);\n searched.push(resolved);\n const version = findPackageJsonVersion(dirname(resolved), searched);\n if (version) return version;\n } catch {\n searched.push(searchedNote(name));\n }\n }\n throw new SharedDependencyResolutionError(name, searched);\n}\n\nfunction resolveOwnVersion(searched: string[]): string {\n const localPackageJson = join(dirname(fileURLToPath(import.meta.url)), \"..\", \"package.json\");\n searched.push(localPackageJson);\n if (existsSync(localPackageJson)) {\n try {\n const version = (JSON.parse(readFileSync(localPackageJson, \"utf8\")) as { version?: string })\n .version;\n if (version) return version;\n } catch {}\n }\n try {\n const resolved = require.resolve(\"every-plugin/package.json\");\n searched.push(resolved);\n const version = (JSON.parse(readFileSync(resolved, \"utf8\")) as { version?: string }).version;\n if (version) return version;\n } catch {\n searched.push(searchedNote(\"every-plugin/package.json\"));\n }\n throw new SharedDependencyResolutionError(\"every-plugin\", searched);\n}\n\nexport function shareConfigFor(\n spec: SharedDependencySpec,\n version: string,\n): Omit<SharedDependencyConfig, \"version\"> {\n return spec.critical\n ? {\n requiredVersion: version,\n singleton: true,\n strictVersion: true,\n eager: false,\n shareScope: \"default\",\n }\n : {\n requiredVersion: false,\n singleton: true,\n strictVersion: false,\n eager: false,\n shareScope: \"default\",\n };\n}\n\nexport interface SharedDepsBuildOptions {\n /** the every-plugin share version; default resolves the installed package.json */\n ownVersion?: string;\n}\n\nfunction specVersion(spec: SharedDependencySpec, options: SharedDepsBuildOptions): string {\n if (spec.resolution === \"self\") {\n return options.ownVersion ?? resolveOwnVersion([`own package.json of \"${spec.name}\"`]);\n }\n return resolveSharedVersion(spec.name, {\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n}\n\nexport function getPluginSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): SharedDependencies {\n return Object.fromEntries(\n CORE_SHARED_DEPS.map((spec) => {\n const version = specVersion(spec, options);\n return [spec.name, { version, ...shareConfigFor(spec, version) }];\n }),\n );\n}\n\nexport interface HostSharedEntry {\n version: string;\n shareScope: string;\n shareConfig: {\n singleton: boolean;\n requiredVersion: string | false;\n strictVersion: boolean;\n eager: boolean;\n };\n}\n\nexport function toHostSharedEntry(name: string, config: SharedConfigInput): HostSharedEntry {\n const normalized = normalizeSharedConfig(config, name);\n return {\n version: normalized.version,\n shareScope: normalized.shareScope,\n shareConfig: {\n singleton: normalized.singleton,\n requiredVersion: normalized.requiredVersion,\n strictVersion: normalized.strictVersion,\n eager: normalized.eager,\n },\n };\n}\n\n/**\n * The runtime mf-config's core shared map: the same entries\n * `getPluginSharedDependencies` assembles, shaped through the one host mapper\n * (`toHostSharedEntry`) so both consumers derive from a single entry type.\n */\nexport function buildMfCoreSharedDependencies(\n options: SharedDepsBuildOptions = {},\n): Record<string, HostSharedEntry> {\n return Object.fromEntries(\n Object.entries(getPluginSharedDependencies(options)).map(([name, config]) => [\n name,\n toHostSharedEntry(name, config),\n ]),\n );\n}\n\nexport interface UiSharedDepEntry {\n version: string;\n requiredVersion: string | false;\n singleton: true;\n strictVersion: boolean;\n eager: false;\n shareScope: \"default\";\n /** critical entries in consumer role only: no bundled fallback copy — the\n * provider provides; tolerant entries keep their own bundled copy so a\n * share negotiation against an old provider still imports */\n import?: false;\n}\n\nexport interface UiSharedDepsOptions {\n /** explicit core-shell parity opt-out for critical entries; default is the\n * strict singleton. Tolerant (`critical: false`) entries are never strict. */\n strictVersion?: boolean;\n role?: \"provider\" | \"consumer\";\n workspaceRoot?: string;\n}\n\nexport function createUiSharedDeps(\n options: UiSharedDepsOptions = {},\n): Record<string, UiSharedDepEntry> {\n const deps: Record<string, UiSharedDepEntry> = {};\n for (const spec of UI_SHARED_DEPS) {\n const version = resolveSharedVersion(spec.name, {\n workspaceRoot: options.workspaceRoot,\n resolution: spec.resolution === \"subpath\" ? \"subpath\" : \"package\",\n });\n const strict = spec.critical !== false && options.strictVersion !== false;\n deps[spec.name] = {\n version,\n requiredVersion: strict ? version : false,\n singleton: true,\n strictVersion: strict,\n eager: false,\n shareScope: \"default\",\n ...(options.role === \"consumer\" && strict ? { import: false as const } : {}),\n };\n }\n return deps;\n}\n\nconst UNRESOLVED_VERSIONS = new Set([\"*\", \"latest\", \"\"]);\n\nexport function assertResolvedSharedVersion(name: string, version: unknown): string {\n if (typeof version !== \"string\" || UNRESOLVED_VERSIONS.has(version.trim())) {\n throw new SharedDependencyResolutionError(name, [\n `declared version ${JSON.stringify(version ?? null)} is not resolvable — \"*\", \"latest\", and empty fail loudly instead of disabling the strict-singleton guard`,\n ]);\n }\n return version;\n}\n\nexport function normalizeSharedConfig(\n config: SharedConfigInput,\n name: string,\n): SharedDependencyConfig {\n const version = assertResolvedSharedVersion(name, config.version);\n return {\n version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nfunction comparableSharedConfig(config: SharedConfigInput) {\n return {\n version: config.version,\n requiredVersion: config.requiredVersion ?? false,\n singleton: config.singleton ?? false,\n strictVersion: config.strictVersion ?? false,\n eager: config.eager ?? false,\n shareScope: config.shareScope ?? \"default\",\n };\n}\n\nexport function isSameSharedConfig(a: SharedConfigInput, b: SharedConfigInput): boolean {\n const left = comparableSharedConfig(a);\n const right = comparableSharedConfig(b);\n return (\n left.version === right.version &&\n left.requiredVersion === right.requiredVersion &&\n left.singleton === right.singleton &&\n left.strictVersion === right.strictVersion &&\n left.eager === right.eager &&\n left.shareScope === right.shareScope\n );\n}\n\nexport function mergeSharedMaps(\n ...maps: Array<Record<string, SharedConfigInput> | undefined>\n): Record<string, SharedDependencyConfig> {\n const merged: Record<string, SharedDependencyConfig> = {};\n for (const map of maps) {\n if (!map) continue;\n for (const [name, config] of Object.entries(map)) {\n const normalized = normalizeSharedConfig(config, name);\n const existing = merged[name];\n if (existing && !isSameSharedConfig(existing, normalized)) {\n throw new Error(\n `Conflicting shared dependency \"${name}\" in shared dependency configuration`,\n );\n }\n merged[name] = normalized;\n }\n }\n return merged;\n}\n\nexport interface SharedVersionRecordEntry {\n version: string;\n singleton?: boolean;\n}\n\n/**\n * The `name → version` record of a build's shared-singleton map, for the\n * build report (and from there the version manifest's `shared` field) —\n * #546: a slot's pin must carry shared-dep semantics so consumers can detect\n * a build skew before loading. Singletons only — non-singletons never take\n * part in the negotiation a skew breaks.\n */\nexport function sharedVersionRecord(\n shared: Record<string, SharedVersionRecordEntry>,\n): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [name, config] of Object.entries(shared)) {\n if (config.singleton !== false && config.version) {\n out[name] = config.version;\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,IAAa,kCAAb,cAAqD,KAAK,YACxD,iCACF,CAAC,C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ACtD,MAAM,IAAI,MACR,kCAAkC,KAAK,qCACzC;GAEF,OAAO,QAAQ;EACjB;CACF;CACA,OAAO;AACT;;;;;;;;AAcA,SAAgB,oBACd,QACwB;CACxB,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GAChD,IAAI,OAAO,cAAc,SAAS,OAAO,SACvC,IAAI,QAAQ,OAAO;CAGvB,OAAO;AACT"}
|
package/package.json
CHANGED
package/src/shared-deps-spec.ts
CHANGED
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
* runtime/services/shared-identity.ts relies on it.
|
|
17
17
|
* - ui: shared by the core ui provider and ui remotes (react, react-dom,
|
|
18
18
|
* @orpc/client, @orpc/contract, TanStack, lingui, the everything-dev
|
|
19
|
-
* session/i18n subpath modules).
|
|
20
|
-
* `import: false`.
|
|
19
|
+
* session/i18n subpath modules). Strict singletons; consumers add
|
|
20
|
+
* `import: false`. Tolerant outliers (`critical: false` — sonner today)
|
|
21
|
+
* keep a bundled fallback copy in consumers and waive requiredVersion, so
|
|
22
|
+
* an old provider / new remote mix degrades to per-remote copies instead
|
|
23
|
+
* of failing a share negotiation.
|
|
21
24
|
*/
|
|
22
25
|
import { existsSync, readFileSync } from "node:fs";
|
|
23
26
|
import { createRequire } from "node:module";
|
|
@@ -114,6 +117,17 @@ export const UI_SHARED_DEPS = [
|
|
|
114
117
|
critical: true,
|
|
115
118
|
resolution: "subpath",
|
|
116
119
|
},
|
|
120
|
+
// Tolerant singleton: the mounted Toaster lives in the core ui's sonner
|
|
121
|
+
// instance, so plugins must resolve the same module for their toast() calls
|
|
122
|
+
// to render. critical:false keeps a bundled fallback copy in remotes — a
|
|
123
|
+
// share negotiation against an old provider degrades to per-remote copies
|
|
124
|
+
// instead of failing the import.
|
|
125
|
+
{
|
|
126
|
+
name: "sonner",
|
|
127
|
+
singleton: true,
|
|
128
|
+
critical: false,
|
|
129
|
+
resolution: "package",
|
|
130
|
+
},
|
|
117
131
|
] as const satisfies readonly SharedDependencySpec[];
|
|
118
132
|
|
|
119
133
|
export const SHARED_DEP_SPECS: readonly SharedDependencySpec[] = (() => {
|
|
@@ -373,12 +387,15 @@ export interface UiSharedDepEntry {
|
|
|
373
387
|
strictVersion: boolean;
|
|
374
388
|
eager: false;
|
|
375
389
|
shareScope: "default";
|
|
376
|
-
/** consumer role only: no bundled fallback copy — the
|
|
390
|
+
/** critical entries in consumer role only: no bundled fallback copy — the
|
|
391
|
+
* provider provides; tolerant entries keep their own bundled copy so a
|
|
392
|
+
* share negotiation against an old provider still imports */
|
|
377
393
|
import?: false;
|
|
378
394
|
}
|
|
379
395
|
|
|
380
396
|
export interface UiSharedDepsOptions {
|
|
381
|
-
/** explicit core-shell parity opt-out; default is the
|
|
397
|
+
/** explicit core-shell parity opt-out for critical entries; default is the
|
|
398
|
+
* strict singleton. Tolerant (`critical: false`) entries are never strict. */
|
|
382
399
|
strictVersion?: boolean;
|
|
383
400
|
role?: "provider" | "consumer";
|
|
384
401
|
workspaceRoot?: string;
|
|
@@ -393,7 +410,7 @@ export function createUiSharedDeps(
|
|
|
393
410
|
workspaceRoot: options.workspaceRoot,
|
|
394
411
|
resolution: spec.resolution === "subpath" ? "subpath" : "package",
|
|
395
412
|
});
|
|
396
|
-
const strict = options.strictVersion !== false;
|
|
413
|
+
const strict = spec.critical !== false && options.strictVersion !== false;
|
|
397
414
|
deps[spec.name] = {
|
|
398
415
|
version,
|
|
399
416
|
requiredVersion: strict ? version : false,
|
|
@@ -401,7 +418,7 @@ export function createUiSharedDeps(
|
|
|
401
418
|
strictVersion: strict,
|
|
402
419
|
eager: false,
|
|
403
420
|
shareScope: "default",
|
|
404
|
-
...(options.role === "consumer" ? { import: false as const } : {}),
|
|
421
|
+
...(options.role === "consumer" && strict ? { import: false as const } : {}),
|
|
405
422
|
};
|
|
406
423
|
}
|
|
407
424
|
return deps;
|