#!/usr/bin/env node import { createRequire as __cjs_createRequire } from "node:module"; const __cjs_require = __cjs_createRequire(import.meta.url); import { a as globalLogger } from "./logger-BU0v7CAk.mjs"; import { t as version } from "./package-BV2VRL7Z.mjs"; import { t as enableDebug } from "./debug-C4FmgzkJ.mjs"; import module from "node:module"; import process from "node:process"; import { dim, yellow } from "ansis"; import { x } from "tinyexec"; import { VERSION } from "rolldown"; const lt = __cjs_require("semver/functions/lt.js"); import { cac } from "cac"; //#region src/cli.ts const cli = cac("tsdown"); cli.help().version(version); cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true, allowUnknownOptions: true }).option("-c, --config ", "Use a custom config file").option("--config-loader ", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format ", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle ", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target ", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel ", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir ", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform ", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch ", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* ", "Define compile-time env variables").option("--env-file ", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix ", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success ", "Command to run on success").option("--copy ", "Copy files to output dir").option("--public-dir ", "Alias for --copy, deprecated").option("--tsconfig ", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--root ", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter ", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => { globalLogger.level = flags.logLevel || "info"; globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`); const { build } = await import("./build-dhDyu66J.mjs"); if (input.length > 0) flags.entry = input; await build(flags); }); cli.command("create", "[deprecated] Create a tsdown project. Use \"npx create-tsdown\" instead.", { allowUnknownOptions: true }).action(async () => { globalLogger.warn(`"tsdown create" is deprecated. Please use "npx create-tsdown" instead.`); const { exitCode } = await x("npx", [ "-y", "create-tsdown@latest", ...process.argv.slice(3) ], { nodeOptions: { stdio: "inherit" } }); process.exitCode = exitCode; }); cli.command("migrate", "[deprecated] Migrate from tsup to tsdown. Use \"npx tsdown-migrate\" instead.", { allowUnknownOptions: true }).action(async () => { globalLogger.warn(`"tsdown migrate" is deprecated. Please use "npx tsdown-migrate" instead.`); const { exitCode } = await x("npx", [ "-y", "tsdown-migrate@latest", ...process.argv.slice(3) ], { nodeOptions: { stdio: "inherit" } }); process.exitCode = exitCode; }); async function runCLI() { cli.parse(process.argv, { run: false }); enableDebug(cli.options.debug); try { await cli.runMatchedCommand(); } catch (error) { globalLogger.error(String(error.stack || error.message)); process.exit(1); } } //#endregion //#region src/run.ts if (lt(process.version, "22.18.0")) console.warn(yellow`[tsdown] Node.js ${process.version} is deprecated. Support will be removed in the next minor release. Please upgrade to Node.js 22.18.0 or later.`); try { module.enableCompileCache?.(); } catch {} runCLI(); //#endregion export {};