KC's Workspace
    Preparing search index...

    Options for tsdown.

    interface UserConfig {
        alias?: Record<string, string>;
        attw?: WithEnabled<AttwOptions>;
        banner?: ChunkAddon;
        bundle?: boolean;
        checks?: ChecksOptions & { legacyCjs?: boolean };
        cjsDefault?: boolean;
        clean?: boolean | string[];
        copy?: CopyOptions | CopyOptionsFn;
        css?: CssOptions;
        customLogger?: Logger;
        cwd?: string;
        define?: Record<string, string>;
        deps?: DepsConfig;
        devtools?: WithEnabled<DevtoolsOptions>;
        dts?: WithEnabled<DtsOptions>;
        entry?: TsdownInputOption;
        env?: Record<string, any>;
        envFile?: string;
        envPrefix?: string | string[];
        exe?: WithEnabled<ExeOptions>;
        exports?: WithEnabled<ExportsOptions>;
        external?: string | RegExp | (string | RegExp)[] | ExternalOptionFunction;
        failOnWarn?: boolean | CIOption;
        fixedExtension?: boolean;
        footer?: ChunkAddon;
        format?:
            | "module"
            | "es"
            | "cjs"
            | "esm"
            | "commonjs"
            | "iife"
            | "umd"
            | ("module" | "es" | "cjs" | "esm" | "commonjs" | "iife" | "umd")[]
            | Partial<
                Record<
                    "module"
                    | "es"
                    | "cjs"
                    | "esm"
                    | "commonjs"
                    | "iife"
                    | "umd",
                    Partial<ResolvedConfig>,
                >,
            >;
        fromVite?: boolean | "vitest";
        globalName?: string;
        globImport?: boolean;
        hash?: boolean;
        hooks?:
            | Partial<TsdownHooks>
            | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
        ignoreWatch?: Arrayable<string | RegExp>;
        injectStyle?: boolean;
        inlineOnly?: false | Arrayable<string | RegExp>;
        inputOptions?:
            | InputOptions
            | (
                (
                    options: InputOptions,
                    format: InternalModuleFormat,
                    context: { cjsDts: boolean },
                ) => Awaitable<void | InputOptions | null>
            );
        loader?: ModuleTypes;
        logLevel?: LogLevel;
        minify?: boolean | "dce-only" | MinifyOptions;
        name?: string;
        nodeProtocol?: boolean | "strip";
        noExternal?: Arrayable<string | RegExp> | NoExternalFn;
        onSuccess?:
            | string
            | ((config: ResolvedConfig, signal: AbortSignal) => void | Promise<void>);
        outDir?: string;
        outExtension?: OutExtensionFactory;
        outExtensions?: OutExtensionFactory;
        outputOptions?:
            | OutputOptions
            | (
                (
                    options: OutputOptions,
                    format: InternalModuleFormat,
                    context: { cjsDts: boolean },
                ) => Awaitable<void | OutputOptions | null>
            );
        platform?: "neutral" | "node" | "browser";
        plugins?: TsdownPluginOption;
        publicDir?: CopyOptions | CopyOptionsFn;
        publint?: WithEnabled<PublintOptions>;
        removeNodeProtocol?: boolean;
        report?: WithEnabled<ReportOptions>;
        root?: string;
        shims?: boolean;
        skipNodeModulesBundle?: boolean;
        sourcemap?: Sourcemap;
        suppressWarnings?: Arrayable<string | RegExp> | ((msg: string) => boolean);
        target?: string | false | string[];
        treeshake?: boolean | TreeshakingOptions;
        tsconfig?: string | boolean;
        unbundle?: boolean;
        unused?: WithEnabled<Options>;
        watch?: boolean | Arrayable<string>;
        workspace?: true | Arrayable<string> | Workspace;
        write?: boolean;
    }

    Hierarchy (View Summary)

    Index
    alias?: Record<string, string>

    Run arethetypeswrong after bundling. Requires @arethetypeswrong/core to be installed.

    banner?: ChunkAddon
    bundle?: boolean

    Use unbundle instead.

    true
    
    checks?: ChecksOptions & { legacyCjs?: boolean }

    Controls which warnings are emitted during the build process. Each option can be set to true (emit warning) or false (suppress warning).

    Type Declaration

    • OptionallegacyCjs?: boolean

      If the config includes the cjs format and one of its target >= node 20.19.0 / 22.12.0, warn the user about the deprecation of CommonJS.

      true
      
    cjsDefault?: boolean
    true
    
    clean?: boolean | string[]

    Clean directories before build.

    Default to output directory.

    true
    

    Copy files to another directory.

    [
    'src/assets',
    'src/env.d.ts',
    'src/styles/**/*.css',
    { from: 'src/assets', to: 'dist/assets' },
    { from: 'src/styles/**/*.css', to: 'dist', flatten: true },
    ]

    [experimental] CSS options. Requires @tsdown/css to be installed.

    customLogger?: Logger

    Custom logger.

    cwd?: string

    The working directory of the config file.

    process.cwd()
    
    define?: Record<string, string>
    deps?: DepsConfig

    Dependency handling options.

    [experimental] Enable devtools.

    DevTools is still under development, and this is for early testers only.

    This may slow down the build process significantly.

    false
    

    Enables generation of TypeScript declaration files (.d.ts).

    By default, this option is auto-detected based on your project's package.json:

    • If exe is enabled, declaration file generation is disabled by default.
    • If the types field is present, or if the main exports contains a types entry, declaration file generation is enabled by default.
    • Otherwise, declaration file generation is disabled by default.

    Optionalentry

    Defaults to 'src/index.ts' if it exists.

    Supports glob patterns with negation to exclude files:

    entry: {
    "hooks/*": ["./src/hooks/*.ts", "!./src/hooks/index.ts"],
    }
    { index: 'src/index.ts'}
    
    env?: Record<string, any>

    Compile-time env variables, which can be accessed via import.meta.env or process.env.

    {
    "DEBUG": true,
    "NODE_ENV": "production"
    }
    {}
    
    envFile?: string

    Path to env file providing compile-time env variables.

    `.env`, `.env.production`, etc.
    
    envPrefix?: string | string[]

    When loading env variables from envFile, only include variables with these prefixes.

    'TSDOWN_'
    

    [experimental] Bundle as executable using Node.js SEA (Single Executable Applications).

    This will bundle the output into a single executable file using Node.js SEA. Note that this is only supported on Node.js 25.7.0 and later, and is not supported in Bun or Deno.

    false
    

    Generate package exports for package.json.

    This will set the exports field in package.json to point to the generated files.

    false
    
    external?: string | RegExp | (string | RegExp)[] | ExternalOptionFunction

    Use deps.neverBundle instead.

    failOnWarn?: boolean | CIOption

    If true, fails the build on warnings.

    false
    
    fixedExtension?: boolean

    Use a fixed extension for output files. The extension will always be .cjs or .mjs. Otherwise, it will depend on the package type.

    Defaults to true if platform is set to node, false otherwise.

    platform === 'node'
    
    footer?: ChunkAddon
    format?:
        | "module"
        | "es"
        | "cjs"
        | "esm"
        | "commonjs"
        | "iife"
        | "umd"
        | ("module" | "es" | "cjs" | "esm" | "commonjs" | "iife" | "umd")[]
        | Partial<
            Record<
                "module"
                | "es"
                | "cjs"
                | "esm"
                | "commonjs"
                | "iife"
                | "umd",
                Partial<ResolvedConfig>,
            >,
        >

    Output format(s). Available formats are

    • esm: ESM
    • cjs: CommonJS
    • iife: IIFE
    • umd: UMD
    'esm'
    
    fromVite?: boolean | "vitest"

    Reuse config from Vite or Vitest (experimental)

    false
    
    globalName?: string
    globImport?: boolean

    import.meta.glob support.

    hash?: boolean

    If enabled, appends hash to chunk filenames.

    true
    
    hooks?:
        | Partial<TsdownHooks>
        | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>)
    ignoreWatch?: Arrayable<string | RegExp>

    Files or patterns to not watch while in watch mode.

    injectStyle?: boolean

    Use css.inject instead.

    inlineOnly?: false | Arrayable<string | RegExp>

    Use deps.onlyBundle instead.

    inputOptions?:
        | InputOptions
        | (
            (
                options: InputOptions,
                format: InternalModuleFormat,
                context: { cjsDts: boolean },
            ) => Awaitable<void | InputOptions | null>
        )

    Use with caution; ensure you understand the implications.

    loader?: ModuleTypes

    Sets how input files are processed. For example, use 'js' to treat files as JavaScript or 'base64' for images. Lets you import or require files like images or fonts.

    { ".jpg": "asset", ".png": "base64" }
    
    logLevel?: LogLevel

    Log level.

    'info'
    
    minify?: boolean | "dce-only" | MinifyOptions
    false
    
    name?: string

    The name to show in CLI output. This is useful for monorepos or workspaces. When using workspace mode, this option defaults to the package name from package.json. In non-workspace mode, this option must be set explicitly for the name to show in the CLI output.

    nodeProtocol?: boolean | "strip"

    Control whether built-in Node.js module imports use the node: protocol.

    • true: Add the node: prefix to built-in module imports.
    • 'strip': Remove the node: prefix from built-in module imports.
    • false: Do not transform built-in module imports.
    false
    
    `nodeProtocol: true` — add the `node:` prefix
    // Input
    import 'fs'

    // Output
    import 'node:fs'
    `nodeProtocol: 'strip'` — remove the `node:` prefix
    // Input
    import 'node:fs'

    // Output
    import 'fs'
    `nodeProtocol: false` — do not transform imports
    // Input
    import 'node:fs'

    // Output
    import 'node:fs'
    noExternal?: Arrayable<string | RegExp> | NoExternalFn

    Use deps.alwaysBundle instead.

    onSuccess?:
        | string
        | ((config: ResolvedConfig, signal: AbortSignal) => void | Promise<void>)

    You can specify command to be executed after a successful build, specially useful for Watch mode

    outDir?: string
    'dist'
    
    outExtension?: OutExtensionFactory

    Use outExtensions instead.

    outExtensions?: OutExtensionFactory

    Custom extensions for output files. fixedExtension will be overridden by this option.

    outputOptions?:
        | OutputOptions
        | (
            (
                options: OutputOptions,
                format: InternalModuleFormat,
                context: { cjsDts: boolean },
            ) => Awaitable<void | OutputOptions | null>
        )

    Use with caution; ensure you understand the implications.

    platform?: "neutral" | "node" | "browser"

    Specifies the target runtime platform for the build.

    • node: Node.js and compatible runtimes (e.g., Deno, Bun). For CJS format, this is always set to node and cannot be changed.
    • neutral: A platform-agnostic target with no specific runtime assumptions.
    • browser: Web browsers.
    'node'
    

    copy

    Alias for copy, will be removed in the future.

    Run publint after bundling. Requires publint to be installed.

    false
    
    removeNodeProtocol?: boolean

    Remove the node: prefix from built-in Node.js module imports. When enabled, rewrites import sources like node:fs to fs.

    false
    

    Use nodeProtocol: 'strip' instead.

    `removeNodeProtocol: true` — remove the `node:` prefix
    // Input
    import 'node:fs'

    // Output
    import 'fs'

    Enable size reporting after bundling.

    true
    
    root?: string

    Specifies the root directory of input files, similar to TypeScript's rootDir. This determines the output directory structure.

    By default, the root is computed as the common base directory of all entry files.

    shims?: boolean
    false
    
    skipNodeModulesBundle?: boolean

    Use deps.skipNodeModulesBundle instead.

    false
    
    sourcemap?: Sourcemap

    Whether to generate source map files.

    Note that this option will always be true if you have declarationMap option enabled in your tsconfig.json.

    false
    
    suppressWarnings?: Arrayable<string | RegExp> | ((msg: string) => boolean)

    Suppress warnings whose message matches the given pattern(s).

    Accepts a string (substring match), a RegExp, an array of either, or a predicate function. Matched warnings are dropped before failOnWarn is applied, so they won't fail the build.

    target?: string | false | string[]

    Specifies the compilation target environment(s).

    Determines the JavaScript version or runtime(s) for which the code should be compiled. If not set, defaults to the value of engines.node in your project's package.json. If no engines.node field exists, no syntax transformations are applied.

    Accepts a single target (e.g., 'es2020', 'node18', 'baseline-widely-available'), an array of targets, or false to disable all transformations.

    https://tsdown.dev/options/target#supported-targets for a list of valid targets and more details.

    // Target a single environment
    { "target": "node18" }
    // Target multiple environments
    { "target": ["node18", "es2020"] }
    // Disable all syntax transformations
    { "target": false }
    treeshake?: boolean | TreeshakingOptions

    Configure tree shaking options.

    true
    
    tsconfig?: string | boolean
    true
    
    unbundle?: boolean

    Determines whether unbundle is enabled. When set to true, the output files will mirror the input file structure.

    false
    

    Enable unused dependencies check with unplugin-unused Requires unplugin-unused to be installed.

    false
    
    watch?: boolean | Arrayable<string>
    false
    
    workspace?: true | Arrayable<string> | Workspace

    [experimental] Enable workspace mode. This allows you to build multiple packages in a monorepo.

    write?: boolean

    Whether to write the files to disk. This option is incompatible with watch mode.

    true