tsdown 0.13.1 → 0.13.3
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/dist/{config-CZj6NGiw.d.mts → config-aSq_QiwF.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-DScmoUke.mjs} +49 -27
- package/dist/{migrate-ZlgAVcyW.mjs → migrate-DSSpr3yy.mjs} +20 -20
- package/dist/package-Celz_JJW.mjs +5 -0
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +2 -2
- package/dist/run.mjs +7 -7
- package/dist/{src-CbHsyAUh.mjs → src-BaOLpcFF.mjs} +64 -37
- package/dist/{types-DIH2hGTd.d.mts → types-DahUJE7h.d.mts} +34 -6
- package/package.json +11 -11
- package/dist/package-DjP1xJYq.mjs +0 -5
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-DahUJE7h.mjs";
|
|
2
|
+
import { defineConfig } from "./config-aSq_QiwF.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-DahUJE7h.mjs";
|
|
2
|
+
import { defineConfig } from "./config-aSq_QiwF.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-BaOLpcFF.mjs";
|
|
3
|
+
import { globalLogger } from "./logger-DScmoUke.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,63 @@ 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 } = {}) {
|
|
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
|
+
warnedMessages.add(message);
|
|
61
|
+
output("warn", `\n${bgYellow` WARN `} ${message}\n`);
|
|
62
|
+
},
|
|
63
|
+
warnOnce(...msgs) {
|
|
64
|
+
const message = format(msgs);
|
|
65
|
+
if (warnedMessages.has(message)) return;
|
|
66
|
+
warnedMessages.add(message);
|
|
67
|
+
output("warn", `\n${bgYellow` WARN `} ${message}\n`);
|
|
68
|
+
},
|
|
69
|
+
error(...msgs) {
|
|
70
|
+
output("error", `\n${bgRed` ERROR `} ${format(msgs)}\n`);
|
|
71
|
+
},
|
|
72
|
+
success(...msgs) {
|
|
73
|
+
output("info", `${green`✔`} ${format(msgs)}`);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return logger;
|
|
77
|
+
}
|
|
78
|
+
const globalLogger = createLogger();
|
|
57
79
|
function prettyName(name) {
|
|
58
80
|
if (!name) return void 0;
|
|
59
81
|
return generateColor(name)(`[${name}]`);
|
|
60
82
|
}
|
|
61
|
-
function prettyFormat(format) {
|
|
62
|
-
const formatColor = format === "es" ? blue : format === "cjs" ? yellow : noop;
|
|
83
|
+
function prettyFormat(format$1) {
|
|
84
|
+
const formatColor = format$1 === "es" ? blue : format$1 === "cjs" ? yellow : noop;
|
|
63
85
|
let formatText;
|
|
64
|
-
switch (format) {
|
|
86
|
+
switch (format$1) {
|
|
65
87
|
case "es":
|
|
66
88
|
formatText = "ESM";
|
|
67
89
|
break;
|
|
68
90
|
default:
|
|
69
|
-
formatText = format.toUpperCase();
|
|
91
|
+
formatText = format$1.toUpperCase();
|
|
70
92
|
break;
|
|
71
93
|
}
|
|
72
94
|
return formatColor(`[${formatText}]`);
|
|
@@ -117,4 +139,4 @@ function hue2rgb(p, q, t) {
|
|
|
117
139
|
}
|
|
118
140
|
|
|
119
141
|
//#endregion
|
|
120
|
-
export { debounce, generateColor,
|
|
142
|
+
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-DScmoUke.mjs";
|
|
2
|
+
import { version } from "./package-Celz_JJW.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-DahUJE7h.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-BaOLpcFF.mjs";
|
|
3
|
+
import "./logger-DScmoUke.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { version } from "./package-
|
|
2
|
+
import { globalLogger, resolveComma, toArray } from "./logger-DScmoUke.mjs";
|
|
3
|
+
import { version } from "./package-Celz_JJW.mjs";
|
|
4
4
|
import module from "node:module";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { dim } from "ansis";
|
|
@@ -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("-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-DSSpr3yy.mjs");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
|
@@ -39,7 +39,7 @@ async function runCLI() {
|
|
|
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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { debounce, generateColor,
|
|
1
|
+
import { LogLevels, createLogger, debounce, generateColor, globalLogger, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-DScmoUke.mjs";
|
|
2
2
|
import { builtinModules } from "node:module";
|
|
3
3
|
import path, { dirname, normalize, sep } from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
@@ -12,6 +12,8 @@ import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:
|
|
|
12
12
|
import { tmpdir } from "node:os";
|
|
13
13
|
import { promisify } from "node:util";
|
|
14
14
|
import debug from "debug";
|
|
15
|
+
import coerce from "semver/functions/coerce.js";
|
|
16
|
+
import satisfies from "semver/functions/satisfies.js";
|
|
15
17
|
import { glob } from "tinyglobby";
|
|
16
18
|
import { RE_CSS, RE_DTS, RE_JS } from "rolldown-plugin-dts/filename";
|
|
17
19
|
import { createHooks } from "hookable";
|
|
@@ -20,6 +22,7 @@ import { Buffer } from "node:buffer";
|
|
|
20
22
|
import { brotliCompress, gzip } from "node:zlib";
|
|
21
23
|
import readline from "node:readline";
|
|
22
24
|
import minVersion from "semver/ranges/min-version.js";
|
|
25
|
+
import { globalContext, invalidateContextFile } from "rolldown-plugin-dts/tsc-context";
|
|
23
26
|
import { up as up$1 } from "empathic/find";
|
|
24
27
|
import { loadConfig } from "unconfig";
|
|
25
28
|
|
|
@@ -105,7 +108,7 @@ function formatProblem(problem) {
|
|
|
105
108
|
async function attw(options) {
|
|
106
109
|
if (!options.attw) return;
|
|
107
110
|
if (!options.pkg) {
|
|
108
|
-
logger.warn("attw is enabled but package.json is not found");
|
|
111
|
+
options.logger.warn("attw is enabled but package.json is not found");
|
|
109
112
|
return;
|
|
110
113
|
}
|
|
111
114
|
const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
|
|
@@ -116,7 +119,7 @@ async function attw(options) {
|
|
|
116
119
|
try {
|
|
117
120
|
attwCore = await import("@arethetypeswrong/core");
|
|
118
121
|
} catch {
|
|
119
|
-
logger.error(`ATTW check requires ${blue`@arethetypeswrong/core`} to be installed.`);
|
|
122
|
+
options.logger.error(`ATTW check requires ${blue`@arethetypeswrong/core`} to be installed.`);
|
|
120
123
|
return;
|
|
121
124
|
}
|
|
122
125
|
try {
|
|
@@ -139,11 +142,11 @@ async function attw(options) {
|
|
|
139
142
|
const problemList = problems.map(formatProblem).join("\n");
|
|
140
143
|
const problemMessage = `Are the types wrong problems found:\n${problemList}`;
|
|
141
144
|
if (level === "error") throw new Error(problemMessage);
|
|
142
|
-
logger.warn(problemMessage);
|
|
145
|
+
options.logger.warn(problemMessage);
|
|
143
146
|
}
|
|
144
|
-
} else logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
147
|
+
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
145
148
|
} catch (error) {
|
|
146
|
-
logger.error("ATTW check failed:", error);
|
|
149
|
+
options.logger.error("ATTW check failed:", error);
|
|
147
150
|
debug$7("Found errors, setting exit code to 1");
|
|
148
151
|
process.exitCode = 1;
|
|
149
152
|
} finally {
|
|
@@ -151,6 +154,22 @@ async function attw(options) {
|
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/features/cjs.ts
|
|
159
|
+
/**
|
|
160
|
+
* If the config includes the `cjs` format and
|
|
161
|
+
* one of its target >= node 23.0.0 / 22.12.0,
|
|
162
|
+
* warn the user about the deprecation of CommonJS.
|
|
163
|
+
*/
|
|
164
|
+
function warnLegacyCJS(config) {
|
|
165
|
+
if (!config.format.includes("cjs") || !config.target) return;
|
|
166
|
+
const legacy = config.target.some((t) => {
|
|
167
|
+
const version = coerce(t.split("node")[1]);
|
|
168
|
+
return version && satisfies(version, ">=23.0.0 || >=22.12.0");
|
|
169
|
+
});
|
|
170
|
+
if (legacy) config.logger.warnOnce("We recommend using the ESM format instead of CommonJS.\nThe ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.\nLearn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here");
|
|
171
|
+
}
|
|
172
|
+
|
|
154
173
|
//#endregion
|
|
155
174
|
//#region src/features/clean.ts
|
|
156
175
|
const debug$6 = debug("tsdown:clean");
|
|
@@ -171,7 +190,7 @@ async function cleanOutDir(configs) {
|
|
|
171
190
|
}
|
|
172
191
|
}
|
|
173
192
|
if (!removes.size) return;
|
|
174
|
-
|
|
193
|
+
globalLogger.info(`Cleaning ${removes.size} files`);
|
|
175
194
|
await Promise.all([...removes].map(async (file) => {
|
|
176
195
|
debug$6("Removing", file);
|
|
177
196
|
await fsRemove(file);
|
|
@@ -540,7 +559,7 @@ const debug$3 = debug("tsdown:publint");
|
|
|
540
559
|
async function publint(options) {
|
|
541
560
|
if (!options.publint) return;
|
|
542
561
|
if (!options.pkg) {
|
|
543
|
-
logger.warn("publint is enabled but package.json is not found");
|
|
562
|
+
options.logger.warn("publint is enabled but package.json is not found");
|
|
544
563
|
return;
|
|
545
564
|
}
|
|
546
565
|
const t = performance.now();
|
|
@@ -549,7 +568,7 @@ async function publint(options) {
|
|
|
549
568
|
const { formatMessage } = await import("publint/utils");
|
|
550
569
|
const { messages } = await publint$1(options.publint === true ? {} : options.publint);
|
|
551
570
|
debug$3("Found %d issues", messages.length);
|
|
552
|
-
if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
571
|
+
if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
553
572
|
let hasError = false;
|
|
554
573
|
for (const message of messages) {
|
|
555
574
|
hasError ||= message.type === "error";
|
|
@@ -559,7 +578,7 @@ async function publint(options) {
|
|
|
559
578
|
warning: "warn",
|
|
560
579
|
suggestion: "info"
|
|
561
580
|
}[message.type];
|
|
562
|
-
logger[logType](formattedMessage);
|
|
581
|
+
options.logger[logType](formattedMessage);
|
|
563
582
|
}
|
|
564
583
|
if (hasError) {
|
|
565
584
|
debug$3("Found errors, setting exit code to 1");
|
|
@@ -579,7 +598,7 @@ function formatBytes(bytes) {
|
|
|
579
598
|
const debug$2 = debug("tsdown:report");
|
|
580
599
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
581
600
|
const gzipAsync = promisify(gzip);
|
|
582
|
-
function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
|
|
601
|
+
function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
583
602
|
return {
|
|
584
603
|
name: "tsdown:report",
|
|
585
604
|
async writeBundle(outputOptions, bundle) {
|
|
@@ -686,12 +705,12 @@ function shortcuts(restart) {
|
|
|
686
705
|
];
|
|
687
706
|
if (input === "h") {
|
|
688
707
|
const loggedKeys = /* @__PURE__ */ new Set();
|
|
689
|
-
|
|
708
|
+
globalLogger.info(" Shortcuts");
|
|
690
709
|
for (const shortcut$1 of SHORTCUTS) {
|
|
691
710
|
if (loggedKeys.has(shortcut$1.key)) continue;
|
|
692
711
|
loggedKeys.add(shortcut$1.key);
|
|
693
712
|
if (shortcut$1.action == null) continue;
|
|
694
|
-
|
|
713
|
+
globalLogger.info(dim` press ` + bold`${shortcut$1.key} + enter` + dim` to ${shortcut$1.description}`);
|
|
695
714
|
}
|
|
696
715
|
return;
|
|
697
716
|
}
|
|
@@ -707,7 +726,7 @@ function shortcuts(restart) {
|
|
|
707
726
|
|
|
708
727
|
//#endregion
|
|
709
728
|
//#region src/features/target.ts
|
|
710
|
-
function resolveTarget(target, pkg, name) {
|
|
729
|
+
function resolveTarget(logger, target, pkg, name) {
|
|
711
730
|
if (target === false) return;
|
|
712
731
|
if (target == null) {
|
|
713
732
|
const pkgTarget = resolvePackageTarget(pkg);
|
|
@@ -727,7 +746,7 @@ function resolvePackageTarget(pkg) {
|
|
|
727
746
|
return `node${nodeMinVersion.version}`;
|
|
728
747
|
}
|
|
729
748
|
let warned = false;
|
|
730
|
-
function RuntimeHelperCheckPlugin(targets) {
|
|
749
|
+
function RuntimeHelperCheckPlugin(logger, targets) {
|
|
731
750
|
return {
|
|
732
751
|
name: "tsdown:runtime-helper-check",
|
|
733
752
|
resolveId: {
|
|
@@ -758,7 +777,7 @@ const endsWithConfig = /[\\/](?:package\.json|tsdown\.config.*)$/;
|
|
|
758
777
|
async function watchBuild(options, configFiles, rebuild, restart) {
|
|
759
778
|
if (typeof options.watch === "boolean" && options.outDir === options.cwd) throw new Error(`Watch is enabled, but output directory is the same as the current working directory.Please specify a different watch directory using ${blue`watch`} option,or set ${blue`outDir`} to a different directory.`);
|
|
760
779
|
const files = toArray(typeof options.watch === "boolean" ? options.cwd : options.watch);
|
|
761
|
-
logger.info(`Watching for changes in ${files.join(", ")}`);
|
|
780
|
+
options.logger.info(`Watching for changes in ${files.join(", ")}`);
|
|
762
781
|
files.push(...configFiles);
|
|
763
782
|
const { watch } = await import("chokidar");
|
|
764
783
|
const debouncedRebuild = debounce(rebuild, 100);
|
|
@@ -769,16 +788,17 @@ async function watchBuild(options, configFiles, rebuild, restart) {
|
|
|
769
788
|
/[\\/]\.git[\\/]/,
|
|
770
789
|
/[\\/]node_modules[\\/]/,
|
|
771
790
|
options.outDir,
|
|
772
|
-
...
|
|
791
|
+
...options.ignoreWatch
|
|
773
792
|
]
|
|
774
793
|
});
|
|
775
794
|
watcher.on("all", (type, file) => {
|
|
776
795
|
if (configFiles.includes(file) || endsWithConfig.test(file)) {
|
|
777
|
-
logger.info(`Reload config: ${file}`);
|
|
796
|
+
options.logger.info(`Reload config: ${file}`);
|
|
778
797
|
restart();
|
|
779
798
|
return;
|
|
780
799
|
}
|
|
781
|
-
logger.info(`Change detected: ${type} ${file}`);
|
|
800
|
+
options.logger.info(`Change detected: ${type} ${file}`);
|
|
801
|
+
invalidateContextFile(globalContext, file);
|
|
782
802
|
debouncedRebuild();
|
|
783
803
|
});
|
|
784
804
|
return watcher;
|
|
@@ -786,7 +806,7 @@ async function watchBuild(options, configFiles, rebuild, restart) {
|
|
|
786
806
|
|
|
787
807
|
//#endregion
|
|
788
808
|
//#region src/features/entry.ts
|
|
789
|
-
async function resolveEntry(entry, cwd, name) {
|
|
809
|
+
async function resolveEntry(logger, entry, cwd, name) {
|
|
790
810
|
const nameLabel = name ? `[${name}] ` : "";
|
|
791
811
|
if (!entry || Object.keys(entry).length === 0) {
|
|
792
812
|
const defaultEntry = path.resolve(cwd, "src/index.ts");
|
|
@@ -815,7 +835,7 @@ async function toObjectEntry(entry, cwd) {
|
|
|
815
835
|
function findTsconfig(cwd, name = "tsconfig.json") {
|
|
816
836
|
return up$1(name, { cwd }) || false;
|
|
817
837
|
}
|
|
818
|
-
async function resolveTsconfig(tsconfig, cwd, name) {
|
|
838
|
+
async function resolveTsconfig(logger, tsconfig, cwd, name) {
|
|
819
839
|
const original = tsconfig;
|
|
820
840
|
if (tsconfig !== false) {
|
|
821
841
|
if (tsconfig === true || tsconfig == null) {
|
|
@@ -859,7 +879,7 @@ async function loadViteConfig(prefix, cwd) {
|
|
|
859
879
|
defaults: {}
|
|
860
880
|
});
|
|
861
881
|
if (!source) return;
|
|
862
|
-
|
|
882
|
+
globalLogger.info(`Using Vite config: ${underline(source)}`);
|
|
863
883
|
const resolved = await config;
|
|
864
884
|
if (typeof resolved === "function") return resolved({
|
|
865
885
|
command: "build",
|
|
@@ -915,11 +935,11 @@ async function loadConfigFile(options, workspace) {
|
|
|
915
935
|
stopAt: workspace && path.dirname(workspace),
|
|
916
936
|
defaults: {}
|
|
917
937
|
}).finally(() => loaded = true);
|
|
918
|
-
const file = sources[0];
|
|
919
|
-
if (file) logger.info(`Using tsdown config: ${underline(file)}`);
|
|
920
938
|
if (typeof config === "function") config = await config(options);
|
|
921
939
|
config = toArray(config);
|
|
922
940
|
if (config.length === 0) config.push({});
|
|
941
|
+
const file = sources[0];
|
|
942
|
+
if (file) globalLogger.info(`Using tsdown config: ${underline(file)}`);
|
|
923
943
|
return {
|
|
924
944
|
configs: config,
|
|
925
945
|
file
|
|
@@ -1014,17 +1034,18 @@ async function resolveWorkspace(config, options) {
|
|
|
1014
1034
|
};
|
|
1015
1035
|
}
|
|
1016
1036
|
async function resolveConfig(userConfig) {
|
|
1017
|
-
let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch = [], shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol } = userConfig;
|
|
1037
|
+
let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch = [], shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol } = userConfig;
|
|
1038
|
+
const logger = createLogger(logLevel, { customLogger });
|
|
1018
1039
|
if (typeof bundle === "boolean") logger.warn("`bundle` option is deprecated. Use `unbundle` instead.");
|
|
1019
1040
|
nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
|
|
1020
1041
|
outDir = path.resolve(cwd, outDir);
|
|
1021
1042
|
clean = resolveClean(clean, outDir, cwd);
|
|
1022
1043
|
const pkg = await readPackageJson(cwd);
|
|
1023
1044
|
if (workspace) name ||= pkg?.name;
|
|
1024
|
-
entry = await resolveEntry(entry, cwd, name);
|
|
1045
|
+
entry = await resolveEntry(logger, entry, cwd, name);
|
|
1025
1046
|
if (dts == null) dts = !!(pkg?.types || pkg?.typings);
|
|
1026
|
-
target = resolveTarget(target, pkg, name);
|
|
1027
|
-
tsconfig = await resolveTsconfig(tsconfig, cwd, name);
|
|
1047
|
+
target = resolveTarget(logger, target, pkg, name);
|
|
1048
|
+
tsconfig = await resolveTsconfig(logger, tsconfig, cwd, name);
|
|
1028
1049
|
if (typeof external === "string") external = resolveRegex(external);
|
|
1029
1050
|
if (typeof noExternal === "string") noExternal = resolveRegex(noExternal);
|
|
1030
1051
|
if (publint$1 === true) publint$1 = {};
|
|
@@ -1041,6 +1062,11 @@ async function resolveConfig(userConfig) {
|
|
|
1041
1062
|
if (viteAlias && !Array.isArray(viteAlias)) alias = viteAlias;
|
|
1042
1063
|
}
|
|
1043
1064
|
}
|
|
1065
|
+
ignoreWatch = toArray(ignoreWatch).map((ignore) => {
|
|
1066
|
+
ignore = resolveRegex(ignore);
|
|
1067
|
+
if (typeof ignore === "string") return path.resolve(cwd, ignore);
|
|
1068
|
+
return ignore;
|
|
1069
|
+
});
|
|
1044
1070
|
const config = {
|
|
1045
1071
|
...userConfig,
|
|
1046
1072
|
entry,
|
|
@@ -1049,7 +1075,7 @@ async function resolveConfig(userConfig) {
|
|
|
1049
1075
|
target,
|
|
1050
1076
|
outDir,
|
|
1051
1077
|
clean,
|
|
1052
|
-
|
|
1078
|
+
logger,
|
|
1053
1079
|
treeshake,
|
|
1054
1080
|
platform,
|
|
1055
1081
|
sourcemap,
|
|
@@ -1089,7 +1115,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
1089
1115
|
//#endregion
|
|
1090
1116
|
//#region src/features/shebang.ts
|
|
1091
1117
|
const RE_SHEBANG = /^#!.*/;
|
|
1092
|
-
function ShebangPlugin(cwd, name, isMultiFormat) {
|
|
1118
|
+
function ShebangPlugin(logger, cwd, name, isMultiFormat) {
|
|
1093
1119
|
return {
|
|
1094
1120
|
name: "tsdown:shebang",
|
|
1095
1121
|
async writeBundle(options, bundle) {
|
|
@@ -1112,14 +1138,14 @@ function ShebangPlugin(cwd, name, isMultiFormat) {
|
|
|
1112
1138
|
* Build with tsdown.
|
|
1113
1139
|
*/
|
|
1114
1140
|
async function build$1(userOptions = {}) {
|
|
1115
|
-
|
|
1141
|
+
globalLogger.level = userOptions.logLevel || (userOptions.silent ? "silent" : "info");
|
|
1116
1142
|
const { configs, files: configFiles } = await resolveOptions(userOptions);
|
|
1117
1143
|
let cleanPromise;
|
|
1118
1144
|
const clean = () => {
|
|
1119
1145
|
if (cleanPromise) return cleanPromise;
|
|
1120
1146
|
return cleanPromise = cleanOutDir(configs);
|
|
1121
1147
|
};
|
|
1122
|
-
|
|
1148
|
+
globalLogger.info("Build start");
|
|
1123
1149
|
const rebuilds = await Promise.all(configs.map((options) => buildSingle(options, clean)));
|
|
1124
1150
|
const disposeCbs = [];
|
|
1125
1151
|
for (const [i, config] of configs.entries()) {
|
|
@@ -1147,9 +1173,10 @@ const shimFile = path.resolve(pkgRoot, "esm-shims.js");
|
|
|
1147
1173
|
* @param config Resolved options
|
|
1148
1174
|
*/
|
|
1149
1175
|
async function buildSingle(config, clean) {
|
|
1150
|
-
const { format: formats, dts, watch, onSuccess } = config;
|
|
1176
|
+
const { format: formats, dts, watch, onSuccess, logger } = config;
|
|
1151
1177
|
let ab;
|
|
1152
1178
|
const { hooks, context } = await createHooks$1(config);
|
|
1179
|
+
warnLegacyCJS(config);
|
|
1153
1180
|
await rebuild(true);
|
|
1154
1181
|
if (watch) return () => rebuild();
|
|
1155
1182
|
async function rebuild(first) {
|
|
@@ -1204,7 +1231,7 @@ async function buildSingle(config, clean) {
|
|
|
1204
1231
|
}
|
|
1205
1232
|
}
|
|
1206
1233
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
1207
|
-
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, unbundle, banner, footer } = config;
|
|
1234
|
+
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, unbundle, banner, footer, logger } = config;
|
|
1208
1235
|
const plugins = [];
|
|
1209
1236
|
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
1210
1237
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
@@ -1225,10 +1252,10 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
|
1225
1252
|
const { Unused } = await import("unplugin-unused");
|
|
1226
1253
|
plugins.push(Unused.rolldown(unused === true ? {} : unused));
|
|
1227
1254
|
}
|
|
1228
|
-
if (target) plugins.push(RuntimeHelperCheckPlugin(target), await LightningCSSPlugin({ target }));
|
|
1229
|
-
plugins.push(ShebangPlugin(cwd, name, isMultiFormat));
|
|
1255
|
+
if (target) plugins.push(RuntimeHelperCheckPlugin(logger, target), await LightningCSSPlugin({ target }));
|
|
1256
|
+
plugins.push(ShebangPlugin(logger, cwd, name, isMultiFormat));
|
|
1230
1257
|
}
|
|
1231
|
-
if (report &&
|
|
1258
|
+
if (report && LogLevels[logger.level] >= 3) plugins.push(ReportPlugin(report, logger, cwd, cjsDts, name, isMultiFormat));
|
|
1232
1259
|
if (!cjsDts) plugins.push(userPlugins);
|
|
1233
1260
|
cjsDts = !!cjsDts;
|
|
1234
1261
|
const inputOptions = await mergeUserOptions({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "ansis";
|
|
1
2
|
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, OutputAsset, OutputChunk, OutputOptions, Plugin } from "rolldown";
|
|
2
3
|
import { Hookable } from "hookable";
|
|
3
4
|
import { CheckPackageOptions } from "@arethetypeswrong/core";
|
|
@@ -122,6 +123,19 @@ type ChunkAddonFunction = (ctx: {
|
|
|
122
123
|
}) => ChunkAddonObject | undefined;
|
|
123
124
|
type ChunkAddon = ChunkAddonObject | ChunkAddonFunction;
|
|
124
125
|
//#endregion
|
|
126
|
+
//#region src/utils/logger.d.ts
|
|
127
|
+
type LogType = "error" | "warn" | "info";
|
|
128
|
+
type LogLevel = LogType | "silent";
|
|
129
|
+
interface Logger {
|
|
130
|
+
level: LogLevel;
|
|
131
|
+
info: (...args: any[]) => void;
|
|
132
|
+
warn: (...args: any[]) => void;
|
|
133
|
+
warnOnce: (...args: any[]) => void;
|
|
134
|
+
error: (...args: any[]) => void;
|
|
135
|
+
success: (...args: any[]) => void;
|
|
136
|
+
}
|
|
137
|
+
declare const globalLogger: Logger;
|
|
138
|
+
//#endregion
|
|
125
139
|
//#region src/features/report.d.ts
|
|
126
140
|
interface ReportOptions {
|
|
127
141
|
/**
|
|
@@ -137,7 +151,7 @@ interface ReportOptions {
|
|
|
137
151
|
*/
|
|
138
152
|
maxCompressSize?: number;
|
|
139
153
|
}
|
|
140
|
-
declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: boolean, name?: string, isMultiFormat?: boolean): Plugin;
|
|
154
|
+
declare function ReportPlugin(options: ReportOptions, logger: Logger, cwd: string, cjsDts?: boolean, name?: string, isMultiFormat?: boolean): Plugin;
|
|
141
155
|
//#endregion
|
|
142
156
|
//#region src/options/types.d.ts
|
|
143
157
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
@@ -275,15 +289,27 @@ interface Options {
|
|
|
275
289
|
* ```
|
|
276
290
|
*/
|
|
277
291
|
loader?: ModuleTypes;
|
|
278
|
-
/**
|
|
292
|
+
/**
|
|
293
|
+
* @default false
|
|
294
|
+
* @deprecated Use `logLevel` instead.
|
|
295
|
+
*/
|
|
279
296
|
silent?: boolean;
|
|
280
297
|
/**
|
|
298
|
+
* Log level.
|
|
299
|
+
* @default 'info'
|
|
300
|
+
*/
|
|
301
|
+
logLevel?: LogLevel;
|
|
302
|
+
/**
|
|
303
|
+
* Custom logger.
|
|
304
|
+
*/
|
|
305
|
+
customLogger?: Logger;
|
|
306
|
+
/**
|
|
281
307
|
* Config file path
|
|
282
308
|
*/
|
|
283
309
|
config?: boolean | string;
|
|
284
310
|
/** @default false */
|
|
285
|
-
watch?: boolean | string
|
|
286
|
-
ignoreWatch?: string |
|
|
311
|
+
watch?: boolean | Arrayable<string>;
|
|
312
|
+
ignoreWatch?: Arrayable<string | RegExp>;
|
|
287
313
|
/**
|
|
288
314
|
* You can specify command to be executed after a successful build, specially useful for Watch mode
|
|
289
315
|
*/
|
|
@@ -422,7 +448,7 @@ interface Options {
|
|
|
422
448
|
type UserConfig = Arrayable<Omit<Options, "config" | "filter">>;
|
|
423
449
|
type UserConfigFn = (cliOptions: Options) => Awaitable<UserConfig>;
|
|
424
450
|
type NormalizedUserConfig = Exclude<UserConfig, any[]>;
|
|
425
|
-
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "bundle" | "banner" | "footer">, {
|
|
451
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "workspace" | "filter" | "silent" | "logLevel" | "customLogger">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "bundle" | "banner" | "footer">, {
|
|
426
452
|
format: NormalizedFormat[];
|
|
427
453
|
target?: string[];
|
|
428
454
|
clean: string[];
|
|
@@ -432,6 +458,8 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "w
|
|
|
432
458
|
pkg?: PackageJson;
|
|
433
459
|
exports: false | ExportsOptions;
|
|
434
460
|
nodeProtocol: "strip" | boolean;
|
|
461
|
+
logger: Logger;
|
|
462
|
+
ignoreWatch: Array<string | RegExp>;
|
|
435
463
|
}>, "config" | "fromVite">;
|
|
436
464
|
//#endregion
|
|
437
|
-
export { type AttwOptions, type BuildContext, type ChunkAddon, type ChunkAddonFunction, type ChunkAddonObject, type CopyEntry, type CopyOptions, type CopyOptionsFn, type DtsOptions, type ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, type OutExtensionContext, type OutExtensionFactory, type OutExtensionObject, type PackageType, type PublintOptions, type ReportOptions, ReportPlugin, ResolvedOptions, type RolldownContext, Sourcemap, type TsdownChunks, type TsdownHooks, type UnusedOptions, UserConfig, UserConfigFn, Workspace };
|
|
465
|
+
export { type AttwOptions, type BuildContext, type ChunkAddon, type ChunkAddonFunction, type ChunkAddonObject, type CopyEntry, type CopyOptions, type CopyOptionsFn, type DtsOptions, type ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, type OutExtensionContext, type OutExtensionFactory, type OutExtensionObject, type PackageType, type PublintOptions, type ReportOptions, ReportPlugin, ResolvedOptions, type RolldownContext, Sourcemap, type TsdownChunks, type TsdownHooks, type UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"diff": "^8.0.2",
|
|
75
75
|
"empathic": "^2.0.0",
|
|
76
76
|
"hookable": "^5.5.3",
|
|
77
|
-
"rolldown": "^1.0.0-beta.
|
|
78
|
-
"rolldown-plugin-dts": "^0.
|
|
77
|
+
"rolldown": "^1.0.0-beta.31",
|
|
78
|
+
"rolldown-plugin-dts": "^0.15.3",
|
|
79
79
|
"semver": "^7.7.2",
|
|
80
80
|
"tinyexec": "^1.0.1",
|
|
81
81
|
"tinyglobby": "^0.2.14",
|
|
@@ -84,27 +84,27 @@
|
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@arethetypeswrong/core": "^0.18.2",
|
|
87
|
-
"@sxzz/eslint-config": "^7.1.
|
|
87
|
+
"@sxzz/eslint-config": "^7.1.2",
|
|
88
88
|
"@sxzz/prettier-config": "^2.2.3",
|
|
89
89
|
"@sxzz/test-utils": "^0.5.9",
|
|
90
90
|
"@types/debug": "^4.1.12",
|
|
91
|
-
"@types/node": "^24.
|
|
91
|
+
"@types/node": "^24.2.0",
|
|
92
92
|
"@types/semver": "^7.7.0",
|
|
93
|
-
"@unocss/eslint-plugin": "^66.
|
|
93
|
+
"@unocss/eslint-plugin": "^66.4.1",
|
|
94
94
|
"@vueuse/core": "^13.6.0",
|
|
95
|
-
"bumpp": "^10.2.
|
|
95
|
+
"bumpp": "^10.2.2",
|
|
96
96
|
"eslint": "^9.32.0",
|
|
97
97
|
"lightningcss": "^1.30.1",
|
|
98
|
-
"oxc-minify": "^0.
|
|
98
|
+
"oxc-minify": "^0.80.0",
|
|
99
99
|
"pkg-types": "^2.2.0",
|
|
100
100
|
"prettier": "^3.6.2",
|
|
101
101
|
"publint": "^0.3.12",
|
|
102
102
|
"tsx": "^4.20.3",
|
|
103
|
-
"typedoc": "^0.28.
|
|
103
|
+
"typedoc": "^0.28.9",
|
|
104
104
|
"typedoc-plugin-markdown": "^4.8.0",
|
|
105
105
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
106
|
-
"typescript": "~5.
|
|
107
|
-
"unocss": "^66.
|
|
106
|
+
"typescript": "~5.9.2",
|
|
107
|
+
"unocss": "^66.4.1",
|
|
108
108
|
"unplugin-lightningcss": "^0.4.1",
|
|
109
109
|
"unplugin-unused": "^0.5.1",
|
|
110
110
|
"vite": "npm:rolldown-vite@latest",
|