Skip to content
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

docs: Package-json.md - Updated example for monorepo and json to jsonc #6656

Open
wants to merge 3 commits into
base: latest
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions docs/lib/content/configuring-npm/package-json.md
Expand Up @@ -144,7 +144,7 @@ Then include a file named `<filename>` at the top level of the package.
Some old packages used license objects or a "licenses" property containing
an array of license objects:

```json
```jsonc
// Not valid metadata
{
"license" : {
Expand Down Expand Up @@ -516,11 +516,9 @@ same shortcut syntax you use for `npm install`:
}
```

If the `package.json` for your package is not in the root directory (for
example if it is part of a monorepo), you can specify the directory in
which it lives:

```json
If your `package.json` isn't in the root directory, common with monorepos like Facebook's React, you can specify its location. i.e. `react-dom`:
```jsonc
/* @/packages/react-dom/package.json */
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is a helpful comment, is it just a bare comment of a path with some sort of "shorthand" for @ meaning cwd?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure this is a helpful comment, is it just a bare comment of a path with some sort of "shorthand" for @ meaning cwd?

Yea. I couldn't think of a good shorthand. This felt too long:
https://github.com/facebook/react/blob/main/packages/react-dom/package.json

I wanted to be verbose on which package.json the block was referring to

{
"repository": {
"type": "git",
Expand All @@ -529,6 +527,12 @@ which it lives:
}
}
```
```txt
react.git/
└── packages/
└── react-dom/
└── package.json
```

### scripts

Expand Down Expand Up @@ -985,7 +989,7 @@ this limitation easier to deal with, overrides may also be defined as a
reference to a spec for a direct dependency by prefixing the name of the
package you wish the version to match with a `$`.

```json
```jsonc
{
"dependencies": {
"foo": "^1.0.0"
Expand Down