tsdown 0.13.0 → 0.13.2

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.
@@ -1,7 +1,4 @@
1
1
  //#region src/config.ts
2
- /**
3
- * Defines the configuration for tsdown.
4
- */
5
2
  function defineConfig(options) {
6
3
  return options;
7
4
  }
@@ -0,0 +1,11 @@
1
+ import { UserConfig, UserConfigFn } from "./types-DIH2hGTd.mjs";
2
+
3
+ //#region src/config.d.ts
4
+
5
+ /**
6
+ * Defines the configuration for tsdown.
7
+ */
8
+ declare function defineConfig(options: UserConfig): UserConfig;
9
+ declare function defineConfig(options: UserConfigFn): UserConfigFn;
10
+ //#endregion
11
+ export { defineConfig };
package/dist/config.d.mts CHANGED
@@ -1,2 +1,3 @@
1
- import { UserConfig, UserConfigFn, defineConfig } from "./config-9hj-APNF.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-DIH2hGTd.mjs";
2
+ import { defineConfig } from "./config-CZj6NGiw.mjs";
2
3
  export { UserConfig, UserConfigFn, defineConfig };
package/dist/config.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { defineConfig } from "./config-CzjtjH-U.mjs";
1
+ import { defineConfig } from "./config-CCGWF4al.mjs";
2
2
 
3
3
  export { defineConfig };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,35 @@
