
























@@ -3,6 +3,7 @@ import fs from "node:fs";
33import path from "node:path";
44import { pathToFileURL } from "node:url";
55import JSON5 from "json5";
6+import { packageJsonForShrinkwrap, readShrinkwrapOverrides } from "../generate-npm-shrinkwrap.mjs";
67import {
78listPluginNpmRuntimeBuildOutputs,
89resolvePluginNpmRuntimeBuildPlan,
@@ -351,32 +352,43 @@ function installPackageLocalBundledDependencies(params) {
351352}
352353353354console.error(`[plugin-npm-publish] installing bundled dependencies for ${params.pluginDir}`);
354-const result = spawnNpmSync(
355-[
356-"ci",
357-"--omit=dev",
358-"--omit=peer",
359-"--legacy-peer-deps",
360-"--ignore-scripts",
361-"--no-audit",
362-"--no-fund",
363-"--loglevel=error",
364-],
365-{
366-cwd: params.packageDir,
367-env: process.env,
368-stdio: ["ignore", "ignore", "inherit"],
369-},
370-);
371-if (result.error) {
372-throw result.error;
373-}
374-if ((result.status ?? 1) !== 0) {
375-throw new Error(
376-`package-local bundled dependency install failed for ${params.pluginDir} with exit ${result.status ?? 1}`,
355+const packageJsonPath = resolvePackageJsonPath(params.packageDir);
356+const publishPackageJsonText = fs.readFileSync(packageJsonPath, "utf8");
357+try {
358+const installPackageJson = packageJsonForShrinkwrap(packageJson, readShrinkwrapOverrides());
359+const installPackageJsonText = `${JSON.stringify(installPackageJson, null, 2)}\n`;
360+if (installPackageJsonText !== publishPackageJsonText) {
361+fs.writeFileSync(packageJsonPath, installPackageJsonText, "utf8");
362+}
363+const result = spawnNpmSync(
364+[
365+"ci",
366+"--omit=dev",
367+"--omit=peer",
368+"--legacy-peer-deps",
369+"--ignore-scripts",
370+"--no-audit",
371+"--no-fund",
372+"--loglevel=error",
373+],
374+{
375+cwd: params.packageDir,
376+env: process.env,
377+stdio: ["ignore", "ignore", "inherit"],
378+},
377379);
380+if (result.error) {
381+throw result.error;
382+}
383+if ((result.status ?? 1) !== 0) {
384+throw new Error(
385+`package-local bundled dependency install failed for ${params.pluginDir} with exit ${result.status ?? 1}`,
386+);
387+}
388+installMissingOptionalBundledDependencies(params);
389+} finally {
390+fs.writeFileSync(packageJsonPath, publishPackageJsonText, "utf8");
378391}
379-installMissingOptionalBundledDependencies(params);
380392return () => {
381393fs.rmSync(nodeModulesPath, { recursive: true, force: true });
382394};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。