Skip to content
24 changes: 24 additions & 0 deletions runtime/fundamentals/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,30 @@ works as well:
}
```

## Exports

The `exports` field in the `deno.json` file allows you to define which modules
or paths are publicly accessible from your package. This is particularly useful
Comment thread
thisisjofrank marked this conversation as resolved.
Outdated
for controlling the API surface of your package and ensuring that only the
intended parts of your code are exposed to users.

```json title="deno.json"
{
"exports": {
Comment thread
thisisjofrank marked this conversation as resolved.
"./module1": "./src/module1.ts",
"./module2": "./src/module2.ts",
"./utils/*": "./src/utils/*.ts"
Comment thread
thisisjofrank marked this conversation as resolved.
Outdated
}
Comment thread
thisisjofrank marked this conversation as resolved.
}
```
Comment thread
thisisjofrank marked this conversation as resolved.

This configuration will:
Comment thread
thisisjofrank marked this conversation as resolved.

- expose `module1` and `module2` as entry points for your package,
- allow importing any file from the `utils` directory using a wildcard. This
means users can import these modules using the specified paths, while other
files in your package remain private.

## An example `deno.json` file

```json
Expand Down