Skip to content

Commit c8aad39

Browse files
authored
docs(workspaces): document publish: false to skip a member (#3179)
1 parent 930282d commit c8aad39

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

runtime/fundamentals/workspaces.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,35 @@ cd my-package
311311
deno publish
312312
```
313313

314+
#### Excluding a workspace member from publish
315+
316+
Workspaces often contain members that are not meant to be published, such as
317+
internal helpers, examples, or packages that only exist to host shared `tasks`.
318+
By default `deno publish` will try to publish every workspace member that has a
319+
`name` and `exports`, and will error if any of them is missing a `version`.
320+
321+
To opt a member out of `deno publish`, set `"publish": false` in that member's
322+
`deno.json`:
323+
324+
```jsonc title="internal-helpers/deno.json"
325+
{
326+
"name": "@scope/internal-helpers",
327+
"tasks": {
328+
"build": "deno run -A scripts/build.ts"
329+
},
330+
"publish": false
331+
}
332+
```
333+
334+
The member is still part of the workspace. Its `tasks` run, its `imports` are
335+
resolved, and other members can depend on it, but `deno publish` skips it
336+
entirely and won't complain about a missing `version`.
337+
338+
This applies to `deno.json` members only. Workspace members defined solely by a
339+
`package.json` are npm packages and are never candidates for `deno publish`
340+
(which targets JSR), so no opt-out is needed for them. `package.json`'s
341+
`"private": true` field is not read by Deno.
342+
314343
#### Managing interdependent packages
315344

316345
When publishing packages from a workspace with interdependencies, use consistent
@@ -469,6 +498,7 @@ root and its members:
469498
| test.include ||| |
470499
| test.exclude ||| |
471500
| test.files | ⚠️ || Deprecated |
501+
| publish ||| Set to `false` to exclude a member from `deno publish`. See [Excluding a workspace member from publish](#excluding-a-workspace-member-from-publish). |
472502
| publish.include ||| |
473503
| publish.exclude ||| |
474504
| bench.include ||| |

runtime/reference/cli/publish.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ Example:
3636
Before you publish your package, you must create it in the registry by visiting
3737
[JSR - Publish a package](https://jsr.io/new).
3838

39+
## Excluding a workspace member
40+
41+
When run inside a [workspace](/runtime/fundamentals/workspaces/), `deno publish`
42+
tries to publish every member that has a `name` and `exports`, and errors if any
43+
of them is missing a `version`. To opt a member out, for example an internal
44+
helper package that only exists to host shared `tasks`, set `"publish": false`
45+
in that member's `deno.json`:
46+
47+
```jsonc title="internal-helpers/deno.json"
48+
{
49+
"name": "@scope/internal-helpers",
50+
"publish": false
51+
}
52+
```
53+
54+
The member stays part of the workspace but is skipped by `deno publish`. See
55+
[Excluding a workspace member from publish](/runtime/fundamentals/workspaces/#excluding-a-workspace-member-from-publish)
56+
for the full discussion.
57+
3958
## Examples
4059

4160
Publish your current workspace

0 commit comments

Comments
 (0)