tsdown 0.12.5 → 0.12.7
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-RMenra1a.d.ts → config-BJDUww56.d.mts} +14 -5
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +3 -0
- package/dist/{index.d.ts → index.d.mts} +1 -1
- package/dist/{index.js → index.mjs} +76 -35
- package/dist/{migrate-nO5Up2ZS.js → migrate-CMJIC73T.mjs} +2 -2
- package/dist/package-ZDuXNobF.mjs +5 -0
- package/dist/{plugins-BgxE5Awo.js → plugins-BmNEEFYs.mjs} +13 -17
- package/dist/{plugins.d.ts → plugins.d.mts} +1 -1
- package/dist/{plugins.js → plugins.mjs} +2 -2
- package/dist/{run.js → run.mjs} +9 -9
- package/package.json +29 -20
- package/dist/config.d.ts +0 -2
- package/dist/config.js +0 -3
- package/dist/package-BQ8czGAY.js +0 -5
- /package/dist/{config-yiJy1jd0.js → config-CzjtjH-U.mjs} +0 -0
- /package/dist/{logger-BMB8Jggq.js → logger-CdK2zFTY.mjs} +0 -0
- /package/dist/{run.d.ts → run.d.mts} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "ansis";
|
|
2
2
|
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, OutputAsset, OutputChunk, OutputOptions, Plugin } from "rolldown";
|
|
3
|
-
import { Options } from "rolldown-plugin-dts";
|
|
4
3
|
import { Hookable } from "hookable";
|
|
5
|
-
import {
|
|
4
|
+
import { CheckPackageOptions } from "@arethetypeswrong/core";
|
|
5
|
+
import { Options } from "publint";
|
|
6
|
+
import { Options as Options$1 } from "rolldown-plugin-dts";
|
|
6
7
|
import { Options as Options$2 } from "unplugin-unused";
|
|
7
8
|
import { PackageJson } from "pkg-types";
|
|
8
9
|
|
|
@@ -289,7 +290,7 @@ interface Options$3 {
|
|
|
289
290
|
* - If the `types` field is present in `package.json`, declaration file emission is enabled.
|
|
290
291
|
* - If the `types` field is absent, declaration file emission is disabled by default.
|
|
291
292
|
*/
|
|
292
|
-
dts?: boolean | Options;
|
|
293
|
+
dts?: boolean | Options$1;
|
|
293
294
|
/**
|
|
294
295
|
* Enable unused dependencies check with `unplugin-unused`
|
|
295
296
|
* Requires `unplugin-unused` to be installed.
|
|
@@ -301,7 +302,15 @@ interface Options$3 {
|
|
|
301
302
|
* Requires `publint` to be installed.
|
|
302
303
|
* @default false
|
|
303
304
|
*/
|
|
304
|
-
publint?: boolean | Options
|
|
305
|
+
publint?: boolean | Options;
|
|
306
|
+
/**
|
|
307
|
+
* Run `arethetypeswrong` after bundling.
|
|
308
|
+
* Requires `@arethetypeswrong/core` to be installed.
|
|
309
|
+
*
|
|
310
|
+
* @default false
|
|
311
|
+
* @see https://github.com/arethetypeswrong/arethetypeswrong.github.io
|
|
312
|
+
*/
|
|
313
|
+
attw?: boolean | CheckPackageOptions;
|
|
305
314
|
/**
|
|
306
315
|
* Enable size reporting after bundling.
|
|
307
316
|
* @default true
|
|
@@ -381,7 +390,7 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
|
|
|
381
390
|
format: NormalizedFormat[];
|
|
382
391
|
target?: string[];
|
|
383
392
|
clean: string[];
|
|
384
|
-
dts: false | Options;
|
|
393
|
+
dts: false | Options$1;
|
|
385
394
|
report: false | ReportOptions;
|
|
386
395
|
tsconfig: string | false;
|
|
387
396
|
pkg?: PackageJson;
|
package/dist/config.mjs
ADDED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-
|
|
1
|
+
import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-BJDUww56.mjs";
|
|
2
2
|
export { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { defineConfig } from "./config-
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-
|
|
3
|
-
import { debounce, generateColor, logger, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-
|
|
1
|
+
import { defineConfig } from "./config-CzjtjH-U.mjs";
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-BmNEEFYs.mjs";
|
|
3
|
+
import { debounce, generateColor, logger, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-CdK2zFTY.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import { blue, bold, dim, green, underline } from "ansis";
|
|
8
8
|
import { build as build$1 } from "rolldown";
|
|
9
9
|
import { exec } from "tinyexec";
|
|
10
|
-
import
|
|
10
|
+
import child_process from "node:child_process";
|
|
11
|
+
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { promisify } from "node:util";
|
|
14
|
+
import debug from "debug";
|
|
11
15
|
import { glob } from "tinyglobby";
|
|
12
|
-
import {
|
|
13
|
-
import { RE_DTS } from "rolldown-plugin-dts";
|
|
16
|
+
import { RE_DTS } from "rolldown-plugin-dts/filename";
|
|
14
17
|
import { createHooks } from "hookable";
|
|
15
18
|
import { up } from "empathic/package";
|
|
16
19
|
import readline from "node:readline";
|
|
@@ -18,8 +21,47 @@ import minVersion from "semver/ranges/min-version.js";
|
|
|
18
21
|
import { up as up$1 } from "empathic/find";
|
|
19
22
|
import { loadConfig } from "unconfig";
|
|
20
23
|
|
|
24
|
+
//#region src/features/attw.ts
|
|
25
|
+
const debug$5 = debug("tsdown:attw");
|
|
26
|
+
const exec$1 = promisify(child_process.exec);
|
|
27
|
+
async function attw(options) {
|
|
28
|
+
if (!options.attw) return;
|
|
29
|
+
if (!options.pkg) {
|
|
30
|
+
logger.warn("attw is enabled but package.json is not found");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const t = performance.now();
|
|
34
|
+
debug$5("Running attw check");
|
|
35
|
+
const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
|
|
36
|
+
let attwCore;
|
|
37
|
+
try {
|
|
38
|
+
attwCore = await import("@arethetypeswrong/core");
|
|
39
|
+
} catch {
|
|
40
|
+
logger.error(`ATTW check requires ${blue`@arethetypeswrong/core`} to be installed.`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const { stdout: tarballInfo } = await exec$1(`npm pack --json ----pack-destination ${tempDir}`, { encoding: "utf-8" });
|
|
45
|
+
const parsed = JSON.parse(tarballInfo);
|
|
46
|
+
if (!Array.isArray(parsed) || !parsed[0]?.filename) throw new Error("Invalid npm pack output format");
|
|
47
|
+
const tarballPath = path.join(tempDir, parsed[0].filename);
|
|
48
|
+
const tarball = await readFile(tarballPath);
|
|
49
|
+
const pkg = attwCore.createPackageFromTarballData(tarball);
|
|
50
|
+
const checkResult = await attwCore.checkPackage(pkg, options.attw === true ? {} : options.attw);
|
|
51
|
+
if (checkResult.types !== false && checkResult.problems) for (const problem of checkResult.problems) logger.warn("Are the types wrong problem:", problem);
|
|
52
|
+
else logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
logger.error("ATTW check failed:", error);
|
|
55
|
+
debug$5("Found errors, setting exit code to 1");
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
} finally {
|
|
58
|
+
await fsRemove(tempDir);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
21
63
|
//#region src/features/clean.ts
|
|
22
|
-
const debug$
|
|
64
|
+
const debug$4 = debug("tsdown:clean");
|
|
23
65
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
24
66
|
async function cleanOutDir(configs) {
|
|
25
67
|
const removes = /* @__PURE__ */ new Set();
|
|
@@ -39,10 +81,10 @@ async function cleanOutDir(configs) {
|
|
|
39
81
|
if (!removes.size) return;
|
|
40
82
|
logger.info(`Cleaning ${removes.size} files`);
|
|
41
83
|
await Promise.all([...removes].map(async (file) => {
|
|
42
|
-
debug$
|
|
84
|
+
debug$4("Removing", file);
|
|
43
85
|
await fsRemove(file);
|
|
44
86
|
}));
|
|
45
|
-
debug$
|
|
87
|
+
debug$4("Removed %d files", removes.size);
|
|
46
88
|
}
|
|
47
89
|
function resolveClean(clean, outDir, cwd) {
|
|
48
90
|
if (clean === true) clean = [slash(outDir)];
|
|
@@ -241,11 +283,11 @@ async function LightningCSSPlugin(options) {
|
|
|
241
283
|
|
|
242
284
|
//#endregion
|
|
243
285
|
//#region src/utils/package.ts
|
|
244
|
-
const debug$
|
|
286
|
+
const debug$3 = debug("tsdown:package");
|
|
245
287
|
async function readPackageJson(dir) {
|
|
246
288
|
const packageJsonPath = up({ cwd: dir });
|
|
247
289
|
if (!packageJsonPath) return;
|
|
248
|
-
debug$
|
|
290
|
+
debug$3("Reading package.json:", packageJsonPath);
|
|
249
291
|
const contents = await readFile(packageJsonPath, "utf8");
|
|
250
292
|
return {
|
|
251
293
|
...JSON.parse(contents),
|
|
@@ -306,7 +348,7 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
|
306
348
|
|
|
307
349
|
//#endregion
|
|
308
350
|
//#region src/features/publint.ts
|
|
309
|
-
const debug$
|
|
351
|
+
const debug$2 = debug("tsdown:publint");
|
|
310
352
|
async function publint(options) {
|
|
311
353
|
if (!options.publint) return;
|
|
312
354
|
if (!options.pkg) {
|
|
@@ -314,11 +356,11 @@ async function publint(options) {
|
|
|
314
356
|
return;
|
|
315
357
|
}
|
|
316
358
|
const t = performance.now();
|
|
317
|
-
debug$
|
|
359
|
+
debug$2("Running publint");
|
|
318
360
|
const { publint: publint$1 } = await import("publint");
|
|
319
361
|
const { formatMessage } = await import("publint/utils");
|
|
320
362
|
const { messages } = await publint$1(options.publint === true ? {} : options.publint);
|
|
321
|
-
debug$
|
|
363
|
+
debug$2("Found %d issues", messages.length);
|
|
322
364
|
if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
323
365
|
let hasError = false;
|
|
324
366
|
for (const message of messages) {
|
|
@@ -332,7 +374,7 @@ async function publint(options) {
|
|
|
332
374
|
logger[logType](formattedMessage);
|
|
333
375
|
}
|
|
334
376
|
if (hasError) {
|
|
335
|
-
debug$
|
|
377
|
+
debug$2("Found errors, setting exit code to 1");
|
|
336
378
|
process.exitCode = 1;
|
|
337
379
|
}
|
|
338
380
|
}
|
|
@@ -623,7 +665,7 @@ async function loadConfigFile(options, workspace) {
|
|
|
623
665
|
|
|
624
666
|
//#endregion
|
|
625
667
|
//#region src/options/index.ts
|
|
626
|
-
const debug =
|
|
668
|
+
const debug$1 = debug("tsdown:options");
|
|
627
669
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
628
670
|
"**/node_modules/**",
|
|
629
671
|
"**/dist/**",
|
|
@@ -632,20 +674,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
632
674
|
];
|
|
633
675
|
async function resolveOptions(options) {
|
|
634
676
|
const files = [];
|
|
635
|
-
debug("options %O", options);
|
|
636
|
-
debug("loading config file: %s", options.config);
|
|
677
|
+
debug$1("options %O", options);
|
|
678
|
+
debug$1("loading config file: %s", options.config);
|
|
637
679
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
638
680
|
if (file) {
|
|
639
681
|
files.push(file);
|
|
640
|
-
debug("loaded root config file %s", file);
|
|
641
|
-
debug("root configs %o", rootConfigs);
|
|
642
|
-
} else debug("no root config file found");
|
|
682
|
+
debug$1("loaded root config file %s", file);
|
|
683
|
+
debug$1("root configs %o", rootConfigs);
|
|
684
|
+
} else debug$1("no root config file found");
|
|
643
685
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
644
686
|
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
645
687
|
if (workspaceFiles) files.push(...workspaceFiles);
|
|
646
688
|
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
|
|
647
689
|
}))).flat();
|
|
648
|
-
debug("resolved configs %O", configs);
|
|
690
|
+
debug$1("resolved configs %O", configs);
|
|
649
691
|
return {
|
|
650
692
|
configs,
|
|
651
693
|
files
|
|
@@ -687,16 +729,16 @@ async function resolveWorkspace(config, options) {
|
|
|
687
729
|
}
|
|
688
730
|
const files = [];
|
|
689
731
|
const configs = (await Promise.all(packages.map(async (cwd) => {
|
|
690
|
-
debug("loading workspace config %s", cwd);
|
|
732
|
+
debug$1("loading workspace config %s", cwd);
|
|
691
733
|
const { configs: configs$1, file } = await loadConfigFile({
|
|
692
734
|
...options,
|
|
693
735
|
config: workspaceConfig,
|
|
694
736
|
cwd
|
|
695
737
|
}, cwd);
|
|
696
738
|
if (file) {
|
|
697
|
-
debug("loaded workspace config file %s", file);
|
|
739
|
+
debug$1("loaded workspace config file %s", file);
|
|
698
740
|
files.push(file);
|
|
699
|
-
} else debug("no workspace config file found in %s", cwd);
|
|
741
|
+
} else debug$1("no workspace config file found in %s", cwd);
|
|
700
742
|
return configs$1.map((config$1) => ({
|
|
701
743
|
...normalized,
|
|
702
744
|
cwd,
|
|
@@ -709,7 +751,7 @@ async function resolveWorkspace(config, options) {
|
|
|
709
751
|
};
|
|
710
752
|
}
|
|
711
753
|
async function resolveConfig(userConfig) {
|
|
712
|
-
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, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false } = userConfig;
|
|
754
|
+
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 } = userConfig;
|
|
713
755
|
outDir = path.resolve(cwd, outDir);
|
|
714
756
|
clean = resolveClean(clean, outDir, cwd);
|
|
715
757
|
const pkg = await readPackageJson(cwd);
|
|
@@ -721,6 +763,7 @@ async function resolveConfig(userConfig) {
|
|
|
721
763
|
if (typeof external === "string") external = resolveRegex(external);
|
|
722
764
|
if (typeof noExternal === "string") noExternal = resolveRegex(noExternal);
|
|
723
765
|
if (publint$1 === true) publint$1 = {};
|
|
766
|
+
if (attw$1 === true) attw$1 = {};
|
|
724
767
|
if (exports === true) exports = {};
|
|
725
768
|
if (publicDir) if (copy$1) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
|
|
726
769
|
else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
|
|
@@ -753,6 +796,7 @@ async function resolveConfig(userConfig) {
|
|
|
753
796
|
shims,
|
|
754
797
|
skipNodeModulesBundle,
|
|
755
798
|
publint: publint$1,
|
|
799
|
+
attw: attw$1,
|
|
756
800
|
alias,
|
|
757
801
|
tsconfig,
|
|
758
802
|
cwd,
|
|
@@ -850,20 +894,17 @@ async function buildSingle(config, clean) {
|
|
|
850
894
|
}
|
|
851
895
|
}));
|
|
852
896
|
if (hasErrors) return;
|
|
853
|
-
await writeExports(config, chunks);
|
|
854
|
-
await publint(config);
|
|
855
|
-
await copy(config);
|
|
897
|
+
await Promise.all([writeExports(config, chunks), copy(config)]);
|
|
898
|
+
await Promise.all([publint(config), attw(config)]);
|
|
856
899
|
await hooks.callHook("build:done", context);
|
|
857
900
|
logger.success(prettyName(config.name), `${first ? "Build" : "Rebuild"} complete in ${green(`${Math.round(performance.now() - startTime)}ms`)}`);
|
|
858
901
|
ab = new AbortController();
|
|
859
902
|
if (typeof onSuccess === "string") {
|
|
860
|
-
const p = exec(onSuccess, [], {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
stdio: "inherit"
|
|
864
|
-
},
|
|
903
|
+
const p = exec(onSuccess, [], { nodeOptions: {
|
|
904
|
+
shell: true,
|
|
905
|
+
stdio: "inherit",
|
|
865
906
|
signal: ab.signal
|
|
866
|
-
});
|
|
907
|
+
} });
|
|
867
908
|
p.then(({ exitCode }) => {
|
|
868
909
|
if (exitCode) process.exitCode = exitCode;
|
|
869
910
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { logger } from "./logger-
|
|
2
|
-
import { version } from "./package-
|
|
1
|
+
import { logger } from "./logger-CdK2zFTY.mjs";
|
|
2
|
+
import { version } from "./package-ZDuXNobF.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";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { logger, noop, prettyFormat, prettyName, toArray } from "./logger-
|
|
1
|
+
import { logger, noop, prettyFormat, prettyName, toArray } from "./logger-CdK2zFTY.mjs";
|
|
2
2
|
import { isBuiltin } from "node:module";
|
|
3
3
|
import path, { dirname, normalize, sep } from "node:path";
|
|
4
4
|
import { bold, dim, green, underline } from "ansis";
|
|
5
|
-
import Debug from "debug";
|
|
6
5
|
import { access, chmod, cp, rm, stat } from "node:fs/promises";
|
|
7
|
-
import { RE_DTS } from "rolldown-plugin-dts";
|
|
8
|
-
import { Buffer } from "node:buffer";
|
|
9
6
|
import { promisify } from "node:util";
|
|
7
|
+
import debug from "debug";
|
|
8
|
+
import { RE_DTS } from "rolldown-plugin-dts/filename";
|
|
9
|
+
import { Buffer } from "node:buffer";
|
|
10
10
|
import { brotliCompress, gzip } from "node:zlib";
|
|
11
11
|
|
|
12
12
|
//#region src/utils/fs.ts
|
|
@@ -49,7 +49,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/features/external.ts
|
|
52
|
-
const debug$
|
|
52
|
+
const debug$2 = debug("tsdown:external");
|
|
53
53
|
function ExternalPlugin(options) {
|
|
54
54
|
const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
|
|
55
55
|
return {
|
|
@@ -72,7 +72,7 @@ function ExternalPlugin(options) {
|
|
|
72
72
|
}
|
|
73
73
|
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
74
74
|
if (shouldExternal) {
|
|
75
|
-
debug$
|
|
75
|
+
debug$2("External dependency:", id);
|
|
76
76
|
return {
|
|
77
77
|
id,
|
|
78
78
|
external: shouldExternal,
|
|
@@ -113,16 +113,12 @@ function NodeProtocolPlugin() {
|
|
|
113
113
|
//#region src/utils/format.ts
|
|
114
114
|
function formatBytes(bytes) {
|
|
115
115
|
if (bytes === Infinity) return void 0;
|
|
116
|
-
|
|
117
|
-
maximumFractionDigits: 2,
|
|
118
|
-
minimumFractionDigits: 2
|
|
119
|
-
});
|
|
120
|
-
return `${numberFormatter.format(bytes / 1e3)} kB`;
|
|
116
|
+
return `${(bytes / 1e3).toFixed(2)} kB`;
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
//#endregion
|
|
124
120
|
//#region src/features/report.ts
|
|
125
|
-
const debug =
|
|
121
|
+
const debug$1 = debug("tsdown:report");
|
|
126
122
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
127
123
|
const gzipAsync = promisify(gzip);
|
|
128
124
|
function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
|
|
@@ -163,19 +159,19 @@ function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
|
|
|
163
159
|
};
|
|
164
160
|
}
|
|
165
161
|
async function calcSize(options, chunk) {
|
|
166
|
-
debug(`Calculating size for`, chunk.fileName);
|
|
162
|
+
debug$1(`Calculating size for`, chunk.fileName);
|
|
167
163
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
168
164
|
const raw = Buffer.byteLength(content, "utf8");
|
|
169
|
-
debug("[size]", chunk.fileName, raw);
|
|
165
|
+
debug$1("[size]", chunk.fileName, raw);
|
|
170
166
|
let gzip$1 = Infinity;
|
|
171
167
|
let brotli = Infinity;
|
|
172
|
-
if (raw > (options.maxCompressSize ?? 1e6)) debug(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
168
|
+
if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
173
169
|
else {
|
|
174
170
|
gzip$1 = (await gzipAsync(content)).length;
|
|
175
|
-
debug("[gzip]", chunk.fileName, gzip$1);
|
|
171
|
+
debug$1("[gzip]", chunk.fileName, gzip$1);
|
|
176
172
|
if (options.brotli) {
|
|
177
173
|
brotli = (await brotliCompressAsync(content)).length;
|
|
178
|
-
debug("[brotli]", chunk.fileName, brotli);
|
|
174
|
+
debug$1("[brotli]", chunk.fileName, brotli);
|
|
179
175
|
}
|
|
180
176
|
}
|
|
181
177
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-
|
|
2
|
-
import "./logger-
|
|
1
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-BmNEEFYs.mjs";
|
|
2
|
+
import "./logger-CdK2zFTY.mjs";
|
|
3
3
|
|
|
4
4
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/{run.js → run.mjs}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { logger, resolveComma, toArray } from "./logger-
|
|
3
|
-
import { version } from "./package-
|
|
2
|
+
import { logger, resolveComma, toArray } from "./logger-CdK2zFTY.mjs";
|
|
3
|
+
import { version } from "./package-ZDuXNobF.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("--silent", "Suppress non-error logs").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("--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) => {
|
|
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("--silent", "Suppress non-error logs").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
18
|
logger.setSilent(!!flags.silent);
|
|
19
19
|
logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
20
|
-
const { build: build$1 } = await import("./index.
|
|
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-CMJIC73T.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();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.7",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"dist",
|
|
19
19
|
"esm-shims.js"
|
|
20
20
|
],
|
|
21
|
-
"main": "./dist/index.
|
|
22
|
-
"module": "./dist/index.
|
|
23
|
-
"types": "./dist/index.d.
|
|
21
|
+
"main": "./dist/index.mjs",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
24
|
"exports": {
|
|
25
|
-
".": "./dist/index.
|
|
26
|
-
"./config": "./dist/config.
|
|
27
|
-
"./plugins": "./dist/plugins.
|
|
28
|
-
"./run": "./dist/run.
|
|
25
|
+
".": "./dist/index.mjs",
|
|
26
|
+
"./config": "./dist/config.mjs",
|
|
27
|
+
"./plugins": "./dist/plugins.mjs",
|
|
28
|
+
"./run": "./dist/run.mjs",
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
31
31
|
"typesVersions": {
|
|
@@ -37,18 +37,22 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"bin": {
|
|
40
|
-
"tsdown": "./dist/run.
|
|
40
|
+
"tsdown": "./dist/run.mjs"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
+
"@arethetypeswrong/core": "^0.18.1",
|
|
46
47
|
"publint": "^0.3.0",
|
|
47
48
|
"typescript": "^5.0.0",
|
|
48
49
|
"unplugin-lightningcss": "^0.4.0",
|
|
49
50
|
"unplugin-unused": "^0.5.0"
|
|
50
51
|
},
|
|
51
52
|
"peerDependenciesMeta": {
|
|
53
|
+
"@arethetypeswrong/core": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
52
56
|
"publint": {
|
|
53
57
|
"optional": true
|
|
54
58
|
},
|
|
@@ -70,45 +74,50 @@
|
|
|
70
74
|
"diff": "^8.0.2",
|
|
71
75
|
"empathic": "^1.1.0",
|
|
72
76
|
"hookable": "^5.5.3",
|
|
73
|
-
"rolldown": "1.0.0-beta.
|
|
74
|
-
"rolldown-plugin-dts": "^0.13.
|
|
77
|
+
"rolldown": "1.0.0-beta.11-commit.f051675",
|
|
78
|
+
"rolldown-plugin-dts": "^0.13.8",
|
|
75
79
|
"semver": "^7.7.2",
|
|
76
80
|
"tinyexec": "^1.0.1",
|
|
77
81
|
"tinyglobby": "^0.2.14",
|
|
78
82
|
"unconfig": "^7.3.2"
|
|
79
83
|
},
|
|
80
84
|
"devDependencies": {
|
|
85
|
+
"@arethetypeswrong/core": "^0.18.1",
|
|
81
86
|
"@oxc-node/core": "^0.0.27",
|
|
82
|
-
"@sxzz/eslint-config": "^7.0.
|
|
87
|
+
"@sxzz/eslint-config": "^7.0.2",
|
|
83
88
|
"@sxzz/prettier-config": "^2.2.1",
|
|
84
89
|
"@sxzz/test-utils": "^0.5.6",
|
|
85
90
|
"@types/debug": "^4.1.12",
|
|
86
|
-
"@types/node": "^22.15.
|
|
91
|
+
"@types/node": "^22.15.29",
|
|
87
92
|
"@types/semver": "^7.7.0",
|
|
88
|
-
"@unocss/eslint-plugin": "^66.1.
|
|
93
|
+
"@unocss/eslint-plugin": "^66.1.3",
|
|
89
94
|
"@vueuse/core": "^13.3.0",
|
|
90
95
|
"bumpp": "^10.1.1",
|
|
91
|
-
"eslint": "^9.
|
|
96
|
+
"eslint": "^9.28.0",
|
|
92
97
|
"lightningcss": "^1.30.1",
|
|
93
98
|
"pkg-types": "^2.1.0",
|
|
94
99
|
"prettier": "^3.5.3",
|
|
95
100
|
"publint": "^0.3.12",
|
|
96
101
|
"typedoc": "^0.28.5",
|
|
97
|
-
"typedoc-plugin-markdown": "^4.6.
|
|
102
|
+
"typedoc-plugin-markdown": "^4.6.4",
|
|
98
103
|
"typescript": "~5.8.3",
|
|
99
|
-
"unocss": "^66.1.
|
|
104
|
+
"unocss": "^66.1.3",
|
|
100
105
|
"unplugin-lightningcss": "^0.4.1",
|
|
101
106
|
"unplugin-unused": "^0.5.0",
|
|
102
|
-
"vite": "
|
|
107
|
+
"vite": "npm:rolldown-vite@latest",
|
|
103
108
|
"vitepress": "^1.6.3",
|
|
104
|
-
"vitepress-plugin-group-icons": "^1.
|
|
109
|
+
"vitepress-plugin-group-icons": "^1.6.0",
|
|
105
110
|
"vitepress-plugin-llms": "^1.3.4",
|
|
106
|
-
"vitest": "^3.1
|
|
111
|
+
"vitest": "^3.2.1",
|
|
107
112
|
"vue": "^3.5.16"
|
|
108
113
|
},
|
|
109
114
|
"engines": {
|
|
110
115
|
"node": ">=18.0.0"
|
|
111
116
|
},
|
|
117
|
+
"resolutions": {
|
|
118
|
+
"rolldown": "catalog:prod",
|
|
119
|
+
"vite": "catalog:docs"
|
|
120
|
+
},
|
|
112
121
|
"prettier": "@sxzz/prettier-config",
|
|
113
122
|
"scripts": {
|
|
114
123
|
"lint": "eslint --cache --max-warnings 0 .",
|
package/dist/config.d.ts
DELETED
package/dist/config.js
DELETED
package/dist/package-BQ8czGAY.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|