fix: tolerate pnpm-backed runtime dependency installs

This commit is contained in:
Peter Steinberger
2026-04-21 06:57:45 +01:00
parent 05ba1335d9
commit 494cd78889
5 changed files with 94 additions and 53 deletions

View File

@@ -465,6 +465,19 @@ export function createNestedNpmInstallEnv(env = process.env) {
return nextEnv;
}
export function createBundledRuntimeDependencyInstallEnv(env = process.env) {
return {
...createNestedNpmInstallEnv(env),
npm_config_legacy_peer_deps: "true",
npm_config_package_lock: "false",
npm_config_save: "false",
};
}
export function createBundledRuntimeDependencyInstallArgs(missingSpecs) {
return ["install", "--ignore-scripts", ...missingSpecs];
}
function shouldEagerInstallBundledPluginDeps(env = process.env) {
return env?.[EAGER_BUNDLED_PLUGIN_DEPS_ENV]?.trim() === "1";
}
@@ -756,28 +769,21 @@ export function runBundledPluginPostinstall(params = {}) {
}
try {
const nestedEnv = createNestedNpmInstallEnv(env);
const installEnv = createBundledRuntimeDependencyInstallEnv(env);
const npmRunner =
params.npmRunner ??
resolveNpmRunner({
env: nestedEnv,
env: installEnv,
execPath: params.execPath,
existsSync: pathExists,
platform: params.platform,
comSpec: params.comSpec,
npmArgs: [
"install",
"--omit=dev",
"--no-save",
"--package-lock=false",
"--legacy-peer-deps",
...missingSpecs,
],
npmArgs: createBundledRuntimeDependencyInstallArgs(missingSpecs),
});
const result = spawn(npmRunner.command, npmRunner.args, {
cwd: packageRoot,
encoding: "utf8",
env: npmRunner.env ?? nestedEnv,
env: npmRunner.env ?? installEnv,
stdio: "pipe",
shell: npmRunner.shell,
windowsVerbatimArguments: npmRunner.windowsVerbatimArguments,

View File

@@ -829,8 +829,11 @@ function runNpmInstall(params) {
CI: "1",
npm_config_audit: "false",
npm_config_fund: "false",
npm_config_legacy_peer_deps: "true",
npm_config_loglevel: "error",
npm_config_package_lock: "false",
npm_config_progress: "false",
npm_config_save: "false",
npm_config_yes: "true",
};
const result = spawnSync(params.npmRunner.command, params.npmRunner.args, {
@@ -1045,16 +1048,7 @@ function installPluginRuntimeDeps(params) {
runNpmInstall({
cwd: tempInstallDir,
npmRunner: resolveNpmRunner({
npmArgs: [
"install",
"--omit=dev",
"--no-audit",
"--no-fund",
"--ignore-scripts",
"--legacy-peer-deps",
"--package-lock=false",
"--silent",
],
npmArgs: ["install", "--no-audit", "--no-fund", "--ignore-scripts", "--silent"],
}),
});
}