Skip to content

Commit bc57ffc

Browse files
doc: add multiple package entries example (#1416)
1 parent bb4e5f6 commit bc57ffc

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

runtime/fundamentals/workspaces.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,33 @@ Deno workspaces are flexible and can work with Node packages. To make migration
147147
for existing Node.js projects easier you can have both Deno-first and Node-first
148148
packages in a single workspace.
149149

150+
### Multiple package entries
151+
152+
So far, our package only has a single entry. This is fine for simple packages,
153+
but often you'll want to have multiple entries that group relevant aspects of
154+
your package. This can be done by passing an `object` instead of a `string` to
155+
`exports`:
156+
157+
```json title="my-package/deno.json"
158+
{
159+
"name": "@scope/my-package",
160+
"version": "0.3.0",
161+
"exports": {
162+
".": "./mod.ts",
163+
"./foo": "./foo.ts",
164+
"./other": "./dir/other.ts"
165+
}
166+
}
167+
```
168+
169+
The `"."` entry is the default entry that's picked when importing
170+
`@scope/my-package`. Therefore, the above `deno.json` example provides the
171+
folowing entries:
172+
173+
- `@scope/my-package`
174+
- `@scope/my-package/foo`
175+
- `@scope/my-package/other`
176+
150177
### Migrating from `npm` workspaces
151178

152179
Deno workspaces support using a Deno-first package from an existing npm package.
@@ -278,7 +305,7 @@ root and its members:
278305
| fmt.singleQuote ||| Package takes priority over workspace. |
279306
| fmt.proseWrap ||| Package takes priority over workspace. |
280307
| fmt.semiColons ||| Package takes priority over workspace. |
281-
| fmt.options.* | ⚠️ || Deprecated |
308+
| fmt.options.\* | ⚠️ || Deprecated |
282309
| nodeModulesDir ||| Resolution behaviour must be the same in the entire workspace. |
283310
| vendor ||| Resolution behaviour must be the same in the entire workspace. |
284311
| tasks ||| Package tasks take priority over workspace. cwd used is the cwd of the config file that the task was inside of. |
@@ -291,7 +318,7 @@ root and its members:
291318
| bench.exclude ||| |
292319
| bench.files | ⚠️ || Deprecated |
293320
| lock ||| Only a single lock file may exist per resolver, and only resolver may exist per workspace, so conditional enablement of the lockfile per package does not make sense. |
294-
| unstable ||| For simplicities sake, we do not allow unstable flags, because a lot of the CLI assumes that unstable flags are immutable and global to the entire process. Also weird interaction with DENO_UNSTABLE_* flags. |
321+
| unstable ||| For simplicities sake, we do not allow unstable flags, because a lot of the CLI assumes that unstable flags are immutable and global to the entire process. Also weird interaction with DENO_UNSTABLE_\* flags. |
295322
| name ||| |
296323
| version ||| |
297324
| exports ||| |

0 commit comments

Comments
 (0)