fix: prefer bundled channel plugins over npm duplicates (#40094)

* fix: prefer bundled channel plugins over npm duplicates

* fix: tighten bundled plugin review follow-ups

* fix: address check gate follow-ups

* docs: add changelog for bundled plugin install fix

* fix: align lifecycle test formatting with CI oxfmt
This commit is contained in:
Tak Hoffman
2026-03-08 13:00:24 -05:00
committed by GitHub
parent 6c9b49a10b
commit 74624e619d
9 changed files with 343 additions and 50 deletions

View File

@@ -459,42 +459,26 @@ export async function syncPluginsForUpdateChannel(params: {
if (!pathsEqual(record.sourcePath, bundledInfo.localPath)) {
continue;
}
const spec = record.spec ?? bundledInfo.npmSpec;
if (!spec) {
summary.warnings.push(`Missing npm spec for ${pluginId}; keeping local path.`);
continue;
}
let result: Awaited<ReturnType<typeof installPluginFromNpmSpec>>;
try {
result = await installPluginFromNpmSpec({
spec,
mode: "update",
expectedPluginId: pluginId,
logger: params.logger,
});
} catch (err) {
summary.errors.push(`Failed to install ${pluginId}: ${String(err)}`);
continue;
}
if (!result.ok) {
summary.errors.push(`Failed to install ${pluginId}: ${result.error}`);
// Keep explicit bundled installs on release channels. Replacing them with
// npm installs can reintroduce duplicate-id shadowing and packaging drift.
loadHelpers.addPath(bundledInfo.localPath);
const alreadyBundled =
record.source === "path" &&
pathsEqual(record.sourcePath, bundledInfo.localPath) &&
pathsEqual(record.installPath, bundledInfo.localPath);
if (alreadyBundled) {
continue;
}
next = recordPluginInstall(next, {
pluginId,
source: "npm",
spec,
installPath: result.targetDir,
version: result.version,
...buildNpmResolutionInstallFields(result.npmResolution),
sourcePath: undefined,
source: "path",
sourcePath: bundledInfo.localPath,
installPath: bundledInfo.localPath,
spec: record.spec ?? bundledInfo.npmSpec,
version: record.version,
});
summary.switchedToNpm.push(pluginId);
changed = true;
loadHelpers.removePath(bundledInfo.localPath);
}
}