KC's Workspace
    Preparing search index...

    Options for tsdown.

    interface UserConfig {
        alias?: Record<string, string>;
        attw?: WithEnabled<AttwOptions>;
        banner?: ChunkAddon;
        bundle?: boolean;
        cjsDefault?: boolean;
        clean?: boolean | string[];
        copy?: CopyOptions | CopyOptionsFn;
        css?: CssOptions;
        customLogger?: Logger;
        cwd?: string;
        debug?: WithEnabled<DebugOptions>;
        define?: Record<string, string>;
        dts?: WithEnabled<Options>;
        entry?: TsdownInputOption;
        env?: Record<string, any>;
        envFile?: string;
        envPrefix?: string | string[];
        exports?: WithEnabled<ExportsOptions>;
        external?: ExternalOption;
        failOnWarn?: boolean | CIOption;
        fixedExtension?: boolean;
        footer?: ChunkAddon;
        format?:
            | ModuleFormat
            | ModuleFormat[]
            | Partial<Record<ModuleFormat, Partial<ResolvedConfig>>>;
        fromVite?: boolean | "vitest";
        globalName?: string;
        globImport?: boolean;
        hash?: boolean;
        hooks?:
            | Partial<TsdownHooks>
            | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
        ignoreWatch?: Arrayable<string | RegExp>;
        inlineOnly?: 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;
        outExtensions?: OutExtensionFactory;
        outputOptions?:
            | OutputOptions
            | (
                (
                    options: OutputOptions,
                    format: InternalModuleFormat,
                    context: { cjsDts: boolean },
                ) => Awaitable<void | OutputOptions | null>
            );
        platform?: "neutral" | "node" | "browser";
        plugins?: RolldownPluginOption<any>;
        publicDir?: CopyOptions | CopyOptionsFn;
        publint?: WithEnabled<PublintOptions>;
        removeNodeProtocol?: boolean;
        report?: WithEnabled<ReportOptions>;
        shims?: boolean;
        silent?: boolean;
        skipNodeModulesBundle?: boolean;
        sourcemap?: Sourcemap;
        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;
    }
    Index

    Properties

    alias?: Record<string, string>

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

    banner?: ChunkAddon
    bundle?: boolean

    Use unbundle instead.

    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.

    customLogger?: Logger

    Custom logger.

    cwd?: string

    The working directory of the config file.

    • Defaults to process.cwd() for root config.
    • Defaults to the package directory for workspace config.

    [experimental] Enable debug mode.

    Both debug mode and Vite DevTools are still under development, and this is for early testers only.

    This may slow down the build process significantly.

    false
    
    define?: Record<string, string>

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

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

    • 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"],
    }
    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_'
    

    Generate package exports for package.json.

    This will set the main, module, types, exports fields in package.json to point to the generated files.

    external?: ExternalOption
    failOnWarn?: boolean | CIOption

    If true, fails the build on warnings.

    'ci-only'
    
    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.

    footer?: ChunkAddon
    format?:
        | ModuleFormat
        | ModuleFormat[]
        | Partial<Record<ModuleFormat, Partial<ResolvedConfig>>>
    'es'
    
    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.

    inlineOnly?: Arrayable<string | RegExp>

    Bundle only the dependencies listed here; throw an error if any others are missing.

    Note: Be sure to include all required sub-dependencies as well.

    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"
    • If true, add node: prefix to built-in modules.
    • If 'strip', strips the node: protocol prefix from import source.
    • If false, does not modify the import source.
    false
    
    // With nodeProtocol enabled:
    import('fs'); // becomes import('node:fs')
    // With nodeProtocol set to 'strip':
    import('node:fs'); // becomes import('fs')
    // With nodeProtocol set to false:
    import('node:fs'); // remains import('node:fs')
    noExternal?: Arrayable<string | RegExp> | NoExternalFn
    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'
    
    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.
    plugins?: RolldownPluginOption<any>

    Alias for copy, will be removed in the future.

    Run publint after bundling. Requires publint to be installed.

    false
    
    removeNodeProtocol?: boolean

    If enabled, strips the node: protocol prefix from import source.

    false
    

    Use nodeProtocol: 'strip' instead.

    // With removeNodeProtocol enabled:
    import('node:fs'); // becomes import('fs')

    Enable size reporting after bundling.

    true
    
    shims?: boolean
    false
    
    silent?: boolean
    false
    

    Use logLevel instead.

    skipNodeModulesBundle?: boolean

    Skip bundling node_modules.

    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
    
    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'), 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
    unbundle?: boolean

    Determines whether unbundle mode 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