tsup
- Version 8.3.5
- Published
- 440 kB
- 16 dependencies
- MIT license
Install
npm i tsup
yarn add tsup
pnpm add tsup
Overview
Bundle your TypeScript library with no config, powered by esbuild
Index
Functions
Type Aliases
Functions
function build
build: (_options: Options) => Promise<void>;
function createLogger
createLogger: (name?: string) => { setName(_name: string): void; success(label: string, ...args: any[]): void; info(label: string, ...args: any[]): void; error(label: string, ...args: any[]): void; warn(label: string, ...args: any[]): void; log( label: string, type: 'info' | 'success' | 'error' | 'warn', ...data: unknown[] ): void;};
function defineConfig
defineConfig: ( options: | Options | Options[] | ((overrideOptions: Options) => MaybePromise<Options | Options[]>)) => | Options | Options[] | ((overrideOptions: Options) => MaybePromise<Options | Options[]>);
Type Aliases
type Format
type Format = 'cjs' | 'esm' | 'iife';
type NormalizedOptions
type NormalizedOptions = Omit< MarkRequired<Options, 'entry' | 'outDir'>, 'dts' | 'experimentalDts' | 'format'> & { dts?: DtsConfig; experimentalDts?: NormalizedExperimentalDtsConfig; tsconfigResolvePaths: Record<string, string[]>; tsconfigDecoratorMetadata?: boolean; format: Format[];};
type Options
type Options = { /** Optional config name to show in CLI output */ name?: string; /** * @deprecated Use `entry` instead */ entryPoints?: Entry; entry?: Entry; /** * Output different formats to different folder instead of using different extensions */ legacyOutput?: boolean; /** * Compile target * * default to `node16` */ target?: Target | Target[]; minify?: boolean | 'terser'; terserOptions?: MinifyOptions; minifyWhitespace?: boolean; minifyIdentifiers?: boolean; minifySyntax?: boolean; keepNames?: boolean; watch?: boolean | string | (string | boolean)[]; ignoreWatch?: string[] | string; onSuccess?: | string | (() => Promise<void | undefined | (() => void | Promise<void>)>); jsxFactory?: string; jsxFragment?: string; outDir?: string; outExtension?: OutExtensionFactory; format?: Format[] | Format; globalName?: string; env?: { [k: string]: string; }; define?: { [k: string]: string; }; dts?: boolean | string | DtsConfig; experimentalDts?: boolean | string | ExperimentalDtsConfig; sourcemap?: boolean | 'inline'; /** Always bundle modules matching given patterns */ noExternal?: (string | RegExp)[]; /** Don't bundle these modules */ external?: (string | RegExp)[]; /** * Replace `process.env.NODE_ENV` with `production` or `development` * `production` when the bundled is minified, `development` otherwise */ replaceNodeEnv?: boolean; /** * Code splitting * Default to `true` for ESM, `false` for CJS. * * You can set it to `true` explicitly, and may want to disable code splitting sometimes: [`#255`](https://github.com/egoist/tsup/issues/255) */ splitting?: boolean; /** * Clean output directory before each build */ clean?: boolean | string[]; esbuildPlugins?: Plugin$1[]; esbuildOptions?: ( options: BuildOptions, context: { format: Format; } ) => void; /** * Suppress non-error logs (excluding "onSuccess" process output) */ silent?: boolean; /** * Skip node_modules bundling * Will still bundle modules matching the `noExternal` option */ skipNodeModulesBundle?: boolean; /** * @see https://esbuild.github.io/api/#pure */ pure?: string | string[]; /** * Disable bundling, default to true */ bundle?: boolean; /** * This option allows you to automatically replace a global variable with an import from another file. * @see https://esbuild.github.io/api/#inject */ inject?: string[]; /** * Emit esbuild metafile * @see https://esbuild.github.io/api/#metafile */ metafile?: boolean; footer?: BannerOrFooter; banner?: BannerOrFooter; /** * Target platform * @default `node` */ platform?: 'node' | 'browser' | 'neutral'; /** * Esbuild loader option */ loader?: Record<string, Loader>; /** * Disable config file with `false` * Or pass a custom config filename */ config?: boolean | string; /** * Use a custom tsconfig */ tsconfig?: string; /** * Inject CSS as style tags to document head * @default {false} */ injectStyle?: | boolean | ((css: string, fileId: string) => string | Promise<string>); /** * Inject cjs and esm shims if needed * @default false */ shims?: boolean; /** * TSUP plugins * @experimental * @alpha */ plugins?: Plugin[]; /** * By default esbuild already does treeshaking * * But this option allow you to perform additional treeshaking with Rollup * * This can result in smaller bundle size */ treeshake?: TreeshakingStrategy; /** * Copy the files inside `publicDir` to output directory */ publicDir?: string | boolean; killSignal?: KILL_SIGNAL; /** * Interop default within `module.exports` in cjs * @default false */ cjsInterop?: boolean; /** * Remove `node:` protocol from imports * * The default value will be flipped to `false` in the next major release * @default true */ removeNodeProtocol?: boolean;};
The options available in tsup.config.ts Not all of them are available from CLI flags
Package Files (1)
Dependencies (16)
Dev Dependencies (23)
Peer Dependencies (4)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/tsup
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/tsup)
- HTML<a href="https://www.jsdocs.io/package/tsup"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2660 ms. - Missing or incorrect documentation? Open an issue for this package.