From a8ce8929096fc6ba40ea96e9fbe4229c2a3492fb Mon Sep 17 00:00:00 2001 From: Vincent Koc <25068+vincentkoc@users.noreply.github.com> Date: Sat, 11 Jul 2026 17:45:29 +0800 Subject: [PATCH] fix(release): keep plugin pack output machine-readable --- scripts/lib/plugin-npm-package-manifest.mjs | 2 +- test/plugin-npm-package-manifest.test.ts | 45 ++++++++++++++++----- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/scripts/lib/plugin-npm-package-manifest.mjs b/scripts/lib/plugin-npm-package-manifest.mjs index 2f69dee7eec3..52ebb3460f3d 100644 --- a/scripts/lib/plugin-npm-package-manifest.mjs +++ b/scripts/lib/plugin-npm-package-manifest.mjs @@ -295,7 +295,7 @@ function installMissingOptionalBundledDependencies(params) { { cwd: params.packageDir, env: process.env, - stdio: ["ignore", "inherit", "inherit"], + stdio: ["ignore", "ignore", "inherit"], }, ); if (result.error) { diff --git a/test/plugin-npm-package-manifest.test.ts b/test/plugin-npm-package-manifest.test.ts index 32e41cc8ff32..c7c084f797e4 100644 --- a/test/plugin-npm-package-manifest.test.ts +++ b/test/plugin-npm-package-manifest.test.ts @@ -446,15 +446,42 @@ describe("plugin npm package manifest staging", () => { }); const nodeModulesPath = join(packageDir, "node_modules"); - withAugmentedPluginNpmManifestForPackage( - { repoRoot: repoDir, packageDir, bundleDependencies: true }, - () => { - expect(existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))).toBe(true); - expect(existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))).toBe( - true, - ); - }, - ); + const manifestModuleUrl = new URL( + "../scripts/lib/plugin-npm-package-manifest.mjs", + import.meta.url, + ).href; + const childSource = ` +import { existsSync } from "node:fs"; +import { join } from "node:path"; +import { withAugmentedPluginNpmManifestForPackage } from ${JSON.stringify(manifestModuleUrl)}; + +const packageDir = ${JSON.stringify(packageDir)}; +const nodeModulesPath = ${JSON.stringify(nodeModulesPath)}; +withAugmentedPluginNpmManifestForPackage( + { + repoRoot: ${JSON.stringify(repoDir)}, + packageDir, + bundleDependencies: true, + }, + () => { + if (!existsSync(join(nodeModulesPath, "local-runtime-dep", "package.json"))) { + throw new Error("missing bundled runtime dependency"); + } + if (!existsSync(join(nodeModulesPath, "optional-platform-dep", "package.json"))) { + throw new Error("missing portable optional bundled dependency"); + } + process.stdout.write("pack-json\\n"); + }, +); +`; + const result = spawnSync(process.execPath, ["--input-type=module", "--eval", childSource], { + cwd: repoDir, + encoding: "utf8", + env: process.env, + }); + + expect(result.status, result.stderr).toBe(0); + expect(result.stdout).toBe("pack-json\n"); expect(existsSync(nodeModulesPath)).toBe(false); });