tsdown 0.13.2 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{config-CZj6NGiw.d.mts → config-CEEvti7D.d.mts} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/index.d.mts +4 -17
- package/dist/index.mjs +3 -3
- package/dist/{logger-6IV2T7t1.mjs → logger-CGMSjTLn.mjs} +51 -27
- package/dist/{migrate-mIs6mjET.mjs → migrate-BghKfLMP.mjs} +20 -20
- package/dist/package-C-PL6-Mh.mjs +5 -0
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +11 -11
- package/dist/{src-C8dUJ_Mj.mjs → src-D6AiyRka.mjs} +634 -586
- package/dist/{types-DIH2hGTd.d.mts → types-QuuoDTDl.d.mts} +45 -8
- package/package.json +7 -7
- package/dist/package-Dg3yzWpE.mjs +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<img src="./docs/public/og-image.svg" alt="tsdown" width="100%" /><br>
|
|
2
2
|
|
|
3
|
-
# tsdown [](https://npmjs.com/package/tsdown) [](https://github.com/rolldown/tsdown/actions/workflows/tests.yml) [](https://npmjs.com/package/tsdown) [](https://github.com/rolldown/tsdown/actions/workflows/tests.yml) [](https://stackblitz.com/github/rolldown/tsdown-starter-stackblitz)
|
|
4
4
|
|
|
5
5
|
✨ The elegant bundler for libraries powered by [Rolldown](https://github.com/rolldown/rolldown).
|
|
6
6
|
|
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./types-
|
|
2
|
-
import { defineConfig } from "./config-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./types-QuuoDTDl.mjs";
|
|
2
|
+
import { defineConfig } from "./config-CEEvti7D.mjs";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace } from "./types-
|
|
2
|
-
import { defineConfig } from "./config-
|
|
3
|
-
import "ansis";
|
|
4
|
-
import { InternalModuleFormat } from "rolldown";
|
|
1
|
+
import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-QuuoDTDl.mjs";
|
|
2
|
+
import { defineConfig } from "./config-CEEvti7D.mjs";
|
|
5
3
|
|
|
6
|
-
//#region src/utils/logger.d.ts
|
|
7
|
-
declare class Logger {
|
|
8
|
-
silent: boolean;
|
|
9
|
-
setSilent(value: boolean): void;
|
|
10
|
-
filter(...args: any[]): any[];
|
|
11
|
-
info(...args: any[]): void;
|
|
12
|
-
warn(...args: any[]): void;
|
|
13
|
-
error(...args: any[]): void;
|
|
14
|
-
success(...args: any[]): void;
|
|
15
|
-
}
|
|
16
|
-
declare const logger: Logger;
|
|
17
|
-
//#endregion
|
|
18
4
|
//#region src/index.d.ts
|
|
5
|
+
|
|
19
6
|
/**
|
|
20
7
|
* Build with tsdown.
|
|
21
8
|
*/
|
|
@@ -32,4 +19,4 @@ declare const shimFile: string;
|
|
|
32
19
|
*/
|
|
33
20
|
declare function buildSingle(config: ResolvedOptions, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
|
|
34
21
|
//#endregion
|
|
35
|
-
export { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, type Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, type Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, type ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, type UserConfig, type UserConfigFn, Workspace, build, buildSingle, defineConfig,
|
|
22
|
+
export { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, type Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, type Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, type ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, type UserConfig, type UserConfigFn, Workspace, build, buildSingle, defineConfig, globalLogger, shimFile };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CCGWF4al.mjs";
|
|
2
|
-
import { build, buildSingle, shimFile } from "./src-
|
|
3
|
-
import {
|
|
2
|
+
import { build, buildSingle, shimFile } from "./src-D6AiyRka.mjs";
|
|
3
|
+
import { globalLogger } from "./logger-CGMSjTLn.mjs";
|
|
4
4
|
|
|
5
|
-
export { build, buildSingle, defineConfig,
|
|
5
|
+
export { build, buildSingle, defineConfig, globalLogger, shimFile };
|
|
@@ -9,7 +9,7 @@ function toArray(val, defaultValue) {
|
|
|
9
9
|
} else return [val];
|
|
10
10
|
}
|
|
11
11
|
function resolveComma(arr) {
|
|
12
|
-
return arr.flatMap((format) => format.split(","));
|
|
12
|
+
return arr.flatMap((format$1) => format$1.split(","));
|
|
13
13
|
}
|
|
14
14
|
function resolveRegex(str) {
|
|
15
15
|
if (typeof str === "string" && str.length > 2 && str[0] === "/" && str.at(-1) === "/") return new RegExp(str.slice(1, -1));
|
|
@@ -32,41 +32,65 @@ const noop = (v) => v;
|
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/utils/logger.ts
|
|
35
|
-
|
|
36
|
-
silent
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
filter(...args) {
|
|
41
|
-
return args.filter((arg) => arg !== void 0 && arg !== false);
|
|
42
|
-
}
|
|
43
|
-
info(...args) {
|
|
44
|
-
if (!this.silent) console.info(blue`ℹ`, ...this.filter(...args));
|
|
45
|
-
}
|
|
46
|
-
warn(...args) {
|
|
47
|
-
if (!this.silent) console.warn("\n", bgYellow` WARN `, ...this.filter(...args), "\n");
|
|
48
|
-
}
|
|
49
|
-
error(...args) {
|
|
50
|
-
if (!this.silent) console.error("\n", bgRed` ERROR `, ...this.filter(...args), "\n");
|
|
51
|
-
}
|
|
52
|
-
success(...args) {
|
|
53
|
-
if (!this.silent) console.info(green`✔`, ...this.filter(...args));
|
|
54
|
-
}
|
|
35
|
+
const LogLevels = {
|
|
36
|
+
silent: 0,
|
|
37
|
+
error: 1,
|
|
38
|
+
warn: 2,
|
|
39
|
+
info: 3
|
|
55
40
|
};
|
|
56
|
-
|
|
41
|
+
function format(msgs) {
|
|
42
|
+
return msgs.filter((arg) => arg !== void 0 && arg !== false).join(" ");
|
|
43
|
+
}
|
|
44
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
|
45
|
+
function createLogger(level = "info", { customLogger, console = globalThis.console, failOnWarn = false } = {}) {
|
|
46
|
+
if (customLogger) return customLogger;
|
|
47
|
+
function output(type, msg) {
|
|
48
|
+
const thresh = LogLevels[logger.level];
|
|
49
|
+
if (thresh < LogLevels[type]) return;
|
|
50
|
+
const method = type === "info" ? "log" : type;
|
|
51
|
+
console[method](msg);
|
|
52
|
+
}
|
|
53
|
+
const logger = {
|
|
54
|
+
level,
|
|
55
|
+
info(...msgs) {
|
|
56
|
+
output("info", `${blue`ℹ`} ${format(msgs)}`);
|
|
57
|
+
},
|
|
58
|
+
warn(...msgs) {
|
|
59
|
+
const message = format(msgs);
|
|
60
|
+
if (failOnWarn) throw new Error(message);
|
|
61
|
+
warnedMessages.add(message);
|
|
62
|
+
output("warn", `\n${bgYellow` WARN `} ${message}\n`);
|
|
63
|
+
},
|
|
64
|
+
warnOnce(...msgs) {
|
|
65
|
+
const message = format(msgs);
|
|
66
|
+
if (warnedMessages.has(message)) return;
|
|
67
|
+
if (failOnWarn) throw new Error(message);
|
|
68
|
+
warnedMessages.add(message);
|
|
69
|
+
output("warn", `\n${bgYellow` WARN `} ${message}\n`);
|
|
70
|
+
},
|
|
71
|
+
error(...msgs) {
|
|
72
|
+
output("error", `\n${bgRed` ERROR `} ${format(msgs)}\n`);
|
|
73
|
+
},
|
|
74
|
+
success(...msgs) {
|
|
75
|
+
output("info", `${green`✔`} ${format(msgs)}`);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return logger;
|
|
79
|
+
}
|
|
80
|
+
const globalLogger = createLogger();
|
|
57
81
|
function prettyName(name) {
|
|
58
82
|
if (!name) return void 0;
|
|
59
83
|
return generateColor(name)(`[${name}]`);
|
|
60
84
|
}
|
|
61
|
-
function prettyFormat(format) {
|
|
62
|
-
const formatColor = format === "es" ? blue : format === "cjs" ? yellow : noop;
|
|
85
|
+
function prettyFormat(format$1) {
|
|
86
|
+
const formatColor = format$1 === "es" ? blue : format$1 === "cjs" ? yellow : noop;
|
|
63
87
|
let formatText;
|
|
64
|
-
switch (format) {
|
|
88
|
+
switch (format$1) {
|
|
65
89
|
case "es":
|
|
66
90
|
formatText = "ESM";
|
|
67
91
|
break;
|
|
68
92
|
default:
|
|
69
|
-
formatText = format.toUpperCase();
|
|
93
|
+
formatText = format$1.toUpperCase();
|
|
70
94
|
break;
|
|
71
95
|
}
|
|
72
96
|
return formatColor(`[${formatText}]`);
|
|
@@ -117,4 +141,4 @@ function hue2rgb(p, q, t) {
|
|
|
117
141
|
}
|
|
118
142
|
|
|
119
143
|
//#endregion
|
|
120
|
-
export { debounce, generateColor,
|
|
144
|
+
export { LogLevels, createLogger, debounce, generateColor, globalLogger, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { version } from "./package-
|
|
1
|
+
import { globalLogger } from "./logger-CGMSjTLn.mjs";
|
|
2
|
+
import { version } from "./package-C-PL6-Mh.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { bold, green, underline } from "ansis";
|
|
5
5
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
@@ -8,18 +8,18 @@ import { createInterface } from "node:readline/promises";
|
|
|
8
8
|
|
|
9
9
|
//#region src/migrate.ts
|
|
10
10
|
async function migrate({ cwd, dryRun }) {
|
|
11
|
-
if (dryRun)
|
|
11
|
+
if (dryRun) globalLogger.info("Dry run enabled. No changes were made.");
|
|
12
12
|
else {
|
|
13
13
|
const rl = createInterface({
|
|
14
14
|
input: process.stdin,
|
|
15
15
|
output: process.stdout
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
globalLogger.warn(`\n\nBefore proceeding, review the migration guide at ${underline`https://tsdown.dev/guide/migrate-from-tsup`}, as this process will modify your files.\nUncommitted changes will be lost. Use the ${green`--dry-run`} flag to preview changes without applying them.`);
|
|
18
18
|
const input = await rl.question(bold`Continue? (Y/n) `);
|
|
19
19
|
rl.close();
|
|
20
20
|
const confirm = input.toLowerCase() === "y" || input === "";
|
|
21
21
|
if (!confirm) {
|
|
22
|
-
|
|
22
|
+
globalLogger.error("Migration cancelled.");
|
|
23
23
|
process.exitCode = 1;
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -27,15 +27,15 @@ async function migrate({ cwd, dryRun }) {
|
|
|
27
27
|
if (cwd) process.chdir(cwd);
|
|
28
28
|
let migrated = await migratePackageJson(dryRun);
|
|
29
29
|
if (await migrateTsupConfig(dryRun)) migrated = true;
|
|
30
|
-
if (migrated)
|
|
30
|
+
if (migrated) globalLogger.success("Migration completed. Remember to run install command with your package manager.");
|
|
31
31
|
else {
|
|
32
|
-
|
|
32
|
+
globalLogger.error("No migration performed.");
|
|
33
33
|
process.exitCode = 1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
async function migratePackageJson(dryRun) {
|
|
37
37
|
if (!existsSync("package.json")) {
|
|
38
|
-
|
|
38
|
+
globalLogger.error("No package.json found");
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
41
|
const pkgRaw = await readFile("package.json", "utf-8");
|
|
@@ -43,44 +43,44 @@ async function migratePackageJson(dryRun) {
|
|
|
43
43
|
const semver = `^${version}`;
|
|
44
44
|
let found = false;
|
|
45
45
|
if (pkg.dependencies?.tsup) {
|
|
46
|
-
|
|
46
|
+
globalLogger.info("Migrating `dependencies` to tsdown.");
|
|
47
47
|
found = true;
|
|
48
48
|
pkg.dependencies = renameKey(pkg.dependencies, "tsup", "tsdown", semver);
|
|
49
49
|
}
|
|
50
50
|
if (pkg.devDependencies?.tsup) {
|
|
51
|
-
|
|
51
|
+
globalLogger.info("Migrating `devDependencies` to tsdown.");
|
|
52
52
|
found = true;
|
|
53
53
|
pkg.devDependencies = renameKey(pkg.devDependencies, "tsup", "tsdown", semver);
|
|
54
54
|
}
|
|
55
55
|
if (pkg.peerDependencies?.tsup) {
|
|
56
|
-
|
|
56
|
+
globalLogger.info("Migrating `peerDependencies` to tsdown.");
|
|
57
57
|
found = true;
|
|
58
58
|
pkg.peerDependencies = renameKey(pkg.peerDependencies, "tsup", "tsdown", "*");
|
|
59
59
|
}
|
|
60
60
|
if (pkg.scripts) {
|
|
61
61
|
for (const key of Object.keys(pkg.scripts)) if (pkg.scripts[key].includes("tsup")) {
|
|
62
|
-
|
|
62
|
+
globalLogger.info(`Migrating \`${key}\` script to tsdown`);
|
|
63
63
|
found = true;
|
|
64
64
|
pkg.scripts[key] = pkg.scripts[key].replaceAll(/tsup(?:-node)?/g, "tsdown");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
if (pkg.tsup) {
|
|
68
|
-
|
|
68
|
+
globalLogger.info("Migrating `tsup` field in package.json to `tsdown`.");
|
|
69
69
|
found = true;
|
|
70
70
|
pkg = renameKey(pkg, "tsup", "tsdown");
|
|
71
71
|
}
|
|
72
72
|
if (!found) {
|
|
73
|
-
|
|
73
|
+
globalLogger.warn("No tsup-related fields found in package.json");
|
|
74
74
|
return false;
|
|
75
75
|
}
|
|
76
76
|
const pkgStr = `${JSON.stringify(pkg, null, 2)}\n`;
|
|
77
77
|
if (dryRun) {
|
|
78
78
|
const { createPatch } = await import("diff");
|
|
79
|
-
|
|
79
|
+
globalLogger.info("[dry-run] package.json:");
|
|
80
80
|
console.info(createPatch("package.json", pkgRaw, pkgStr));
|
|
81
81
|
} else {
|
|
82
82
|
await writeFile("package.json", pkgStr);
|
|
83
|
-
|
|
83
|
+
globalLogger.success("Migrated `package.json`");
|
|
84
84
|
}
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
@@ -97,22 +97,22 @@ async function migrateTsupConfig(dryRun) {
|
|
|
97
97
|
let found = false;
|
|
98
98
|
for (const file of TSUP_FILES) {
|
|
99
99
|
if (!existsSync(file)) continue;
|
|
100
|
-
|
|
100
|
+
globalLogger.info(`Found \`${file}\``);
|
|
101
101
|
found = true;
|
|
102
102
|
const tsupConfigRaw = await readFile(file, "utf-8");
|
|
103
103
|
const tsupConfig = tsupConfigRaw.replaceAll(/\btsup\b/g, "tsdown").replaceAll(/\bTSUP\b/g, "TSDOWN");
|
|
104
104
|
const renamed = file.replaceAll("tsup", "tsdown");
|
|
105
105
|
if (dryRun) {
|
|
106
106
|
const { createTwoFilesPatch } = await import("diff");
|
|
107
|
-
|
|
107
|
+
globalLogger.info(`[dry-run] ${file} -> ${renamed}:`);
|
|
108
108
|
console.info(createTwoFilesPatch(file, renamed, tsupConfigRaw, tsupConfig));
|
|
109
109
|
} else {
|
|
110
110
|
await writeFile(renamed, tsupConfig, "utf8");
|
|
111
111
|
await unlink(file);
|
|
112
|
-
|
|
112
|
+
globalLogger.success(`Migrated \`${file}\` to \`${renamed}\``);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
if (!found)
|
|
115
|
+
if (!found) globalLogger.warn("No tsup config found");
|
|
116
116
|
return found;
|
|
117
117
|
}
|
|
118
118
|
function renameKey(obj, oldKey, newKey, newValue) {
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReportPlugin, ResolvedOptions } from "./types-
|
|
1
|
+
import { Logger, ReportPlugin, ResolvedOptions } from "./types-QuuoDTDl.mjs";
|
|
2
2
|
import { Plugin } from "rolldown";
|
|
3
3
|
import { PackageJson } from "pkg-types";
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import { PackageJson } from "pkg-types";
|
|
|
6
6
|
declare function ExternalPlugin(options: ResolvedOptions): Plugin;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/features/shebang.d.ts
|
|
9
|
-
declare function ShebangPlugin(cwd: string, name?: string, isMultiFormat?: boolean): Plugin;
|
|
9
|
+
declare function ShebangPlugin(logger: Logger, cwd: string, name?: string, isMultiFormat?: boolean): Plugin;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/features/node-protocol.d.ts
|
|
12
12
|
/**
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./config-CCGWF4al.mjs";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-
|
|
3
|
-
import "./logger-
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-D6AiyRka.mjs";
|
|
3
|
+
import "./logger-CGMSjTLn.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { version } from "./package-
|
|
2
|
+
import { globalLogger, resolveComma, toArray } from "./logger-CGMSjTLn.mjs";
|
|
3
|
+
import { version } from "./package-C-PL6-Mh.mjs";
|
|
4
4
|
import module from "node:module";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { dim } from "ansis";
|
|
7
7
|
import { VERSION } from "rolldown";
|
|
8
|
-
import
|
|
8
|
+
import debug from "debug";
|
|
9
9
|
import { cac } from "cac";
|
|
10
10
|
|
|
11
11
|
//#region src/cli.ts
|
|
@@ -14,15 +14,15 @@ cli.help().version(version);
|
|
|
14
14
|
cli.command("[...files]", "Bundle files", {
|
|
15
15
|
ignoreOptionDefaultValue: true,
|
|
16
16
|
allowUnknownOptions: true
|
|
17
|
-
}).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
}).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("-d, --out-dir <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 <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 <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
|
|
18
|
+
globalLogger.level = flags.logLevel || (flags.silent ? "silent" : "info");
|
|
19
|
+
globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
20
20
|
const { build: build$1 } = await import("./index.mjs");
|
|
21
21
|
if (input.length > 0) flags.entry = input;
|
|
22
22
|
await build$1(flags);
|
|
23
23
|
});
|
|
24
24
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
25
|
-
const { migrate } = await import("./migrate-
|
|
25
|
+
const { migrate } = await import("./migrate-BghKfLMP.mjs");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
|
@@ -31,15 +31,15 @@ async function runCLI() {
|
|
|
31
31
|
let namespace;
|
|
32
32
|
if (cli.options.debug === true) namespace = "tsdown:*";
|
|
33
33
|
else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
|
|
34
|
-
const enabled =
|
|
34
|
+
const enabled = debug.disable();
|
|
35
35
|
if (enabled) namespace += `,${enabled}`;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
debug.enable(namespace);
|
|
37
|
+
debug("tsdown:debug")("Debugging enabled", namespace);
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
40
|
await cli.runMatchedCommand();
|
|
41
41
|
} catch (error) {
|
|
42
|
-
|
|
42
|
+
globalLogger.error(error);
|
|
43
43
|
process.exit(1);
|
|
44
44
|
}
|
|
45
45
|
}
|