1
- import { AttwOptions, BuildContext, ChunkAddon, CopyOptions, DtsOptions, ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, build, buildSingle, defineConfig, logger, shimFile } from "./config-9hj-APNF.mjs";
2
- export { AttwOptions, BuildContext, ChunkAddon, CopyOptions, DtsOptions, ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, build, buildSingle, defineConfig, logger, shimFile };
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-DIH2hGTd.mjs";
2
+ import { defineConfig } from "./config-CZj6NGiw.mjs";
3
+ import "ansis";
4
+ import { InternalModuleFormat } from "rolldown";
5
+
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
+ //#region src/index.d.ts
19
+ /**
20
+ * Build with tsdown.
21
+ */
22
+ declare function build(userOptions?: Options): Promise<void>;
23
+ /** @internal */
24
+ declare const shimFile: string;
25
+ /**
26
+ * Build a single configuration, without watch and shortcuts features.
27
+ *
28
+ * Internal API, not for public use
29
+ *
30
+ * @private
31
+ * @param config Resolved options
32
+ */
33
+ declare function buildSingle(config: ResolvedOptions, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
34
+ //#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, logger, shimFile };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { defineConfig } from "./config-CzjtjH-U.mjs";
2
- import { build, buildSingle, shimFile } from "./src-vU2xJl3a.mjs";
1
+ import { defineConfig } from "./config-CCGWF4al.mjs";
2
+ import { build, buildSingle, shimFile } from "./src-C8dUJ_Mj.mjs";
3
3
  import { logger } from "./logger-6IV2T7t1.mjs";
4
4
 
5
5
  export { build, buildSingle, defineConfig, logger, shimFile };
@@ -1,5 +1,5 @@
1
1
  import { logger } from "./logger-6IV2T7t1.mjs";
2
- import { version } from "./package-CtrYqHTS.mjs";
2
+ import { version } from "./package-Dg3yzWpE.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";
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.13.2";
3
+
4
+ //#endregion
5
+ export { version };
@@ -1,4 +1,4 @@
1
- import { ReportPlugin, ResolvedOptions } from "./config-9hj-APNF.mjs";
1
+ import { ReportPlugin, ResolvedOptions } from "./types-DIH2hGTd.mjs";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/plugins.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import "./config-CzjtjH-U.mjs";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-vU2xJl3a.mjs";
1
+ import "./config-CCGWF4al.mjs";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-C8dUJ_Mj.mjs";
3
3
  import "./logger-6IV2T7t1.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 { logger, resolveComma, toArray } from "./logger-6IV2T7t1.mjs";
3
- import { version } from "./package-CtrYqHTS.mjs";
3
+ import { version } from "./package-Dg3yzWpE.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 debug from "debug";
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-B4LQBP_A.mjs");
25
+ const { migrate } = await import("./migrate-mIs6mjET.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 = debug.disable();
34
+ const enabled = Debug.disable();
35
35
  if (enabled) namespace += `,${enabled}`;
36
- debug.enable(namespace);
37
- debug("tsdown:debug")("Debugging enabled", namespace);
36
+ Debug.enable(namespace);
37
+ Debug("tsdown:debug")("Debugging enabled", namespace);
38
38
  }
39
39
  try {
40
40
  await cli.runMatchedCommand();
@@ -6,11 +6,12 @@ import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import { blue, bold, dim, green, underline } from "ansis";
7
7
  import { build } from "rolldown";
8
8
  import { exec } from "tinyexec";
9
+ import treeKill from "tree-kill";
9
10
  import child_process from "node:child_process";
10
11
  import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
11
12
  import { tmpdir } from "node:os";
12
13
  import { promisify } from "node:util";
13
- import debug from "debug";
14
+ import Debug from "debug";
14
15
  import { glob } from "tinyglobby";
15
16
  import { RE_CSS, RE_DTS, RE_JS } from "rolldown-plugin-dts/filename";
16
17
  import { createHooks } from "hookable";
@@ -19,6 +20,7 @@ import { Buffer } from "node:buffer";
19
20
  import { brotliCompress, gzip } from "node:zlib";
20
21
  import readline from "node:readline";
21
22
  import minVersion from "semver/ranges/min-version.js";
23
+ import { globalContext, invalidateContextFile } from "rolldown-plugin-dts/tsc-context";
22
24
  import { up as up$1 } from "empathic/find";
23
25
  import { loadConfig } from "unconfig";
24
26
 
@@ -62,7 +64,7 @@ function lowestCommonAncestor(...filepaths) {
62
64
 
63
65
  //#endregion
64
66
  //#region src/features/attw.ts
65
- const debug$7 = debug("tsdown:attw");
67
+ const debug$6 = Debug("tsdown:attw");
66
68
  const exec$1 = promisify(child_process.exec);
67
69
  /**
68
70
  * ATTW profiles.
@@ -109,7 +111,7 @@ async function attw(options) {
109
111
  }
110
112
  const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
111
113
  const t = performance.now();
112
- debug$7("Running attw check");
114
+ debug$6("Running attw check");
113
115
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
114
116
  let attwCore;
115
117
  try {
@@ -143,7 +145,7 @@ async function attw(options) {
143
145
  } else logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
144
146
  } catch (error) {
145
147
  logger.error("ATTW check failed:", error);
146
- debug$7("Found errors, setting exit code to 1");
148
+ debug$6("Found errors, setting exit code to 1");
147
149
  process.exitCode = 1;
148
150
  } finally {
149
151
  await fsRemove(tempDir);
@@ -152,7 +154,7 @@ async function attw(options) {
152
154
 
153
155
  //#endregion
154
156
  //#region src/features/clean.ts
155
- const debug$6 = debug("tsdown:clean");
157
+ const debug$5 = Debug("tsdown:clean");
156
158
  const RE_LAST_SLASH = /[/\\]$/;
157
159
  async function cleanOutDir(configs) {
158
160
  const removes = /* @__PURE__ */ new Set();
@@ -172,10 +174,10 @@ async function cleanOutDir(configs) {
172
174
  if (!removes.size) return;
173
175
  logger.info(`Cleaning ${removes.size} files`);
174
176
  await Promise.all([...removes].map(async (file) => {
175
- debug$6("Removing", file);
177
+ debug$5("Removing", file);
176
178
  await fsRemove(file);
177
179
  }));
178
- debug$6("Removed %d files", removes.size);
180
+ debug$5("Removed %d files", removes.size);
179
181
  }
180
182
  function resolveClean(clean, outDir, cwd) {
181
183
  if (clean === true) clean = [slash(outDir)];
@@ -243,7 +245,10 @@ async function generateExports(pkg, outDir, chunks, { devExports, all, customExp
243
245
  else main = distFile;
244
246
  else if (format === "es") if (isDts) esmTypes = distFile;
245
247
  else module$1 = distFile;
246
- } else name = `./${name}`;
248
+ } else {
249
+ const isDirIndex = name.endsWith("/index");
250
+ name = isDirIndex ? `./${name.slice(0, -6)}` : `./${name}`;
251
+ }
247
252
  let subExport = exportsMap.get(name);
248
253
  if (!subExport) {
249
254
  subExport = {};
@@ -306,7 +311,7 @@ function exportMeta(exports, all) {
306
311
 
307
312
  //#endregion
308
313
  //#region src/features/external.ts
309
- const debug$5 = debug("tsdown:external");
314
+ const debug$4 = Debug("tsdown:external");
310
315
  function ExternalPlugin(options) {
311
316
  const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
312
317
  return {
@@ -334,7 +339,7 @@ function ExternalPlugin(options) {
334
339
  }
335
340
  if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
336
341
  if (shouldExternal) {
337
- debug$5("External dependency:", id);
342
+ debug$4("External dependency:", id);
338
343
  return {
339
344
  id,
340
345
  external: shouldExternal,
@@ -455,11 +460,11 @@ function NodeProtocolPlugin(nodeProtocolOption) {
455
460
 
456
461
  //#endregion
457
462
  //#region src/utils/package.ts
458
- const debug$4 = debug("tsdown:package");
463
+ const debug$3 = Debug("tsdown:package");
459
464
  async function readPackageJson(dir) {
460
465
  const packageJsonPath = up({ cwd: dir });
461
466
  if (!packageJsonPath) return;
462
- debug$4("Reading package.json:", packageJsonPath);
467
+ debug$3("Reading package.json:", packageJsonPath);
463
468
  const contents = await readFile(packageJsonPath, "utf8");
464
469
  return {
465
470
  ...JSON.parse(contents),
@@ -532,7 +537,7 @@ function resolveChunkAddon(chunkAddon, format) {
532
537
 
533
538
  //#endregion
534
539
  //#region src/features/publint.ts
535
- const debug$3 = debug("tsdown:publint");
540
+ const debug$2 = Debug("tsdown:publint");
536
541
  async function publint(options) {
537
542
  if (!options.publint) return;
538
543
  if (!options.pkg) {
@@ -540,11 +545,11 @@ async function publint(options) {
540
545
  return;
541
546
  }
542
547
  const t = performance.now();
543
- debug$3("Running publint");
548
+ debug$2("Running publint");
544
549
  const { publint: publint$1 } = await import("publint");
545
550
  const { formatMessage } = await import("publint/utils");
546
551
  const { messages } = await publint$1(options.publint === true ? {} : options.publint);
547
- debug$3("Found %d issues", messages.length);
552
+ debug$2("Found %d issues", messages.length);
548
553
  if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
549
554
  let hasError = false;
550
555
  for (const message of messages) {
@@ -558,7 +563,7 @@ async function publint(options) {
558
563
  logger[logType](formattedMessage);
559
564
  }
560
565
  if (hasError) {
561
- debug$3("Found errors, setting exit code to 1");
566
+ debug$2("Found errors, setting exit code to 1");
562
567
  process.exitCode = 1;
563
568
  }
564
569
  }
@@ -572,7 +577,7 @@ function formatBytes(bytes) {
572
577
 
573
578
  //#endregion
574
579
  //#region src/features/report.ts
575
- const debug$2 = debug("tsdown:report");
580
+ const debug$1 = Debug("tsdown:report");
576
581
  const brotliCompressAsync = promisify(brotliCompress);
577
582
  const gzipAsync = promisify(gzip);
578
583
  function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
@@ -613,19 +618,19 @@ function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
613
618
  };
614
619
  }
615
620
  async function calcSize(options, chunk) {
616
- debug$2(`Calculating size for`, chunk.fileName);
621
+ debug$1(`Calculating size for`, chunk.fileName);
617
622
  const content = chunk.type === "chunk" ? chunk.code : chunk.source;
618
623
  const raw = Buffer.byteLength(content, "utf8");
619
- debug$2("[size]", chunk.fileName, raw);
624
+ debug$1("[size]", chunk.fileName, raw);
620
625
  let gzip$1 = Infinity;
621
626
  let brotli = Infinity;
622
- if (raw > (options.maxCompressSize ?? 1e6)) debug$2(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
627
+ if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
623
628
  else {
624
629
  gzip$1 = (await gzipAsync(content)).length;
625
- debug$2("[gzip]", chunk.fileName, gzip$1);
630
+ debug$1("[gzip]", chunk.fileName, gzip$1);
626
631
  if (options.brotli) {
627
632
  brotli = (await brotliCompressAsync(content)).length;
628
- debug$2("[brotli]", chunk.fileName, brotli);
633
+ debug$1("[brotli]", chunk.fileName, brotli);
629
634
  }
630
635
  }
631
636
  return {
@@ -775,6 +780,7 @@ async function watchBuild(options, configFiles, rebuild, restart) {
775
780
  return;
776
781
  }
777
782
  logger.info(`Change detected: ${type} ${file}`);
783
+ invalidateContextFile(globalContext, file);
778
784
  debouncedRebuild();
779
785
  });
780
786
  return watcher;
@@ -911,11 +917,11 @@ async function loadConfigFile(options, workspace) {
911
917
  stopAt: workspace && path.dirname(workspace),
912
918
  defaults: {}
913
919
  }).finally(() => loaded = true);
914
- const file = sources[0];
915
- if (file) logger.info(`Using tsdown config: ${underline(file)}`);
916
920
  if (typeof config === "function") config = await config(options);
917
921
  config = toArray(config);
918
922
  if (config.length === 0) config.push({});
923
+ const file = sources[0];
924
+ if (file) logger.info(`Using tsdown config: ${underline(file)}`);
919
925
  return {
920
926
  configs: config,
921
927
  file
@@ -924,7 +930,7 @@ async function loadConfigFile(options, workspace) {
924
930
 
925
931
  //#endregion
926
932
  //#region src/options/index.ts
927
- const debug$1 = debug("tsdown:options");
933
+ const debug = Debug("tsdown:options");
928
934
  const DEFAULT_EXCLUDE_WORKSPACE = [
929
935
  "**/node_modules/**",
930
936
  "**/dist/**",
@@ -933,20 +939,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
933
939
  ];
934
940
  async function resolveOptions(options) {
935
941
  const files = [];
936
- debug$1("options %O", options);
937
- debug$1("loading config file: %s", options.config);
942
+ debug("options %O", options);
943
+ debug("loading config file: %s", options.config);
938
944
  const { configs: rootConfigs, file } = await loadConfigFile(options);
939
945
  if (file) {
940
946
  files.push(file);
941
- debug$1("loaded root config file %s", file);
942
- debug$1("root configs %o", rootConfigs);
943
- } else debug$1("no root config file found");
947
+ debug("loaded root config file %s", file);
948
+ debug("root configs %o", rootConfigs);
949
+ } else debug("no root config file found");
944
950
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
945
951
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
946
952
  if (workspaceFiles) files.push(...workspaceFiles);
947
953
  return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
948
954
  }))).flat();
949
- debug$1("resolved configs %O", configs);
955
+ debug("resolved configs %O", configs);
950
956
  return {
951
957
  configs,
952
958
  files
@@ -988,16 +994,16 @@ async function resolveWorkspace(config, options) {
988
994
  }
989
995
  const files = [];
990
996
  const configs = (await Promise.all(packages.map(async (cwd) => {
991
- debug$1("loading workspace config %s", cwd);
997
+ debug("loading workspace config %s", cwd);
992
998
  const { configs: configs$1, file } = await loadConfigFile({
993
999
  ...options,
994
1000
  config: workspaceConfig,
995
1001
  cwd
996
1002
  }, cwd);
997
1003
  if (file) {
998
- debug$1("loaded workspace config file %s", file);
1004
+ debug("loaded workspace config file %s", file);
999
1005
  files.push(file);
1000
- } else debug$1("no workspace config file found in %s", cwd);
1006
+ } else debug("no workspace config file found in %s", cwd);
1001
1007
  return configs$1.map((config$1) => ({
1002
1008
  ...normalized,
1003
1009
  cwd,
@@ -1011,6 +1017,7 @@ async function resolveWorkspace(config, options) {
1011
1017
  }
1012
1018
  async function resolveConfig(userConfig) {
1013
1019
  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;
1020
+ if (silent) logger.setSilent(true);
1014
1021
  if (typeof bundle === "boolean") logger.warn("`bundle` option is deprecated. Use `unbundle` instead.");
1015
1022
  nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
1016
1023
  outDir = path.resolve(cwd, outDir);
@@ -1108,7 +1115,6 @@ function ShebangPlugin(cwd, name, isMultiFormat) {
1108
1115
  * Build with tsdown.
1109
1116
  */
1110
1117
  async function build$1(userOptions = {}) {
1111
- if (typeof userOptions.silent === "boolean") logger.setSilent(userOptions.silent);
1112
1118
  const { configs, files: configFiles } = await resolveOptions(userOptions);
1113
1119
  let cleanPromise;
1114
1120
  const clean = () => {
@@ -1117,21 +1123,22 @@ async function build$1(userOptions = {}) {
1117
1123
  };
1118
1124
  logger.info("Build start");
1119
1125
  const rebuilds = await Promise.all(configs.map((options) => buildSingle(options, clean)));
1120
- const cleanCbs = [];
1126
+ const disposeCbs = [];
1121
1127
  for (const [i, config] of configs.entries()) {
1122
1128
  const rebuild = rebuilds[i];
1123
1129
  if (!rebuild) continue;
1124
1130
  const watcher = await watchBuild(config, configFiles, rebuild, restart);
1125
- cleanCbs.push(() => watcher.close());
1131
+ disposeCbs.push(() => watcher.close());
1126
1132
  }
1127
- if (cleanCbs.length) shortcuts(restart);
1133
+ if (disposeCbs.length) shortcuts(restart);
1128
1134
  async function restart() {
1129
- for (const clean$1 of cleanCbs) await clean$1();
1135
+ for (const dispose of disposeCbs) await dispose();
1130
1136
  build$1(userOptions);
1131
1137
  }
1132
1138
  }
1133
1139
  const dirname$1 = path.dirname(fileURLToPath(import.meta.url));
1134
1140
  const pkgRoot = path.resolve(dirname$1, "..");
1141
+ /** @internal */
1135
1142
  const shimFile = path.resolve(pkgRoot, "esm-shims.js");
1136
1143
  /**
1137
1144
  * Build a single configuration, without watch and shortcuts features.
@@ -1151,7 +1158,8 @@ async function buildSingle(config, clean) {
1151
1158
  const startTime = performance.now();
1152
1159
  await hooks.callHook("build:prepare", context);
1153
1160
  ab?.abort();
1154
- await clean();
1161
+ if (first) await clean();
1162
+ else await cleanOutDir([config]);
1155
1163
  let hasErrors = false;
1156
1164
  const isMultiFormat = formats.length > 1;
1157
1165
  const chunks = {};
@@ -1186,12 +1194,14 @@ async function buildSingle(config, clean) {
1186
1194
  if (typeof onSuccess === "string") {
1187
1195
  const p = exec(onSuccess, [], { nodeOptions: {
1188
1196
  shell: true,
1189
- stdio: "inherit",
1190
- signal: ab.signal
1197
+ stdio: "inherit"
1191
1198
  } });
1192
1199
  p.then(({ exitCode }) => {
1193
1200
  if (exitCode) process.exitCode = exitCode;
1194
1201
  });
1202
+ ab.signal.addEventListener("abort", () => {
1203
+ if (typeof p.pid === "number") treeKill(p.pid);
1204
+ });
1195
1205
  } else await onSuccess?.(config, ab.signal);
1196
1206
  }
1197
1207
  }
@@ -1,4 +1,3 @@
1
- import "ansis";
2
1
  import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, OutputAsset, OutputChunk, OutputOptions, Plugin } from "rolldown";
3
2
  import { Hookable } from "hookable";
4
3
  import { CheckPackageOptions } from "@arethetypeswrong/core";
@@ -47,17 +46,26 @@ interface CopyEntry {
47
46
  type CopyOptions = Arrayable<string | CopyEntry>;
48
47
  type CopyOptionsFn = (options: ResolvedOptions) => Awaitable<CopyOptions>;
49
48
  //#endregion
50
- //#region src/utils/logger.d.ts
51
- declare class Logger {
52
- silent: boolean;
53
- setSilent(value: boolean): void;
54
- filter(...args: any[]): any[];
55
- info(...args: any[]): void;
56
- warn(...args: any[]): void;
57
- error(...args: any[]): void;
58
- success(...args: any[]): void;
49
+ //#region src/features/exports.d.ts
50
+ type TsdownChunks = Partial<Record<NormalizedFormat, Array<OutputChunk | OutputAsset>>>;
51
+ interface ExportsOptions {
52
+ /**
53
+ * Generate exports that link to source code during development.
54
+ * - string: add as a custom condition.
55
+ * - true: all conditions point to source files, and add dist exports to `publishConfig`.
56
+ */
57
+ devExports?: boolean | string;
58
+ /**
59
+ * Exports for all files.
60
+ */
61
+ all?: boolean;
62
+ customExports?: (exports: Record<string, any>, context: {
63
+ pkg: PackageJson;
64
+ chunks: TsdownChunks;
65
+ outDir: string;
66
+ isPublish: boolean;
67
+ }) => Awaitable<Record<string, any>>;
59
68
  }
60
- declare const logger: Logger;
61
69
  //#endregion
62
70
  //#region src/features/hooks.d.ts
63
71
  interface BuildContext {
@@ -89,43 +97,6 @@ interface TsdownHooks {
89
97
  "build:done": (ctx: BuildContext) => void | Promise<void>;
90
98
  }
91
99
  //#endregion
92
- //#region src/index.d.ts
93
- /**
94
- * Build with tsdown.
95
- */
96
- declare function build$1(userOptions?: Options): Promise<void>;
97
- declare const shimFile: string;
98
- type TsdownChunks = Partial<Record<NormalizedFormat, Array<OutputChunk | OutputAsset>>>;
99
- /**
100
- * Build a single configuration, without watch and shortcuts features.
101
- *
102
- * Internal API, not for public use
103
- *
104
- * @private
105
- * @param config Resolved options
106
- */
107
- declare function buildSingle(config: ResolvedOptions, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
108
- //#endregion
109
- //#region src/features/exports.d.ts
110
- interface ExportsOptions {
111
- /**
112
- * Generate exports that link to source code during development.
113
- * - string: add as a custom condition.
114
- * - true: all conditions point to source files, and add dist exports to `publishConfig`.
115
- */
116
- devExports?: boolean | string;
117
- /**
118
- * Exports for all files.
119
- */
120
- all?: boolean;
121
- customExports?: (exports: Record<string, any>, context: {
122
- pkg: PackageJson;
123
- chunks: TsdownChunks;
124
- outDir: string;
125
- isPublish: boolean;
126
- }) => Awaitable<Record<string, any>>;
127
- }
128
- //#endregion
129
100
  //#region src/utils/package.d.ts
130
101
  type PackageType = "module" | "commonjs" | undefined;
131
102
  //#endregion
@@ -463,10 +434,4 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "w
463
434
  nodeProtocol: "strip" | boolean;
464
435
  }>, "config" | "fromVite">;
465
436
  //#endregion
466
- //#region src/config.d.ts
467
- /**
468
- * Defines the configuration for tsdown.
469
- */
470
- declare function defineConfig<const T extends UserConfig | UserConfigFn>(options: T): T;
471
- //#endregion
472
- export { type AttwOptions, type BuildContext, type ChunkAddon, type CopyOptions, type DtsOptions, type ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, type Options, type PublintOptions, type ReportOptions, ReportPlugin, type ResolvedOptions, type RolldownContext, Sourcemap, TsdownChunks, type TsdownHooks, type UnusedOptions, type UserConfig, type UserConfigFn, Workspace, build$1 as build, buildSingle, defineConfig, logger, shimFile };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -74,51 +74,49 @@
74
74
  "diff": "^8.0.2",
75
75
  "empathic": "^2.0.0",
76
76
  "hookable": "^5.5.3",
77
- "rolldown": "^1.0.0-beta.28",
78
- "rolldown-plugin-dts": "^0.14.0",
77
+ "rolldown": "^1.0.0-beta.30",
78
+ "rolldown-plugin-dts": "^0.15.0",
79
79
  "semver": "^7.7.2",
80
80
  "tinyexec": "^1.0.1",
81
81
  "tinyglobby": "^0.2.14",
82
+ "tree-kill": "^1.2.2",
82
83
  "unconfig": "^7.3.2"
83
84
  },
84
85
  "devDependencies": {
85
86
  "@arethetypeswrong/core": "^0.18.2",
86
- "@sxzz/eslint-config": "^7.0.6",
87
+ "@sxzz/eslint-config": "^7.1.2",
87
88
  "@sxzz/prettier-config": "^2.2.3",
88
- "@sxzz/test-utils": "^0.5.7",
89
+ "@sxzz/test-utils": "^0.5.9",
89
90
  "@types/debug": "^4.1.12",
90
- "@types/node": "^24.0.14",
91
+ "@types/node": "^24.1.0",
91
92
  "@types/semver": "^7.7.0",
92
- "@unocss/eslint-plugin": "^66.3.3",
93
- "@vueuse/core": "^13.5.0",
94
- "bumpp": "^10.2.0",
95
- "eslint": "^9.31.0",
93
+ "@unocss/eslint-plugin": "^66.4.0",
94
+ "@vueuse/core": "^13.6.0",
95
+ "bumpp": "^10.2.2",
96
+ "eslint": "^9.32.0",
96
97
  "lightningcss": "^1.30.1",
97
- "oxc-minify": "^0.77.2",
98
+ "oxc-minify": "^0.79.1",
98
99
  "pkg-types": "^2.2.0",
99
100
  "prettier": "^3.6.2",
100
101
  "publint": "^0.3.12",
101
102
  "tsx": "^4.20.3",
102
- "typedoc": "^0.28.7",
103
- "typedoc-plugin-markdown": "^4.7.0",
104
- "typescript": "~5.8.3",
105
- "unocss": "^66.3.3",
103
+ "typedoc": "^0.28.9",
104
+ "typedoc-plugin-markdown": "^4.8.0",
105
+ "typedoc-vitepress-theme": "^1.1.2",
106
+ "typescript": "~5.9.2",
107
+ "unocss": "^66.4.0",
106
108
  "unplugin-lightningcss": "^0.4.1",
107
109
  "unplugin-unused": "^0.5.1",
108
110
  "vite": "npm:rolldown-vite@latest",
109
111
  "vitepress": "^2.0.0-alpha.7",
110
112
  "vitepress-plugin-group-icons": "^1.6.1",
111
- "vitepress-plugin-llms": "^1.7.1",
113
+ "vitepress-plugin-llms": "^1.7.2",
112
114
  "vitest": "^3.2.4",
113
- "vue": "^3.5.17"
115
+ "vue": "^3.5.18"
114
116
  },
115
117
  "engines": {
116
118
  "node": ">=20.19.0"
117
119
  },
118
- "resolutions": {
119
- "rolldown": "catalog:prod",
120
- "vite": "catalog:docs"
121
- },
122
120
  "prettier": "@sxzz/prettier-config",
123
121
  "scripts": {
124
122
  "lint": "eslint --cache --max-warnings 0 .",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.13.0";
3
-
4
- //#endregion
5
- export { version };