


























@@ -19,6 +19,7 @@ const ROOT_RUNTIME_ALIAS_PATTERN = /^(?<base>.+\.(?:runtime|contract))-[A-Za-z0-
1919const ROOT_STABLE_RUNTIME_ALIAS_PATTERN = /^.+\.(?:runtime|contract)\.js$/u;
2020const ROOT_RUNTIME_IMPORT_SPECIFIER_PATTERN =
2121/(["'])\.\/([^"']+\.(?:runtime|contract)-[A-Za-z0-9_-]+\.js)\1/gu;
22+const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
2223const LEGACY_ROOT_RUNTIME_COMPAT_ALIASES = [
2324// v2026.4.29 dispatch lazy chunks. Package updates used to replace the
2425// dist tree before the live gateway had restarted, so an already-loaded old
@@ -45,6 +46,77 @@ const LEGACY_ROOT_RUNTIME_COMPAT_ALIASES = [
4546["provider-dispatcher-BpL2E92x.js", "provider-dispatcher.runtime.js"],
4647["provider-dispatcher-JG96SkLX.js", "provider-dispatcher.runtime.js"],
4748];
49+const LEGACY_PLUGIN_INSTALL_RUNTIME_MARKERS = [
50+"scanPackageInstallSource",
51+"scanFileInstallSource",
52+"scanInstalledPackageDependencyTree",
53+"scanBundleInstallSource",
54+];
55+const PLUGIN_INSTALL_RUNTIME_ALIAS = {
56+aliasFileName: "install.runtime.js",
57+sourceIncludes: LEGACY_PLUGIN_INSTALL_RUNTIME_MARKERS,
58+};
59+const LEGACY_PLUGIN_INSTALL_RUNTIME_COMPAT_ALIASES = [
60+// Published releases from v2026.3.22 onward. Older updaters could
61+// overlay package dist instead of swapping it, leaving old install chunks
62+// that still import these hashed plugin install runtime files.
63+"install.runtime-D7SL02B2.js",
64+"install.runtime-Deq6Beal.js",
65+"install.runtime-Eoq8y3HE.js",
66+"install.runtime-DDmlaKdG.js",
67+"install.runtime-ADTafpVD.js",
68+"install.runtime-v8X-j3Tm.js",
69+"install.runtime-BLcZ-44g.js",
70+"install.runtime-vS4aFJvO.js",
71+"install.runtime-Dm_c092A.js",
72+"install.runtime-D_7OUvuY.js",
73+"install.runtime-BLEE0OIk.js",
74+"install.runtime-3LpjZbr8.js",
75+"install.runtime-BrsB9OnV.js",
76+"install.runtime-BEOb-kNW.js",
77+"install.runtime-Cx_xphd1.js",
78+"install.runtime-B-MtEMSR.js",
79+"install.runtime-C-Y4HAqX.js",
80+"install.runtime-j1SedTZh.js",
81+"install.runtime-4zsL_8wt.js",
82+"install.runtime-BhCKlLSJ.js",
83+"install.runtime-tGJ0KhMF.js",
84+"install.runtime-DtmATpak.js",
85+"install.runtime-BzZ38ePb.js",
86+"install.runtime-DwQr7nEE.js",
87+"install.runtime-CEIURnUz.js",
88+"install.runtime-D3EPlM0r.js",
89+"install.runtime-DIlN5H3O.js",
90+"install.runtime-DjcOwVH_.js",
91+"install.runtime-B13jZink.js",
92+"install.runtime-O8MXNrwm.js",
93+"install.runtime-Bkf_VMnk.js",
94+"install.runtime-QOfEzAcZ.js",
95+"install.runtime-BRVACueI.js",
96+"install.runtime-DX8jy7tN.js",
97+"install.runtime-BdfsTamp.js",
98+"install.runtime-B6OA2_P8.js",
99+"install.runtime-D9cTH-C0.js",
100+"install.runtime-OCJULXQo.js",
101+"install.runtime-9ZXBhZSk.js",
102+"install.runtime-DlL3C3t_.js",
103+"install.runtime-TU-jP-TN.js",
104+"install.runtime-a2FlfOSp.js",
105+"install.runtime-BwuRABU1.js",
106+"install.runtime-B3mZL_R2.js",
107+"install.runtime-CWUzypNQ.js",
108+"install.runtime-D6FSd9v2.js",
109+"install.runtime-DQ-ui3nL.js",
110+"install.runtime-CNHwKOIb.js",
111+"install.runtime-Dzuj9tSw.js",
112+"install.runtime-BuF-YAfQ.js",
113+"install.runtime-Xom5hOHq.js",
114+"install.runtime-tnhNR9WW.js",
115+].map((legacyFileName) => ({
116+ legacyFileName,
117+aliasFileName: PLUGIN_INSTALL_RUNTIME_ALIAS.aliasFileName,
118+sourceIncludes: LEGACY_PLUGIN_INSTALL_RUNTIME_MARKERS,
119+}));
48120const LEGACY_CLI_EXIT_COMPAT_CHUNKS = [
49121{
50122dest: "dist/memory-state-CcqRgDZU.js",
@@ -82,10 +154,18 @@ export function writeStableRootRuntimeAliases(params = {}) {
82154candidatesByAlias.set(aliasFileName, candidates);
83155}
8415685-const resolveAliasCandidate = (candidates) => {
157+const resolveAliasCandidate = (aliasFileName, candidates) => {
86158if (candidates.length === 1) {
87159return candidates[0];
88160}
161+if (aliasFileName === PLUGIN_INSTALL_RUNTIME_ALIAS.aliasFileName) {
162+return resolveRootRuntimeCandidateByMarkers({
163+ distDir,
164+ fsImpl,
165+ aliasFileName,
166+sourceIncludes: PLUGIN_INSTALL_RUNTIME_ALIAS.sourceIncludes,
167+});
168+}
89169const candidateSet = new Set(candidates);
90170const wrappers = candidates.filter((candidate) => {
91171const filePath = path.join(distDir, candidate);
@@ -108,7 +188,7 @@ export function writeStableRootRuntimeAliases(params = {}) {
108188109189for (const [aliasFileName, candidates] of candidatesByAlias) {
110190const aliasPath = path.join(distDir, aliasFileName);
111-const candidate = resolveAliasCandidate(candidates);
191+const candidate = resolveAliasCandidate(aliasFileName, candidates);
112192if (!candidate) {
113193fsImpl.rmSync?.(aliasPath, { force: true });
114194continue;
@@ -143,10 +223,21 @@ export function rewriteRootRuntimeImportsToStableAliases(params = {}) {
143223}
144224const runtimeAliasFiles = new Map();
145225for (const [aliasFileName, candidates] of candidatesByAlias) {
146-if (candidates.length !== 1) {
226+if (candidates.length === 1) {
227+runtimeAliasFiles.set(candidates[0], aliasFileName);
147228continue;
148229}
149-runtimeAliasFiles.set(candidates[0], aliasFileName);
230+if (aliasFileName === PLUGIN_INSTALL_RUNTIME_ALIAS.aliasFileName) {
231+const candidate = resolveRootRuntimeCandidateByMarkers({
232+ distDir,
233+ fsImpl,
234+ aliasFileName,
235+sourceIncludes: PLUGIN_INSTALL_RUNTIME_ALIAS.sourceIncludes,
236+});
237+if (candidate) {
238+runtimeAliasFiles.set(candidate, aliasFileName);
239+}
240+}
150241}
151242if (runtimeAliasFiles.size === 0) {
152243return;
@@ -179,19 +270,87 @@ export function rewriteRootRuntimeImportsToStableAliases(params = {}) {
179270}
180271}
181272273+function resolveRootRuntimeCandidateByMarkers(params) {
274+if (!params.sourceIncludes?.length) {
275+return null;
276+}
277+const match = params.aliasFileName.match(ROOT_STABLE_RUNTIME_ALIAS_PATTERN);
278+if (!match) {
279+return null;
280+}
281+const aliasBaseFileName = params.aliasFileName.replace(/\.js$/u, "");
282+const hashedPattern = new RegExp(`^${escapeRegExp(aliasBaseFileName)}-[A-Za-z0-9_-]+\\.js$`, "u");
283+let entries = [];
284+try {
285+entries = params.fsImpl.readdirSync(params.distDir, { withFileTypes: true });
286+} catch {
287+return null;
288+}
289+const candidates = [];
290+for (const entry of entries.toSorted((left, right) => left.name.localeCompare(right.name))) {
291+if (!entry.isFile() || !hashedPattern.test(entry.name)) {
292+continue;
293+}
294+const candidatePath = path.join(params.distDir, entry.name);
295+let source;
296+try {
297+source = params.fsImpl.readFileSync(candidatePath, "utf8");
298+} catch {
299+continue;
300+}
301+if (params.sourceIncludes.every((marker) => source.includes(marker))) {
302+candidates.push(entry.name);
303+}
304+}
305+return candidates.length === 1 ? candidates[0] : null;
306+}
307+308+function resolveLegacyRootRuntimeCompatTarget(params) {
309+if (
310+params.aliasFileName &&
311+params.fsImpl.existsSync(path.join(params.distDir, params.aliasFileName))
312+) {
313+return params.aliasFileName;
314+}
315+const match = params.legacyFileName.match(ROOT_RUNTIME_ALIAS_PATTERN);
316+if (!match?.groups?.base) {
317+return null;
318+}
319+return resolveRootRuntimeCandidateByMarkers({
320+distDir: params.distDir,
321+fsImpl: params.fsImpl,
322+aliasFileName: `${match.groups.base}.js`,
323+sourceIncludes: params.sourceIncludes,
324+});
325+}
326+182327export function writeLegacyRootRuntimeCompatAliases(params = {}) {
183328const rootDir = params.rootDir ?? ROOT;
184329const distDir = path.join(rootDir, "dist");
185330const fsImpl = params.fs ?? fs;
186-for (const [legacyFileName, aliasFileName] of LEGACY_ROOT_RUNTIME_COMPAT_ALIASES) {
331+for (const entry of [
332+ ...LEGACY_ROOT_RUNTIME_COMPAT_ALIASES.map(([legacyFileName, aliasFileName]) => ({
333+ legacyFileName,
334+ aliasFileName,
335+})),
336+ ...LEGACY_PLUGIN_INSTALL_RUNTIME_COMPAT_ALIASES,
337+]) {
338+const { legacyFileName } = entry;
187339const legacyPath = path.join(distDir, legacyFileName);
188340if (fsImpl.existsSync(legacyPath)) {
189341continue;
190342}
191-if (!fsImpl.existsSync(path.join(distDir, aliasFileName))) {
343+const targetFileName = resolveLegacyRootRuntimeCompatTarget({
344+ distDir,
345+ fsImpl,
346+ legacyFileName,
347+aliasFileName: entry.aliasFileName,
348+sourceIncludes: entry.sourceIncludes,
349+});
350+if (!targetFileName) {
192351continue;
193352}
194-writeTextFileIfChanged(legacyPath, `export * from "./${aliasFileName}";\n`);
353+writeTextFileIfChanged(legacyPath, `export * from "./${targetFileName}";\n`);
195354}
196355}
197356此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。