KC's Workspace
    Preparing search index...
    interface ExportsOptions {
        all?: boolean;
        bin?: string | boolean | Record<string, string>;
        customExports?:
            | Record<string, any>
            | (
                (
                    exports: Record<string, any>,
                    context: {
                        chunks: ChunksByFormat;
                        isPublish: boolean;
                        pkg: PackageJson;
                    },
                ) => Awaitable<Record<string, any>>
            );
        devExports?: string | boolean;
        exclude?: (string | RegExp)[];
        extensions?: boolean;
        inlinedDependencies?: boolean;
        legacy?: boolean;
        packageJson?: boolean;
    }
    Index
    all?: boolean

    Generate exports for all files.

    {
    "exports": {
    "./*": "./*"
    }
    }
    false
    
    bin?: string | boolean | Record<string, string>

    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 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.

    Auto-detect a CLI entry from a shebang
    {
    bin: true
    }
    Single CLI command with an explicit source entry
    {
    bin: './src/cli.ts'
    }
    Multiple named CLI commands
    {
    bin: {
    tool: './src/cli.ts',
    serve: './src/cli-extra.ts',
    },
    }
    customExports?:
        | Record<string, any>
        | (
            (
                exports: Record<string, any>,
                context: { chunks: ChunksByFormat; isPublish: boolean; pkg: PackageJson },
            ) => Awaitable<Record<string, any>>
        )

    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.

    customExports(exports) {
    exports['./worker.js'] = './dist/worker.js';
    return exports;
    }
    {
    "customExports": {
    "./worker.js": {
    "types": "./dist/worker.d.ts",
    "default": "./dist/worker.js"
    }
    }
    }
    devExports?: string | boolean

    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?: (string | RegExp)[]

    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.

    exclude: ['cli', '**/*.test', /internal/]
    
    extensions?: boolean

    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:

    inlinedDependencies?: boolean

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

    legacy?: boolean

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

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

    packageJson?: boolean

    Generate exports for package.json file.

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