From 60e3ef657b5f9e7380a077c20bbe040a42109722 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 23 Jul 2026 15:26:05 +0000 Subject: [PATCH] fix(release): stage bundled packages without registry workspace fetches Co-Authored-By: Paperclip --- scripts/acpx-patch-packaging.test.mjs | 2 ++ scripts/prepare-bundled-package.mjs | 34 +++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/scripts/acpx-patch-packaging.test.mjs b/scripts/acpx-patch-packaging.test.mjs index ea632652f9e..3bd10607641 100644 --- a/scripts/acpx-patch-packaging.test.mjs +++ b/scripts/acpx-patch-packaging.test.mjs @@ -79,6 +79,8 @@ test("bundled package staging rebuilds npm dependencies and applies the acpx pat const binDir = join(fixtureDir, "bin"); const callLog = join(fixtureDir, "calls.log"); mkdirSync(sourceDir); + mkdirSync(join(sourceDir, "dist")); + writeFileSync(join(sourceDir, "dist", "index.js"), "export {};\n"); mkdirSync(destinationDir); mkdirSync(binDir); writeFileSync(join(sourceDir, "package.json"), JSON.stringify(adapterUtilsPackage)); diff --git a/scripts/prepare-bundled-package.mjs b/scripts/prepare-bundled-package.mjs index da90abc6df6..84d92dace0d 100644 --- a/scripts/prepare-bundled-package.mjs +++ b/scripts/prepare-bundled-package.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { execFileSync } from "node:child_process"; -import { readFileSync, rmSync, writeFileSync } from "node:fs"; +import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; @@ -65,25 +65,35 @@ export function prepareBundledPackage(sourceDir, destinationDir) { throw new Error(`${sourcePackage.name} does not declare bundled dependencies`); } - execFileSync( - "pnpm", - ["--filter", sourcePackage.name, "deploy", "--prod", resolve(destinationDir)], - { cwd: repoRoot, stdio: "inherit" }, - ); + rmSync(destinationDir, { recursive: true, force: true }); + mkdirSync(destinationDir, { recursive: true }); + for (const entry of sourcePackage.files ?? []) { + cpSync(resolve(sourceDir, entry), resolve(destinationDir, entry), { recursive: true }); + } + for (const entry of ["README.md", "LICENSE", "LICENSE.md"]) { + const sourcePath = resolve(sourceDir, entry); + if (existsSync(sourcePath)) cpSync(sourcePath, resolve(destinationDir, entry)); + } const deployedPackagePath = resolve(destinationDir, "package.json"); - const deployedPackage = JSON.parse(readFileSync(deployedPackagePath, "utf8")); - writeFileSync( - deployedPackagePath, - `${JSON.stringify(materializePublishManifest(deployedPackage), null, 2)}\n`, - ); + const publishManifest = materializePublishManifest(sourcePackage); + const installManifest = structuredClone(publishManifest); + for (const section of ["dependencies", "optionalDependencies", "peerDependencies"]) { + if (!installManifest[section] || !sourcePackage[section]) continue; + for (const [name, specifier] of Object.entries(sourcePackage[section])) { + if (typeof specifier === "string" && specifier.startsWith("workspace:")) { + delete installManifest[section][name]; + } + } + } + writeFileSync(deployedPackagePath, `${JSON.stringify(installManifest, null, 2)}\n`); - rmSync(resolve(destinationDir, "node_modules"), { recursive: true, force: true }); execFileSync( "npm", ["install", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund"], { cwd: destinationDir, stdio: "inherit" }, ); + writeFileSync(deployedPackagePath, `${JSON.stringify(publishManifest, null, 2)}\n`); applyBundledDependencyPatches(destinationDir, bundledDependencies); if (