tsdown 0.15.3 → 0.15.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/dist/index.mjs +1 -1
- package/dist/{migrate-Buw8lGN7.mjs → migrate-BsOBsX36.mjs} +1 -1
- package/dist/package-CtgHh8kt.mjs +5 -0
- package/dist/plugins.mjs +1 -1
- package/dist/run.mjs +6 -6
- package/dist/{src-AiuiQJQr.mjs → src-BouWk1_F.mjs} +34 -34
- package/package.json +2 -2
- package/dist/package-x7iVusai.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-BouWk1_F.mjs";
|
|
3
3
|
import { globalLogger } from "./logger-C09npKHT.mjs";
|
|
4
4
|
|
|
5
5
|
export { build, buildSingle, defineConfig, globalLogger, shimFile };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { globalLogger } from "./logger-C09npKHT.mjs";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-CtgHh8kt.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-BouWk1_F.mjs";
|
|
3
3
|
import "./logger-C09npKHT.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
2
|
import { globalLogger, resolveComma, toArray } from "./logger-C09npKHT.mjs";
|
|
3
|
-
import { version } from "./package-
|
|
3
|
+
import { version } from "./package-CtgHh8kt.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-BsOBsX36.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();
|
|
@@ -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";
|
|
@@ -67,7 +67,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
67
67
|
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/features/attw.ts
|
|
70
|
-
const debug$
|
|
70
|
+
const debug$7 = Debug("tsdown:attw");
|
|
71
71
|
const exec$1 = promisify(child_process.exec);
|
|
72
72
|
/**
|
|
73
73
|
* 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 {
|
|
@@ -146,7 +146,7 @@ async function attw(options) {
|
|
|
146
146
|
} else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
147
147
|
} catch (error) {
|
|
148
148
|
options.logger.error("ATTW check failed:", error);
|
|
149
|
-
debug$
|
|
149
|
+
debug$7("Found errors, setting exit code to 1");
|
|
150
150
|
process.exitCode = 1;
|
|
151
151
|
} finally {
|
|
152
152
|
await fsRemove(tempDir);
|
|
@@ -170,7 +170,7 @@ function warnLegacyCJS(config) {
|
|
|
170
170
|
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/features/clean.ts
|
|
173
|
-
const debug$
|
|
173
|
+
const debug$6 = Debug("tsdown:clean");
|
|
174
174
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
175
175
|
async function cleanOutDir(configs) {
|
|
176
176
|
const removes = /* @__PURE__ */ new Set();
|
|
@@ -187,10 +187,10 @@ async function cleanOutDir(configs) {
|
|
|
187
187
|
if (!removes.size) return;
|
|
188
188
|
globalLogger.info(`Cleaning ${removes.size} files`);
|
|
189
189
|
await Promise.all([...removes].map(async (file) => {
|
|
190
|
-
debug$
|
|
190
|
+
debug$6("Removing", file);
|
|
191
191
|
await fsRemove(file);
|
|
192
192
|
}));
|
|
193
|
-
debug$
|
|
193
|
+
debug$6("Removed %d files", removes.size);
|
|
194
194
|
}
|
|
195
195
|
function resolveClean(clean, outDir, cwd) {
|
|
196
196
|
if (clean === true) clean = [slash(outDir)];
|
|
@@ -348,7 +348,7 @@ async function createHooks$1(options) {
|
|
|
348
348
|
|
|
349
349
|
//#endregion
|
|
350
350
|
//#region src/features/publint.ts
|
|
351
|
-
const debug$
|
|
351
|
+
const debug$5 = Debug("tsdown:publint");
|
|
352
352
|
async function publint(options) {
|
|
353
353
|
if (!options.publint) return;
|
|
354
354
|
if (!options.pkg) {
|
|
@@ -356,11 +356,11 @@ async function publint(options) {
|
|
|
356
356
|
return;
|
|
357
357
|
}
|
|
358
358
|
const t = performance.now();
|
|
359
|
-
debug$
|
|
359
|
+
debug$5("Running publint");
|
|
360
360
|
const { publint: publint$1 } = await import("publint");
|
|
361
361
|
const { formatMessage } = await import("publint/utils");
|
|
362
362
|
const { messages } = await publint$1(options.publint === true ? {} : options.publint);
|
|
363
|
-
debug$
|
|
363
|
+
debug$5("Found %d issues", messages.length);
|
|
364
364
|
if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
365
365
|
let hasError = false;
|
|
366
366
|
for (const message of messages) {
|
|
@@ -374,7 +374,7 @@ async function publint(options) {
|
|
|
374
374
|
options.logger[logType](formattedMessage);
|
|
375
375
|
}
|
|
376
376
|
if (hasError) {
|
|
377
|
-
debug$
|
|
377
|
+
debug$5("Found errors, setting exit code to 1");
|
|
378
378
|
process.exitCode = 1;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
@@ -460,11 +460,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
|
|
|
460
460
|
|
|
461
461
|
//#endregion
|
|
462
462
|
//#region src/utils/package.ts
|
|
463
|
-
const debug$
|
|
463
|
+
const debug$4 = Debug("tsdown:package");
|
|
464
464
|
async function readPackageJson(dir) {
|
|
465
465
|
const packageJsonPath = up$1({ cwd: dir });
|
|
466
466
|
if (!packageJsonPath) return;
|
|
467
|
-
debug$
|
|
467
|
+
debug$4("Reading package.json:", packageJsonPath);
|
|
468
468
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
469
469
|
return {
|
|
470
470
|
...JSON.parse(contents),
|
|
@@ -590,7 +590,7 @@ async function nativeImport(id) {
|
|
|
590
590
|
|
|
591
591
|
//#endregion
|
|
592
592
|
//#region src/options/index.ts
|
|
593
|
-
const debug$
|
|
593
|
+
const debug$3 = Debug("tsdown:options");
|
|
594
594
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
595
595
|
"**/node_modules/**",
|
|
596
596
|
"**/dist/**",
|
|
@@ -598,20 +598,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
598
598
|
"**/t?(e)mp/**"
|
|
599
599
|
];
|
|
600
600
|
async function resolveOptions(options) {
|
|
601
|
-
debug$
|
|
601
|
+
debug$3("options %O", options);
|
|
602
602
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
603
603
|
const files = [];
|
|
604
604
|
if (file) {
|
|
605
605
|
files.push(file);
|
|
606
|
-
debug$
|
|
607
|
-
debug$
|
|
608
|
-
} else debug$
|
|
606
|
+
debug$3("loaded root config file %s", file);
|
|
607
|
+
debug$3("root configs %O", rootConfigs);
|
|
608
|
+
} else debug$3("no root config file found");
|
|
609
609
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
610
610
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
611
611
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
612
612
|
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
|
|
613
613
|
}))).flat();
|
|
614
|
-
debug$
|
|
614
|
+
debug$3("resolved configs %O", configs);
|
|
615
615
|
return {
|
|
616
616
|
configs,
|
|
617
617
|
files
|
|
@@ -654,16 +654,16 @@ async function resolveWorkspace(config, options) {
|
|
|
654
654
|
const files = [];
|
|
655
655
|
return {
|
|
656
656
|
configs: (await Promise.all(packages.map(async (cwd) => {
|
|
657
|
-
debug$
|
|
657
|
+
debug$3("loading workspace config %s", cwd);
|
|
658
658
|
const { configs, file } = await loadConfigFile({
|
|
659
659
|
...options,
|
|
660
660
|
config: workspaceConfig,
|
|
661
661
|
cwd
|
|
662
662
|
}, cwd);
|
|
663
663
|
if (file) {
|
|
664
|
-
debug$
|
|
664
|
+
debug$3("loaded workspace config file %s", file);
|
|
665
665
|
files.push(file);
|
|
666
|
-
} else debug$
|
|
666
|
+
} else debug$3("no workspace config file found in %s", cwd);
|
|
667
667
|
return configs.map((config$1) => ({
|
|
668
668
|
...normalized,
|
|
669
669
|
cwd,
|
|
@@ -762,7 +762,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
762
762
|
|
|
763
763
|
//#endregion
|
|
764
764
|
//#region src/features/external.ts
|
|
765
|
-
const debug$
|
|
765
|
+
const debug$2 = Debug("tsdown:external");
|
|
766
766
|
function ExternalPlugin(options) {
|
|
767
767
|
const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
|
|
768
768
|
return {
|
|
@@ -789,7 +789,7 @@ function ExternalPlugin(options) {
|
|
|
789
789
|
}
|
|
790
790
|
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
791
791
|
if (shouldExternal) {
|
|
792
|
-
debug$
|
|
792
|
+
debug$2("External dependency:", id);
|
|
793
793
|
return {
|
|
794
794
|
id,
|
|
795
795
|
external: shouldExternal,
|
|
@@ -950,7 +950,7 @@ function formatBytes(bytes) {
|
|
|
950
950
|
|
|
951
951
|
//#endregion
|
|
952
952
|
//#region src/features/report.ts
|
|
953
|
-
const debug$
|
|
953
|
+
const debug$1 = Debug("tsdown:report");
|
|
954
954
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
955
955
|
const gzipAsync = promisify(gzip);
|
|
956
956
|
function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
@@ -991,19 +991,19 @@ function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
|
|
|
991
991
|
};
|
|
992
992
|
}
|
|
993
993
|
async function calcSize(options, chunk) {
|
|
994
|
-
debug$
|
|
994
|
+
debug$1(`Calculating size for`, chunk.fileName);
|
|
995
995
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
996
996
|
const raw = Buffer.byteLength(content, "utf8");
|
|
997
|
-
debug$
|
|
997
|
+
debug$1("[size]", chunk.fileName, raw);
|
|
998
998
|
let gzip$1 = Infinity;
|
|
999
999
|
let brotli = Infinity;
|
|
1000
|
-
if (raw > (options.maxCompressSize ?? 1e6)) debug$
|
|
1000
|
+
if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
1001
1001
|
else {
|
|
1002
1002
|
gzip$1 = (await gzipAsync(content)).length;
|
|
1003
|
-
debug$
|
|
1003
|
+
debug$1("[gzip]", chunk.fileName, gzip$1);
|
|
1004
1004
|
if (options.brotli) {
|
|
1005
1005
|
brotli = (await brotliCompressAsync(content)).length;
|
|
1006
|
-
debug$
|
|
1006
|
+
debug$1("[brotli]", chunk.fileName, brotli);
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
1009
|
return {
|
|
@@ -1050,7 +1050,7 @@ function getShimsInject(format, platform) {
|
|
|
1050
1050
|
|
|
1051
1051
|
//#endregion
|
|
1052
1052
|
//#region src/features/rolldown.ts
|
|
1053
|
-
const debug
|
|
1053
|
+
const debug = Debug("tsdown:rolldown");
|
|
1054
1054
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
1055
1055
|
const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
|
|
1056
1056
|
const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
|
|
@@ -1058,7 +1058,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
|
|
|
1058
1058
|
...inputOptions,
|
|
1059
1059
|
output: outputOptions
|
|
1060
1060
|
};
|
|
1061
|
-
debug
|
|
1061
|
+
debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
|
|
1062
1062
|
return rolldownConfig;
|
|
1063
1063
|
}
|
|
1064
1064
|
async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
|
|
@@ -1150,7 +1150,6 @@ function shortcuts(restart) {
|
|
|
1150
1150
|
key: "r",
|
|
1151
1151
|
description: "reload config and rebuild",
|
|
1152
1152
|
action() {
|
|
1153
|
-
rl.close();
|
|
1154
1153
|
restart();
|
|
1155
1154
|
}
|
|
1156
1155
|
},
|
|
@@ -1188,6 +1187,7 @@ function shortcuts(restart) {
|
|
|
1188
1187
|
}
|
|
1189
1188
|
const rl = readline.createInterface({ input: process.stdin });
|
|
1190
1189
|
rl.on("line", onInput);
|
|
1190
|
+
return () => rl.close();
|
|
1191
1191
|
}
|
|
1192
1192
|
|
|
1193
1193
|
//#endregion
|
|
@@ -1245,7 +1245,7 @@ async function build$1(userOptions = {}) {
|
|
|
1245
1245
|
const watcher = await watchBuild(config, configFiles, rebuild, restart);
|
|
1246
1246
|
disposeCbs.push(() => watcher.close());
|
|
1247
1247
|
}
|
|
1248
|
-
if (disposeCbs.length) shortcuts(restart);
|
|
1248
|
+
if (disposeCbs.length) disposeCbs.push(shortcuts(restart));
|
|
1249
1249
|
async function restart() {
|
|
1250
1250
|
for (const dispose of disposeCbs) await dispose();
|
|
1251
1251
|
build$1(userOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"empathic": "^2.0.0",
|
|
78
78
|
"hookable": "^5.5.3",
|
|
79
79
|
"rolldown": "latest",
|
|
80
|
-
"rolldown-plugin-dts": "^0.16.
|
|
80
|
+
"rolldown-plugin-dts": "^0.16.7",
|
|
81
81
|
"semver": "^7.7.2",
|
|
82
82
|
"tinyexec": "^1.0.1",
|
|
83
83
|
"tinyglobby": "^0.2.15",
|