---
url: /reference/api/Interface.ExportsOptions.md
---
# Interface: ExportsOptions

Defined in: [src/features/pkg/exports.ts:16](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L16)

## Properties

### all?

```ts
optional all?: boolean;
```

Defined in: [src/features/pkg/exports.ts:58](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L58)

Generate `exports` for all files.

#### Example

```json
{
  "exports": {
    "./*": "./*"
  }
}
```

#### Default

```ts
false
```

***

### bin?

```ts
optional bin?: string | boolean | Record<string, string>;
```

Defined in: [src/features/pkg/exports.ts:198](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L198)

Generate the `bin` field in `package.json` for CLI executables.

Behavior depends on the value:

* *Unset* (default): Soft auto-detect. Scans entry chunks for shebangs
  (e.g. `#!/usr/bin/env node`). If exactly one is found, it is used as
  the bin entry. If multiple are found, a warning is shown and no `bin`
  field is written. If none are found, nothing happens silently.
* `true`: Strict auto-detect. Same as the default, but throws if
  multiple shebang entries are found, and warns if none are found.
  Use this when your package is known to ship a CLI and you want to
  fail fast on misconfiguration.
* `false`: Disable bin generation entirely, even if shebangs are
  present.
* `string`: Use the given source file path (relative to `cwd`) as the
  CLI entry. The command name is derived from the package name without
  its scope. Warns if the source file does not contain a shebang.
* `Record<string, string>`: Explicitly map command names to source file
  paths (relative to `cwd`). Warns for each source file that does not
  contain a shebang.

When [ExportsOptions.devExports](#devexports) is enabled, the `bin` field in
`package.json` points to source files during local development, while
`publishConfig.bin` points to built output paths for publishing.

#### Examples

```ts
{
  bin: true
}
```

```ts
{
  bin: './src/cli.ts'
}
```

```ts
{
  bin: {
    tool: './src/cli.ts',
    serve: './src/cli-extra.ts',
  },
}
```

#### See

[npm documentation for the \`bin\` field](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin)

***

### customExports?

```ts
optional customExports?:
  | Record<string, any>
  | ((exports, context) => Awaitable<Record<string, any>>);
```

Defined in: [src/features/pkg/exports.ts:107](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L107)

Specifies custom exports to add to the package exports in addition to the ones generated by tsdown.
Use this to add additional exports in the exported package, such as workers or assets.

#### Examples

```ts
customExports(exports) {
  exports['./worker.js'] = './dist/worker.js';
  return exports;
}
```

```jsonc
{
  "customExports": {
    "./worker.js": {
      "types": "./dist/worker.d.ts",
      "default": "./dist/worker.js",
    },
  },
}
```

***

### devExports?

```ts
optional devExports?: string | boolean;
```

Defined in: [src/features/pkg/exports.ts:22](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L22)

Generate exports that link to source code during development.

* `string`: add as a custom condition.
* `true`: all conditions point to source files, and add `dist` exports to `publishConfig`.

***

### exclude?

```ts
optional exclude?: (string | RegExp)[];
```

Defined in: [src/features/pkg/exports.ts:71](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L71)

Specifies file patterns (as glob patterns or regular expressions) to exclude from package exports.
Use this to prevent certain files from being included in the exported package, such as test files, binaries, or internal utilities.

**Note:** Do not include file extensions, and paths should be relative to the dist directory.

#### Example

```ts
exclude: ['cli', '**/*.test', /internal/]
```

***

### extensions?

```ts
optional extensions?: boolean;
```

Defined in: [src/features/pkg/exports.ts:138](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L138)

Add file extensions to subpath export keys.

When enabled, all subpath exports (except the root `"."`) will include
a `.js` extension in the key (e.g., `"./utils.js"` instead of `"./utils"`).

This follows the Node.js recommendation for subpath exports:

#### See

<https://nodejs.org/api/packages.html#extensions-in-subpaths>

#### Default

```ts
false
```

***

### inlinedDependencies?

```ts
optional inlinedDependencies?: boolean;
```

Defined in: [src/features/pkg/exports.ts:125](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L125)

Generate `inlinedDependencies` field in `package.json`.
Lists dependencies that are physically inlined into the bundle with their exact versions.

#### Default

```ts
true
```

#### See

<https://github.com/e18e/ecosystem-issues/issues/237>

***

### legacy?

```ts
optional legacy?: boolean;
```

Defined in: [src/features/pkg/exports.ts:81](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L81)

Generate legacy fields (`main`, `module`, and `types`) for older Node.js
versions and bundlers that do not support the package `exports` field.

Defaults to `false` if only ESM builds are included, `true` otherwise.

#### See

<https://github.com/publint/publint/issues/24>

***

### packageJson?

```ts
optional packageJson?: boolean;
```

Defined in: [src/features/pkg/exports.ts:42](https://github.com/rolldown/tsdown/blob/eb40c95efdf7f98d0aa7b0178a3b7322986bd419/src/features/pkg/exports.ts#L42)

Generate `exports` for `package.json` file.

#### Example

```json
{
  "exports": {
    ".": {
      "types": "./dist/index.d.mts",
      "import": "./dist/index.mjs"
    },
    "./package.json": "./package.json"
  }
}
```

#### Default

```ts
true
```
