Skip to content

fix: Preserve source dependencies when adding workspace deps in turbo-gen#11935

Open
sleitor wants to merge 2 commits intovercel:mainfrom
sleitor:fix/gen-copy-deps
Open

fix: Preserve source dependencies when adding workspace deps in turbo-gen#11935
sleitor wants to merge 2 commits intovercel:mainfrom
sleitor:fix/gen-copy-deps

Conversation

@sleitor
Copy link
Contributor

@sleitor sleitor commented Feb 20, 2026

Closes #11505

Summary

Fix turbo gen workspace --copy to preserve the source package's existing dependencies when the user chooses to add workspace dependencies.

Problem

When copying a workspace and selecting "Add workspace dependencies", the copied package's original dependencies, devDependencies, etc. are completely replaced by only the selected workspace packages. All original deps from the source are lost.

Root Cause

In packages/turbo-gen/src/generators/copy.ts, the dependency update logic uses direct assignment:

packageJson[group] = deps;

This overwrites the entire dependency group instead of merging.

Fix

Merge the workspace dependencies with the existing ones:

packageJson[group] = { ...packageJson[group], ...deps };

Workspace deps take precedence (override) if there's a conflict, which is the expected behavior when explicitly adding them.

@sleitor sleitor requested a review from a team as a code owner February 20, 2026 19:07
@sleitor sleitor requested review from tknickman and removed request for a team February 20, 2026 19:07
@vercel
Copy link
Contributor

vercel bot commented Feb 20, 2026

Someone is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@sleitor sleitor changed the title fix(gen): preserve source dependencies when adding workspace deps fix: preserve source dependencies when adding workspace deps in turbo-gen Feb 20, 2026
@sleitor sleitor changed the title fix: preserve source dependencies when adding workspace deps in turbo-gen fix: Preserve source dependencies when adding workspace deps in turbo-gen Feb 20, 2026
@sleitor
Copy link
Contributor Author

sleitor commented Feb 20, 2026

cc @anthonyshew — would appreciate a review when you get a chance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

turbo gen workspace --copy does not keep the dependencies of the source if "Add workspace dependencies" is chosen

1 participant