From 9bf03722349ff5db60c87e28d593dfdf7cf9bcdb Mon Sep 17 00:00:00 2001 From: Manuel <30698007+manuel3108@users.noreply.github.com> Date: Fri, 7 Feb 2025 14:34:17 +0100 Subject: [PATCH] fix: `onlyBuiltDependencies` not added on new projects (#439) --- .changeset/nine-phones-shout.md | 5 +++++ packages/cli/utils/package-manager.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changeset/nine-phones-shout.md diff --git a/.changeset/nine-phones-shout.md b/.changeset/nine-phones-shout.md new file mode 100644 index 00000000..41de9fe3 --- /dev/null +++ b/.changeset/nine-phones-shout.md @@ -0,0 +1,5 @@ +--- +'sv': patch +--- + +fix: `onlyBuiltDependencies` not added on new projects diff --git a/packages/cli/utils/package-manager.ts b/packages/cli/utils/package-manager.ts index 64babcb7..fe9a8f86 100644 --- a/packages/cli/utils/package-manager.ts +++ b/packages/cli/utils/package-manager.ts @@ -80,12 +80,15 @@ export function addPnpmBuildDependendencies( // other package managers are currently not affected by this change if (!packageManager || packageManager !== 'pnpm') return; - // find the workspace root + // find the workspace root (if present) const pnpmWorkspacePath = find.up('pnpm-workspace.yaml', { cwd }); - if (!pnpmWorkspacePath) return; + let packageDirectory; + + if (pnpmWorkspacePath) packageDirectory = path.dirname(pnpmWorkspacePath); + else packageDirectory = cwd; // load the package.json - const pkgPath = path.join(path.dirname(pnpmWorkspacePath), 'package.json'); + const pkgPath = path.join(packageDirectory, 'package.json'); const content = fs.readFileSync(pkgPath, 'utf-8'); const { data, generateCode } = parseJson(content);