tsdown 0.13.5 → 0.14.1
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/index.mjs +1 -1
- package/dist/{migrate-BCQUL2Gs.mjs → migrate-ByqyzNKc.mjs} +1 -1
- package/dist/package-hNMMm6hX.mjs +5 -0
- package/dist/plugins.mjs +1 -1
- package/dist/run.d.mts +1 -1
- package/dist/run.mjs +8 -7
- package/dist/{src-D6AiyRka.mjs → src-XtWW9dvn.mjs} +42 -39
- package/package.json +3 -3
- package/dist/package-TDRl9aMv.mjs +0 -5
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CCGWF4al.mjs";
|
|
2
|
-
import { build, buildSingle, shimFile } from "./src-
|
|
2
|
+
import { build, buildSingle, shimFile } from "./src-XtWW9dvn.mjs";
|
|
3
3
|
import { globalLogger } from "./logger-CGMSjTLn.mjs";
|
|
4
4
|
|
|
5
5
|
export { build, buildSingle, defineConfig, globalLogger, shimFile };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { globalLogger } from "./logger-CGMSjTLn.mjs";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-hNMMm6hX.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";
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./config-CCGWF4al.mjs";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-XtWW9dvn.mjs";
|
|
3
3
|
import "./logger-CGMSjTLn.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
package/dist/run.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { globalLogger, resolveComma, toArray } from "./logger-CGMSjTLn.mjs";
|
|
3
|
-
import { version } from "./package-
|
|
3
|
+
import { version } from "./package-hNMMm6hX.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
|
|
@@ -22,7 +22,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
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-ByqyzNKc.mjs");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
|
@@ -31,10 +31,10 @@ 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();
|
|
@@ -51,4 +51,5 @@ try {
|
|
|
51
51
|
} catch {}
|
|
52
52
|
runCLI();
|
|
53
53
|
|
|
54
|
-
//#endregion
|
|
54
|
+
//#endregion
|
|
55
|
+
export { };
|
|
@@ -11,7 +11,7 @@ import child_process from "node:child_process";
|
|
|
11
11
|
import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
12
12
|
import { tmpdir } from "node:os";
|
|
13
13
|
import { promisify } from "node:util";
|
|
14
|
-
import
|
|
14
|
+
import Debug from "debug";
|
|
15
15
|
import coerce from "semver/functions/coerce.js";
|
|
16
16
|
import satisfies from "semver/functions/satisfies.js";
|
|
17
17
|
import { glob } from "tinyglobby";
|
|
@@ -66,7 +66,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region src/features/attw.ts
|
|
69
|
-
const debug$
|
|
69
|
+
const debug$7 = Debug("tsdown:attw");
|
|
70
70
|
const exec$1 = promisify(child_process.exec);
|
|
71
71
|
/**
|
|
72
72
|
* ATTW profiles.
|
|
@@ -113,7 +113,7 @@ async function attw(options) {
|
|
|
113
113
|
}
|
|
114
114
|
const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
|
|
115
115
|
const t = performance.now();
|
|
116
|
-
debug$
|
|
116
|
+
debug$7("Running attw check");
|
|
117
117
|
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
118
118
|
let attwCore;
|
|
119
119
|
try {
|
|
@@ -147,7 +147,7 @@ async function attw(options) {
|
|
|
147
147
|
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
148
148
|
} catch (error) {
|
|
149
149
|
options.logger.error("ATTW check failed:", error);
|
|
150
|
-
debug$
|
|
150
|
+
debug$7("Found errors, setting exit code to 1");
|
|
151
151
|
process.exitCode = 1;
|
|
152
152
|
} finally {
|
|
153
153
|
await fsRemove(tempDir);
|
|
@@ -172,7 +172,7 @@ function warnLegacyCJS(config) {
|
|
|
172
172
|
|
|
173
173
|
//#endregion
|
|
174
174
|
//#region src/features/clean.ts
|
|
175
|
-
const debug$
|
|
175
|
+
const debug$6 = Debug("tsdown:clean");
|
|
176
176
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
177
177
|
async function cleanOutDir(configs) {
|
|
178
178
|
const removes = /* @__PURE__ */ new Set();
|
|
@@ -192,10 +192,10 @@ async function cleanOutDir(configs) {
|
|
|
192
192
|
if (!removes.size) return;
|
|
193
193
|
globalLogger.info(`Cleaning ${removes.size} files`);
|
|
194
194
|
await Promise.all([...removes].map(async (file) => {
|
|
195
|
-
debug$
|
|
195
|
+
debug$6("Removing", file);
|
|
196
196
|
await fsRemove(file);
|
|
197
197
|
}));
|
|
198
|
-
debug$
|
|
198
|
+
debug$6("Removed %d files", removes.size);
|
|
199
199
|
}
|
|
200
200
|
function resolveClean(clean, outDir, cwd) {
|
|
201
201
|
if (clean === true) clean = [slash(outDir)];
|
|
@@ -345,7 +345,7 @@ async function createHooks$1(options) {
|
|
|
345
345
|
|
|
346
346
|
//#endregion
|
|
347
347
|
//#region src/features/publint.ts
|
|
348
|
-
const debug$
|
|
348
|
+
const debug$5 = Debug("tsdown:publint");
|
|
349
349
|
async function publint(options) {
|
|
350
350
|
if (!options.publint) return;
|
|
351
351
|
if (!options.pkg) {
|
|
@@ -353,11 +353,11 @@ async function publint(options) {
|
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
355
|
const t = performance.now();
|
|
356
|
-
debug$
|
|
356
|
+
debug$5("Running publint");
|
|
357
357
|
const { publint: publint$1 } = await import("publint");
|
|
358
358
|
const { formatMessage } = await import("publint/utils");
|
|
359
359
|
const { messages } = await publint$1(options.publint === true ? {} : options.publint);
|
|
360
|
-
debug$
|
|
360
|
+
debug$5("Found %d issues", messages.length);
|
|
361
361
|
if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
362
362
|
let hasError = false;
|
|
363
363
|
for (const message of messages) {
|
|
@@ -371,7 +371,7 @@ async function publint(options) {
|
|
|
371
371
|
options.logger[logType](formattedMessage);
|
|
372
372
|
}
|
|
373
373
|
if (hasError) {
|
|
374
|
-
debug$
|
|
374
|
+
debug$5("Found errors, setting exit code to 1");
|
|
375
375
|
process.exitCode = 1;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -394,7 +394,10 @@ async function resolveEntry(logger, entry, cwd, name) {
|
|
|
394
394
|
async function toObjectEntry(entry, cwd) {
|
|
395
395
|
if (typeof entry === "string") entry = [entry];
|
|
396
396
|
if (!Array.isArray(entry)) return entry;
|
|
397
|
-
const resolvedEntry = (await glob(entry, {
|
|
397
|
+
const resolvedEntry = (await glob(entry, {
|
|
398
|
+
cwd,
|
|
399
|
+
expandDirectories: false
|
|
400
|
+
})).map((file) => path.resolve(cwd, file));
|
|
398
401
|
const base = lowestCommonAncestor(...resolvedEntry);
|
|
399
402
|
return Object.fromEntries(resolvedEntry.map((file) => {
|
|
400
403
|
const relative = path.relative(base, file);
|
|
@@ -479,11 +482,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
|
|
|
479
482
|
|
|
480
483
|
//#endregion
|
|
481
484
|
//#region src/utils/package.ts
|
|
482
|
-
const debug$
|
|
485
|
+
const debug$4 = Debug("tsdown:package");
|
|
483
486
|
async function readPackageJson(dir) {
|
|
484
487
|
const packageJsonPath = up$1({ cwd: dir });
|
|
485
488
|
if (!packageJsonPath) return;
|
|
486
|
-
debug$
|
|
489
|
+
debug$4("Reading package.json:", packageJsonPath);
|
|
487
490
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
488
491
|
return {
|
|
489
492
|
...JSON.parse(contents),
|
|
@@ -599,7 +602,7 @@ async function loadConfigFile(options, workspace) {
|
|
|
599
602
|
|
|
600
603
|
//#endregion
|
|
601
604
|
//#region src/options/index.ts
|
|
602
|
-
const debug$
|
|
605
|
+
const debug$3 = Debug("tsdown:options");
|
|
603
606
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
604
607
|
"**/node_modules/**",
|
|
605
608
|
"**/dist/**",
|
|
@@ -607,20 +610,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
607
610
|
"**/t?(e)mp/**"
|
|
608
611
|
];
|
|
609
612
|
async function resolveOptions(options) {
|
|
610
|
-
debug$
|
|
613
|
+
debug$3("options %O", options);
|
|
611
614
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
612
615
|
const files = [];
|
|
613
616
|
if (file) {
|
|
614
617
|
files.push(file);
|
|
615
|
-
debug$
|
|
616
|
-
debug$
|
|
617
|
-
} else debug$
|
|
618
|
+
debug$3("loaded root config file %s", file);
|
|
619
|
+
debug$3("root configs %O", rootConfigs);
|
|
620
|
+
} else debug$3("no root config file found");
|
|
618
621
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
619
622
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
620
623
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
621
624
|
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
|
|
622
625
|
}))).flat();
|
|
623
|
-
debug$
|
|
626
|
+
debug$3("resolved configs %O", configs);
|
|
624
627
|
return {
|
|
625
628
|
configs,
|
|
626
629
|
files
|
|
@@ -640,17 +643,17 @@ async function resolveWorkspace(config, options) {
|
|
|
640
643
|
if (workspace === true) workspace = {};
|
|
641
644
|
else if (typeof workspace === "string" || Array.isArray(workspace)) workspace = { include: workspace };
|
|
642
645
|
let { include: packages = "auto", exclude = DEFAULT_EXCLUDE_WORKSPACE, config: workspaceConfig } = workspace;
|
|
643
|
-
if (packages === "auto") packages = (await glob({
|
|
644
|
-
patterns: "**/package.json",
|
|
646
|
+
if (packages === "auto") packages = (await glob("**/package.json", {
|
|
645
647
|
ignore: exclude,
|
|
646
|
-
cwd: rootCwd
|
|
648
|
+
cwd: rootCwd,
|
|
649
|
+
expandDirectories: false
|
|
647
650
|
})).filter((file) => file !== "package.json").map((file) => slash(path.resolve(rootCwd, file, "..")));
|
|
648
|
-
else packages = (await glob({
|
|
649
|
-
patterns: packages,
|
|
651
|
+
else packages = (await glob(packages, {
|
|
650
652
|
ignore: exclude,
|
|
651
653
|
cwd: rootCwd,
|
|
652
654
|
onlyDirectories: true,
|
|
653
|
-
absolute: true
|
|
655
|
+
absolute: true,
|
|
656
|
+
expandDirectories: false
|
|
654
657
|
})).map((file) => slash(path.resolve(file)));
|
|
655
658
|
if (packages.length === 0) throw new Error("No workspace packages found, please check your config");
|
|
656
659
|
if (options.filter) {
|
|
@@ -662,16 +665,16 @@ async function resolveWorkspace(config, options) {
|
|
|
662
665
|
}
|
|
663
666
|
const files = [];
|
|
664
667
|
const configs = (await Promise.all(packages.map(async (cwd) => {
|
|
665
|
-
debug$
|
|
668
|
+
debug$3("loading workspace config %s", cwd);
|
|
666
669
|
const { configs: configs$1, file } = await loadConfigFile({
|
|
667
670
|
...options,
|
|
668
671
|
config: workspaceConfig,
|
|
669
672
|
cwd
|
|
670
673
|
}, cwd);
|
|
671
674
|
if (file) {
|
|
672
|
-
debug$
|
|
675
|
+
debug$3("loaded workspace config file %s", file);
|
|
673
676
|
files.push(file);
|
|
674
|
-
} else debug$
|
|
677
|
+
} else debug$3("no workspace config file found in %s", cwd);
|
|
675
678
|
return configs$1.map((config$1) => ({
|
|
676
679
|
...normalized,
|
|
677
680
|
cwd,
|
|
@@ -768,7 +771,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
768
771
|
|
|
769
772
|
//#endregion
|
|
770
773
|
//#region src/features/external.ts
|
|
771
|
-
const debug$
|
|
774
|
+
const debug$2 = Debug("tsdown:external");
|
|
772
775
|
function ExternalPlugin(options) {
|
|
773
776
|
const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
|
|
774
777
|
return {
|
|
@@ -796,7 +799,7 @@ function ExternalPlugin(options) {
|
|
|
796
799
|
}
|
|
797
800
|
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
798
801
|
if (shouldExternal) {
|
|
799
|
-
debug$
|
|
802
|
+
debug$2("External dependency:", id);
|
|
800
803
|
return {
|
|
801
804
|
id,
|
|
802
805
|
external: shouldExternal,
|
|
@@ -953,7 +956,7 @@ function formatBytes(bytes) {
|
|
|
953
956
|
|
|
954
957
|
//#endregion
|
|
955
958
|
//#region src/features/report.ts
|
|
956
|
-
const debug$
|
|
959
|
+
const debug$1 = Debug("tsdown:report");
|
|
957
960
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
958
961
|
const gzipAsync = promisify(gzip);
|
|
959
962
|
function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
@@ -994,19 +997,19 @@ function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
|
994
997
|
};
|
|
995
998
|
}
|
|
996
999
|
async function calcSize(options, chunk) {
|
|
997
|
-
debug$
|
|
1000
|
+
debug$1(`Calculating size for`, chunk.fileName);
|
|
998
1001
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
999
1002
|
const raw = Buffer.byteLength(content, "utf8");
|
|
1000
|
-
debug$
|
|
1003
|
+
debug$1("[size]", chunk.fileName, raw);
|
|
1001
1004
|
let gzip$1 = Infinity;
|
|
1002
1005
|
let brotli = Infinity;
|
|
1003
|
-
if (raw > (options.maxCompressSize ?? 1e6)) debug$
|
|
1006
|
+
if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
1004
1007
|
else {
|
|
1005
1008
|
gzip$1 = (await gzipAsync(content)).length;
|
|
1006
|
-
debug$
|
|
1009
|
+
debug$1("[gzip]", chunk.fileName, gzip$1);
|
|
1007
1010
|
if (options.brotli) {
|
|
1008
1011
|
brotli = (await brotliCompressAsync(content)).length;
|
|
1009
|
-
debug$
|
|
1012
|
+
debug$1("[brotli]", chunk.fileName, brotli);
|
|
1010
1013
|
}
|
|
1011
1014
|
}
|
|
1012
1015
|
return {
|
|
@@ -1053,7 +1056,7 @@ function getShimsInject(format, platform) {
|
|
|
1053
1056
|
|
|
1054
1057
|
//#endregion
|
|
1055
1058
|
//#region src/features/rolldown.ts
|
|
1056
|
-
const debug
|
|
1059
|
+
const debug = Debug("tsdown:rolldown");
|
|
1057
1060
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
1058
1061
|
const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
|
|
1059
1062
|
const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
|
|
@@ -1061,7 +1064,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
|
1061
1064
|
...inputOptions,
|
|
1062
1065
|
output: outputOptions
|
|
1063
1066
|
};
|
|
1064
|
-
debug
|
|
1067
|
+
debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1065
1068
|
return rolldownConfig;
|
|
1066
1069
|
}
|
|
1067
1070
|
async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -100,7 +100,7 @@
|
|
|
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.10",
|
|
104
104
|
"typedoc-plugin-markdown": "^4.8.0",
|
|
105
105
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
106
106
|
"typescript": "~5.9.2",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"test": "vitest",
|
|
127
127
|
"typecheck": "tsc --noEmit",
|
|
128
128
|
"format": "prettier --cache --write .",
|
|
129
|
-
"release": "bumpp
|
|
129
|
+
"release": "bumpp",
|
|
130
130
|
"docs:dev": "vitepress dev docs",
|
|
131
131
|
"docs:build": "vitepress build docs",
|
|
132
132
|
"docs:preview": "vitepress preview docs",
|