Skip to content

alpheuscfg/tsdown

Repository files navigation

tsdown Configuration

A shareable tsdown configuration.

Installation

Install this package as a dependency in the project:

# npm
npm i @apst/tsdown

# Yarn
yarn add @apst/tsdown

# pnpm
pnpm add @apst/tsdown

# Bun
bun add @apst/tsdown

Usage

Implement the preset into tsdown.config.ts:

import { defineConfig } from "@apst/tsdown";
import { 
    cjsPreset,
    esmPreset,
    dtsPreset,
} from "@apst/tsdown/presets";

export default defineConfig(
    {
        entry: {
            index: "./src/index.ts",
        },
    },
    [
        cjsPreset(),
        esmPreset(),
        dtsPreset(),
    ],
);

With IIFE output:

import type { UserConfig } from "tsdown";

import { defineConfig } from "@apst/tsdown";
import { 
    cjsPreset,
    esmPreset,
    dtsPreset,
    iifePreset,
} from "@apst/tsdown/presets";

const config: UserConfig = {
    entry: {
        index: "./src/index.ts",
    },
};

const iifeConfig: UserConfig = {
    entry: {
        init: "./src/init.ts",
    },
    deps: {
        alwaysBundle: [
            /** ... */
        ],
    },
};

export default defineConfig([
    cjsPreset(config),
    esmPreset(config),
    dtsPreset(config),
    iifePreset(iifeConfig),
]);

APIs

For the APIs, please refer to the APIs.

License

This project is licensed under the terms of the MIT license.