tsdown 0.13.1 → 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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from "./config-CCGWF4al.mjs";
2
- import { build, buildSingle, shimFile } from "./src-CbHsyAUh.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-DjP1xJYq.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 };
package/dist/plugins.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./config-CCGWF4al.mjs";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-CbHsyAUh.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-DjP1xJYq.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-ZlgAVcyW.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();
@@ -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 debug from "debug";
14
+ import Debug from "debug";
15
15
  import { glob } from "tinyglobby";
16
16
  import { RE_CSS, RE_DTS, RE_JS } from "rolldown-plugin-dts/filename";
17
17
  import { createHooks } from "hookable";
@@ -20,6 +20,7 @@ import { Buffer } from "node:buffer";
20
20
  import { brotliCompress, gzip } from "node:zlib";
21
21
  import readline from "node:readline";
22
22
  import minVersion from "semver/ranges/min-version.js";
23
+ import { globalContext, invalidateContextFile } from "rolldown-plugin-dts/tsc-context";
23
24
  import { up as up$1 } from "empathic/find";
24
25
  import { loadConfig } from "unconfig";
25
26
 
@@ -63,7 +64,7 @@ function lowestCommonAncestor(...filepaths) {
63
64
 
64
65
  //#endregion
65
66
  //#region src/features/attw.ts
66
- const debug$7 = debug("tsdown:attw");
67
+ const debug$6 = Debug("tsdown:attw");
67
68
  const exec$1 = promisify(child_process.exec);
68
69
  /**
69
70
  * ATTW profiles.
@@ -110,7 +111,7 @@ async function attw(options) {
110
111
  }
111
112
  const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
112
113
  const t = performance.now();
113
- debug$7("Running attw check");
114
+ debug$6("Running attw check");
114
115
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
115
116
  let attwCore;
116
117
  try {
@@ -144,7 +145,7 @@ async function attw(options) {
144
145
  } else logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
145
146
  } catch (error) {
146
147
  logger.error("ATTW check failed:", error);
147
- debug$7("Found errors, setting exit code to 1");
148
+ debug$6("Found errors, setting exit code to 1");
148
149
  process.exitCode = 1;
149
150
  } finally {
150
151
  await fsRemove(tempDir);
@@ -153,7 +154,7 @@ async function attw(options) {
153
154
 
154
155
  //#endregion
155
156
  //#region src/features/clean.ts
156
- const debug$6 = debug("tsdown:clean");
157
+ const debug$5 = Debug("tsdown:clean");
157
158
  const RE_LAST_SLASH = /[/\\]$/;
158
159
  async function cleanOutDir(configs) {
159
160
  const removes = /* @__PURE__ */ new Set();
@@ -173,10 +174,10 @@ async function cleanOutDir(configs) {
173
174
  if (!removes.size) return;
174
175
  logger.info(`Cleaning ${removes.size} files`);
175
176
  await Promise.all([...removes].map(async (file) => {
176
- debug$6("Removing", file);
177
+ debug$5("Removing", file);
177
178
  await fsRemove(file);
178
179
  }));
179
- debug$6("Removed %d files", removes.size);
180
+ debug$5("Removed %d files", removes.size);
180
181
  }
181
182
  function resolveClean(clean, outDir, cwd) {
182
183
  if (clean === true) clean = [slash(outDir)];
@@ -310,7 +311,7 @@ function exportMeta(exports, all) {
310
311
 
311
312
  //#endregion
312
313
  //#region src/features/external.ts
313
- const debug$5 = debug("tsdown:external");
314
+ const debug$4 = Debug("tsdown:external");
314
315
  function ExternalPlugin(options) {
315
316
  const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
316
317
  return {
@@ -338,7 +339,7 @@ function ExternalPlugin(options) {
338
339
  }
339
340
  if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
340
341
  if (shouldExternal) {
341
- debug$5("External dependency:", id);
342
+ debug$4("External dependency:", id);
342
343
  return {
343
344
  id,
344
345
  external: shouldExternal,
@@ -459,11 +460,11 @@ function NodeProtocolPlugin(nodeProtocolOption) {
459
460
 
460
461
  //#endregion
461
462
  //#region src/utils/package.ts
462
- const debug$4 = debug("tsdown:package");
463
+ const debug$3 = Debug("tsdown:package");
463
464
  async function readPackageJson(dir) {
464
465
  const packageJsonPath = up({ cwd: dir });
465
466
  if (!packageJsonPath) return;
466
- debug$4("Reading package.json:", packageJsonPath);
467
+ debug$3("Reading package.json:", packageJsonPath);
467
468
  const contents = await readFile(packageJsonPath, "utf8");
468
469
  return {
469
470
  ...JSON.parse(contents),
@@ -536,7 +537,7 @@ function resolveChunkAddon(chunkAddon, format) {
536
537
 
537
538
  //#endregion
538
539
  //#region src/features/publint.ts
539
- const debug$3 = debug("tsdown:publint");
540
+ const debug$2 = Debug("tsdown:publint");
540
541
  async function publint(options) {
541
542
  if (!options.publint) return;
542
543
  if (!options.pkg) {
@@ -544,11 +545,11 @@ async function publint(options) {
544
545
  return;
545
546
  }
546
547
  const t = performance.now();
547
- debug$3("Running publint");
548
+ debug$2("Running publint");
548
549
  const { publint: publint$1 } = await import("publint");
549
550
  const { formatMessage } = await import("publint/utils");
550
551
  const { messages } = await publint$1(options.publint === true ? {} : options.publint);
551
- debug$3("Found %d issues", messages.length);
552
+ debug$2("Found %d issues", messages.length);
552
553
  if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
553
554
  let hasError = false;
554
555
  for (const message of messages) {
@@ -562,7 +563,7 @@ async function publint(options) {
562
563
  logger[logType](formattedMessage);
563
564
  }
564
565
  if (hasError) {
565
- debug$3("Found errors, setting exit code to 1");
566
+ debug$2("Found errors, setting exit code to 1");
566
567
  process.exitCode = 1;
567
568
  }
568
569
  }
@@ -576,7 +577,7 @@ function formatBytes(bytes) {
576
577
 
577
578
  //#endregion
578
579
  //#region src/features/report.ts
579
- const debug$2 = debug("tsdown:report");
580
+ const debug$1 = Debug("tsdown:report");
580
581
  const brotliCompressAsync = promisify(brotliCompress);
581
582
  const gzipAsync = promisify(gzip);
582
583
  function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
@@ -617,19 +618,19 @@ function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
617
618
  };
618
619
  }
619
620
  async function calcSize(options, chunk) {
620
- debug$2(`Calculating size for`, chunk.fileName);
621
+ debug$1(`Calculating size for`, chunk.fileName);
621
622
  const content = chunk.type === "chunk" ? chunk.code : chunk.source;
622
623
  const raw = Buffer.byteLength(content, "utf8");
623
- debug$2("[size]", chunk.fileName, raw);
624
+ debug$1("[size]", chunk.fileName, raw);
624
625
  let gzip$1 = Infinity;
625
626
  let brotli = Infinity;
626
- 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");
627
628
  else {
628
629
  gzip$1 = (await gzipAsync(content)).length;
629
- debug$2("[gzip]", chunk.fileName, gzip$1);
630
+ debug$1("[gzip]", chunk.fileName, gzip$1);
630
631
  if (options.brotli) {
631
632
  brotli = (await brotliCompressAsync(content)).length;
632
- debug$2("[brotli]", chunk.fileName, brotli);
633
+ debug$1("[brotli]", chunk.fileName, brotli);
633
634
  }
634
635
  }
635
636
  return {
@@ -779,6 +780,7 @@ async function watchBuild(options, configFiles, rebuild, restart) {
779
780
  return;
780
781
  }
781
782
  logger.info(`Change detected: ${type} ${file}`);
783
+ invalidateContextFile(globalContext, file);
782
784
  debouncedRebuild();
783
785
  });
784
786
  return watcher;
@@ -915,11 +917,11 @@ async function loadConfigFile(options, workspace) {
915
917
  stopAt: workspace && path.dirname(workspace),
916
918
  defaults: {}
917
919
  }).finally(() => loaded = true);
918
- const file = sources[0];
919
- if (file) logger.info(`Using tsdown config: ${underline(file)}`);
920
920
  if (typeof config === "function") config = await config(options);
921
921
  config = toArray(config);
922
922
  if (config.length === 0) config.push({});
923
+ const file = sources[0];
924
+ if (file) logger.info(`Using tsdown config: ${underline(file)}`);
923
925
  return {
924
926
  configs: config,
925
927
  file
@@ -928,7 +930,7 @@ async function loadConfigFile(options, workspace) {
928
930
 
929
931
  //#endregion
930
932
  //#region src/options/index.ts
931
- const debug$1 = debug("tsdown:options");
933
+ const debug = Debug("tsdown:options");
932
934
  const DEFAULT_EXCLUDE_WORKSPACE = [
933
935
  "**/node_modules/**",
934
936
  "**/dist/**",
@@ -937,20 +939,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
937
939
  ];
938
940
  async function resolveOptions(options) {
939
941
  const files = [];
940
- debug$1("options %O", options);
941
- debug$1("loading config file: %s", options.config);
942
+ debug("options %O", options);
943
+ debug("loading config file: %s", options.config);
942
944
  const { configs: rootConfigs, file } = await loadConfigFile(options);
943
945
  if (file) {
944
946
  files.push(file);
945
- debug$1("loaded root config file %s", file);
946
- debug$1("root configs %o", rootConfigs);
947
- } 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");
948
950
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
949
951
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
950
952
  if (workspaceFiles) files.push(...workspaceFiles);
951
953
  return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
952
954
  }))).flat();
953
- debug$1("resolved configs %O", configs);
955
+ debug("resolved configs %O", configs);
954
956
  return {
955
957
  configs,
956
958
  files
@@ -992,16 +994,16 @@ async function resolveWorkspace(config, options) {
992
994
  }
993
995
  const files = [];
994
996
  const configs = (await Promise.all(packages.map(async (cwd) => {
995
- debug$1("loading workspace config %s", cwd);
997
+ debug("loading workspace config %s", cwd);
996
998
  const { configs: configs$1, file } = await loadConfigFile({
997
999
  ...options,
998
1000
  config: workspaceConfig,
999
1001
  cwd
1000
1002
  }, cwd);
1001
1003
  if (file) {
1002
- debug$1("loaded workspace config file %s", file);
1004
+ debug("loaded workspace config file %s", file);
1003
1005
  files.push(file);
1004
- } else debug$1("no workspace config file found in %s", cwd);
1006
+ } else debug("no workspace config file found in %s", cwd);
1005
1007
  return configs$1.map((config$1) => ({
1006
1008
  ...normalized,
1007
1009
  cwd,
@@ -1015,6 +1017,7 @@ async function resolveWorkspace(config, options) {
1015
1017
  }
1016
1018
  async function resolveConfig(userConfig) {
1017
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);
1018
1021
  if (typeof bundle === "boolean") logger.warn("`bundle` option is deprecated. Use `unbundle` instead.");
1019
1022
  nodeProtocol = nodeProtocol ?? (removeNodeProtocol ? "strip" : false);
1020
1023
  outDir = path.resolve(cwd, outDir);
@@ -1112,7 +1115,6 @@ function ShebangPlugin(cwd, name, isMultiFormat) {
1112
1115
  * Build with tsdown.
1113
1116
  */
1114
1117
  async function build$1(userOptions = {}) {
1115
- if (typeof userOptions.silent === "boolean") logger.setSilent(userOptions.silent);
1116
1118
  const { configs, files: configFiles } = await resolveOptions(userOptions);
1117
1119
  let cleanPromise;
1118
1120
  const clean = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -75,7 +75,7 @@
75
75
  "empathic": "^2.0.0",
76
76
  "hookable": "^5.5.3",
77
77
  "rolldown": "^1.0.0-beta.30",
78
- "rolldown-plugin-dts": "^0.14.3",
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",
@@ -84,15 +84,15 @@
84
84
  },
85
85
  "devDependencies": {
86
86
  "@arethetypeswrong/core": "^0.18.2",
87
- "@sxzz/eslint-config": "^7.1.1",
87
+ "@sxzz/eslint-config": "^7.1.2",
88
88
  "@sxzz/prettier-config": "^2.2.3",
89
89
  "@sxzz/test-utils": "^0.5.9",
90
90
  "@types/debug": "^4.1.12",
91
91
  "@types/node": "^24.1.0",
92
92
  "@types/semver": "^7.7.0",
93
- "@unocss/eslint-plugin": "^66.3.3",
93
+ "@unocss/eslint-plugin": "^66.4.0",
94
94
  "@vueuse/core": "^13.6.0",
95
- "bumpp": "^10.2.1",
95
+ "bumpp": "^10.2.2",
96
96
  "eslint": "^9.32.0",
97
97
  "lightningcss": "^1.30.1",
98
98
  "oxc-minify": "^0.79.1",
@@ -100,11 +100,11 @@
100
100
  "prettier": "^3.6.2",
101
101
  "publint": "^0.3.12",
102
102
  "tsx": "^4.20.3",
103
- "typedoc": "^0.28.8",
103
+ "typedoc": "^0.28.9",
104
104
  "typedoc-plugin-markdown": "^4.8.0",
105
105
  "typedoc-vitepress-theme": "^1.1.2",
106
- "typescript": "~5.8.3",
107
- "unocss": "^66.3.3",
106
+ "typescript": "~5.9.2",
107
+ "unocss": "^66.4.0",
108
108
  "unplugin-lightningcss": "^0.4.1",
109
109
  "unplugin-unused": "^0.5.1",
110
110
  "vite": "npm:rolldown-vite@latest",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.13.1";
3
-
4
- //#endregion
5
- export { version };