From ea7124a13ee9d4244eb27e1012135f5eca357dab Mon Sep 17 00:00:00 2001 From: Linfang Wang Date: Mon, 20 Apr 2026 19:38:08 +0800 Subject: [PATCH 1/2] release: prune staged runtime bin shims --- scripts/stage-bundled-plugin-runtime-deps.mjs | 24 +++++++++++++++++++ .../stage-bundled-plugin-runtime-deps.test.ts | 7 ++++++ 2 files changed, 31 insertions(+) diff --git a/scripts/stage-bundled-plugin-runtime-deps.mjs b/scripts/stage-bundled-plugin-runtime-deps.mjs index 1431bce8fc68b..9d67edee38efb 100644 --- a/scripts/stage-bundled-plugin-runtime-deps.mjs +++ b/scripts/stage-bundled-plugin-runtime-deps.mjs @@ -489,6 +489,29 @@ function pruneDependencyFilesBySuffixes(depRoot, suffixes) { }); } +function pruneNodeModulesBinDirectories(nodeModulesDir) { + if (!fs.existsSync(nodeModulesDir)) { + return; + } + const pending = [nodeModulesDir]; + while (pending.length > 0) { + const currentDir = pending.shift(); + if (!currentDir || !fs.existsSync(currentDir)) { + continue; + } + for (const entry of fs.readdirSync(currentDir, { withFileTypes: true })) { + const entryPath = path.join(currentDir, entry.name); + if (entry.name === ".bin") { + removePathIfExists(entryPath); + continue; + } + if (entry.isDirectory()) { + pending.push(entryPath); + } + } + } +} + function pruneStagedInstalledDependencyCargo(nodeModulesDir, depName, pruneConfig) { const depRoot = dependencyNodeModulesPath(nodeModulesDir, depName); if (depRoot === null) { @@ -526,6 +549,7 @@ function listInstalledDependencyNames(nodeModulesDir) { } function pruneStagedRuntimeDependencyCargo(nodeModulesDir, pruneConfig) { + pruneNodeModulesBinDirectories(nodeModulesDir); for (const depName of listInstalledDependencyNames(nodeModulesDir)) { pruneStagedInstalledDependencyCargo(nodeModulesDir, depName, pruneConfig); } diff --git a/test/scripts/stage-bundled-plugin-runtime-deps.test.ts b/test/scripts/stage-bundled-plugin-runtime-deps.test.ts index ae6d5b6b2bc9b..153968ec289c3 100644 --- a/test/scripts/stage-bundled-plugin-runtime-deps.test.ts +++ b/test/scripts/stage-bundled-plugin-runtime-deps.test.ts @@ -771,8 +771,14 @@ describe("stageBundledPluginRuntimeDeps", () => { fs.writeFileSync(path.join(gifwrapDir, "test", "fixtures", "large.gif"), "fixture\n", "utf8"); const playwrightDir = writePackage("playwright-core"); fs.mkdirSync(path.join(playwrightDir, "types"), { recursive: true }); + fs.mkdirSync(path.join(rootNodeModules, ".bin"), { recursive: true }); fs.writeFileSync(path.join(playwrightDir, "types", "types.d.ts"), "export {};\n", "utf8"); fs.writeFileSync(path.join(playwrightDir, "index.js"), "export {};\n", "utf8"); + fs.writeFileSync(path.join(playwrightDir, "cli.js"), "export {};\n", "utf8"); + fs.symlinkSync( + path.join("..", "playwright-core", "cli.js"), + path.join(rootNodeModules, ".bin", "playwright-core"), + ); const jimpDir = writePackage("@jimp/plugin-blit"); fs.mkdirSync(path.join(jimpDir, "src", "__image_snapshots__"), { recursive: true }); fs.writeFileSync( @@ -794,6 +800,7 @@ describe("stageBundledPluginRuntimeDeps", () => { expect(fs.existsSync(path.join(pluginDir, "node_modules", "playwright-core", "index.js"))).toBe( true, ); + expect(fs.existsSync(path.join(pluginDir, "node_modules", ".bin"))).toBe(false); expect( fs.existsSync( path.join(pluginDir, "node_modules", "@jimp", "plugin-blit", "src", "__image_snapshots__"), From ca43b0199eb982e693eff15719c08aaba6c16ee5 Mon Sep 17 00:00:00 2001 From: Linfang Wang Date: Mon, 20 Apr 2026 19:45:17 +0800 Subject: [PATCH 2/2] Update scripts/stage-bundled-plugin-runtime-deps.mjs Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- scripts/stage-bundled-plugin-runtime-deps.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/stage-bundled-plugin-runtime-deps.mjs b/scripts/stage-bundled-plugin-runtime-deps.mjs index 9d67edee38efb..310cf004fe275 100644 --- a/scripts/stage-bundled-plugin-runtime-deps.mjs +++ b/scripts/stage-bundled-plugin-runtime-deps.mjs @@ -495,8 +495,8 @@ function pruneNodeModulesBinDirectories(nodeModulesDir) { } const pending = [nodeModulesDir]; while (pending.length > 0) { - const currentDir = pending.shift(); - if (!currentDir || !fs.existsSync(currentDir)) { + const currentDir = pending.pop(); + if (!fs.existsSync(currentDir)) { continue; } for (const entry of fs.readdirSync(currentDir, { withFileTypes: true })) {