这是indexloc提供的服务,不要输入任何密码
Skip to content

docs: add workspace configuration example to package.json #10455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2025

Conversation

Feli-dev
Copy link
Contributor

@Feli-dev Feli-dev commented May 7, 2025

Description

This PR updates the package.json configuration example in the documentation to include the workspaces field, which is necessary for multi-package repositories using Turborepo.

Motivation

While following this documentation page, I noticed that the package.json example showed how to add the packageManager field, but omitted the workspaces field. Although this information is later explained at https://turborepo.com/docs/crafting-your-repository/structuring-a-repository#declaring-directories-for-packages, including it in this initial example would make the documentation more consistent and help prevent confusion for new users who are following the steps sequentially.

Changes made

I've updated the diff example in the "Add a packageManager field to root package.json" section to show the workspaces field alongside the packageManager field, making the example complete and consistent with what's explained later in the documentation.

This change updates the documentation to include the workspaces field
in the package.json example, which is necessary for multi-package 
repositories using Turborepo. This makes the documentation more 
complete and helps prevent potential confusion for users setting up
workspaces.
@Feli-dev Feli-dev requested review from anthonyshew and a team as code owners May 7, 2025 19:49
@Feli-dev Feli-dev requested a review from chris-olszewski May 7, 2025 19:49
@turbo-orchestrator turbo-orchestrator bot added area: docs Improvements or additions to documentation needs: triage New issues get this label. Remove it after triage labels May 7, 2025
@Feli-dev
Copy link
Contributor Author

Feli-dev commented May 7, 2025

I'm open to making any additional adjustments that might be necessary. Thank you for considering this contribution to improve documentation consistency.

Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 5:04pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 5:04pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 5:04pm
examples-svelte-web ❌ Failed (Inspect) May 12, 2025 5:04pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 5:04pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 5:04pm
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 5:04pm

Copy link

vercel bot commented May 7, 2025

@Feli-dev is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@anthonyshew anthonyshew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This need is talked about elsewhere on the page, but an optional step wouldn't hurt.

Would it be possible that you could add another step to the flow instead of adding to this diff? Maybe titled "Set up package manager workspaces". And with a small explanation and then the diff.

As requested in PR feedback, this change adds a separate step for
workspace configuration instead of modifying the existing diff.
@Feli-dev
Copy link
Contributor Author

Feli-dev commented May 8, 2025

Good catch. This need is talked about elsewhere on the page, but an optional step wouldn't hurt.

Would it be possible that you could add another step to the flow instead of adding to this diff? Maybe titled "Set up package manager workspaces". And with a small explanation and then the diff.

Thank you for the feedback! I've implemented the changes as suggested by adding a new dedicated step titled "Set up package manager workspaces" between the current steps 4 and 5.

The new step includes:

  • A brief explanation of what workspaces are and why they're needed for multi-package repos
  • The diff showing how to add the workspaces field to package.json
  • Additional information for different package managers (npm, yarn, pnpm)
  • A note that single-package repository users can skip this step
  • A reference to the more detailed documentation

I've just pushed these changes to my branch. Please let me know if this addresses your suggestion or if you'd like to see any further adjustments.

@Feli-dev Feli-dev requested a review from anthonyshew May 8, 2025 02:19
<Step>
### Set up package manager workspaces

For multi-package repositories, you'll need to configure your package manager to recognize your workspace structure. This is done by adding a `workspaces` field to your root `package.json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make "multi-package repositories" a link to https://vercel.com/docs/glossary#multi-package-workspace and have the copy be "multi-package workspaces".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, let's remove this sentence, since pnpm is different.

Suggested change
For multi-package repositories, you'll need to configure your package manager to recognize your workspace structure. This is done by adding a `workspaces` field to your root `package.json`.
For multi-package repositories, you'll need to configure your package manager to recognize your workspace structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

Comment on lines 209 to 217
```diff title="package.json"
{
"packageManager": "npm@8.5.0",
+ "workspaces": [
+ "apps/*",
+ "packages/*"
+ ]
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete this diff since we're showing these codeblocks in the anyway, and they'll be contextual to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

}
```

<Callout type="info">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is softens the rendered styles of the callout so it demands less attention. This is likely my personal preference, info makes sense, too, but I'm sensing that we can turn down the intent for this particular piece of knowledge.

Suggested change
<Callout type="info">
<Callout type="good-to-know">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

workspaces aren't needed.
</Callout>

Different package managers may have alternative ways to configure workspaces:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this line. The tabs construct conveys this without needing to say it explicitly.

}
```

<LinkToDocumentation href="https://bun.sh/docs/install/workspaces">npm workspace documentation</LinkToDocumentation>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<LinkToDocumentation href="https://bun.sh/docs/install/workspaces">npm workspace documentation</LinkToDocumentation>
<LinkToDocumentation href="https://bun.sh/docs/install/workspaces">bun workspace documentation</LinkToDocumentation>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

Copy link
Contributor

@anthonyshew anthonyshew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! Definitely the right direction. Getting into the details of things now.

I suspect we might have one more review round after we see how these look, but we're certainly close.

@Feli-dev Feli-dev requested a review from anthonyshew May 8, 2025 19:24
Copy link
Contributor

@anthonyshew anthonyshew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks!

@Feli-dev
Copy link
Contributor Author

Feli-dev commented May 9, 2025

Looks great. Thanks!

Thank you for the guidance and review!
Happy to contribute and glad the changes worked out well. Looking forward to the merge. 🚀

@anthonyshew anthonyshew merged commit 5911b42 into vercel:main May 9, 2025
30 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs Improvements or additions to documentation needs: triage New issues get this label. Remove it after triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants