tsdown 0.15.6 → 0.15.8

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,4 +1,4 @@
1
- import { UserConfig, UserConfigFn } from "./types-DMJKFE0E.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-CAr6Dndf.mjs";
2
2
 
3
3
  //#region src/config.d.ts
4
4
 
package/dist/config.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { UserConfig, UserConfigFn } from "./types-DMJKFE0E.mjs";
2
- import { defineConfig } from "./config-oNMlaVK7.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-CAr6Dndf.mjs";
2
+ import { defineConfig } from "./config-Ck33bdQw.mjs";
3
3
  export { UserConfig, UserConfigFn, defineConfig };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, NoExternalFn, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-DMJKFE0E.mjs";
2
- import { defineConfig } from "./config-oNMlaVK7.mjs";
1
+ import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, NoExternalFn, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-CAr6Dndf.mjs";
2
+ import { defineConfig } from "./config-Ck33bdQw.mjs";
3
3
 
4
4
  //#region src/index.d.ts
5
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-Bl9Gdsdl.mjs";
3
- import { globalLogger } from "./logger-BjPuONhe.mjs";
2
+ import { build, buildSingle, shimFile } from "./src-DjVGuMse.mjs";
3
+ import { globalLogger } from "./package-BPB-NGqU.mjs";
4
4
 
5
5
  export { build, buildSingle, defineConfig, globalLogger, shimFile };
@@ -1,5 +1,4 @@
1
- import { globalLogger } from "./logger-BjPuONhe.mjs";
2
- import { version } from "./package-f3XEXjm-.mjs";
1
+ import { globalLogger, version } from "./package-BPB-NGqU.mjs";
3
2
  import process from "node:process";
4
3
  import { bold, green, underline } from "ansis";
5
4
  import { readFile, unlink, writeFile } from "node:fs/promises";
@@ -110,8 +110,7 @@ function generateColor(name = "default") {
110
110
  else {
111
111
  let hash = 0;
112
112
  for (let i = 0; i < name.length; i++) hash = name.charCodeAt(i) + ((hash << 5) - hash);
113
- const hue = hash % 360;
114
- color = rgb(...hslToRgb(hue, 35, 55));
113
+ color = rgb(...hslToRgb(hash % 360, 35, 55));
115
114
  }
116
115
  colors.set(name, color);
117
116
  return color;
@@ -146,4 +145,8 @@ function hue2rgb(p, q, t) {
146
145
  }
147
146
 
148
147
  //#endregion
149
- export { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray };
148
+ //#region package.json
149
+ var version = "0.15.8";
150
+
151
+ //#endregion
152
+ export { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray, version };
@@ -1,4 +1,4 @@
1
- import { Logger, ReportPlugin, ResolvedOptions } from "./types-DMJKFE0E.mjs";
1
+ import { Logger, ReportPlugin, ResolvedOptions } from "./types-CAr6Dndf.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
1
  import "./config-CCGWF4al.mjs";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-Bl9Gdsdl.mjs";
3
- import "./logger-BjPuONhe.mjs";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-DjVGuMse.mjs";
3
+ import "./package-BPB-NGqU.mjs";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.mjs CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cjs_createRequire } from "node:module";
3
3
  const __cjs_require = __cjs_createRequire(import.meta.url);
4
- import { globalLogger, resolveComma, toArray } from "./logger-BjPuONhe.mjs";
5
- import { version } from "./package-f3XEXjm-.mjs";
4
+ import { globalLogger, resolveComma, toArray, version } from "./package-BPB-NGqU.mjs";
6
5
  import module from "node:module";
7
6
  import process from "node:process";
8
7
  import { dim } from "ansis";
@@ -24,7 +23,7 @@ cli.command("[...files]", "Bundle files", {
24
23
  await build$1(flags);
25
24
  });
26
25
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
27
- const { migrate } = await import("./migrate-CeG6I3xh.mjs");
26
+ const { migrate } = await import("./migrate-DWAdCBXo.mjs");
28
27
  await migrate(args);
29
28
  });
30
29
  async function runCLI() {
@@ -1,18 +1,18 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-BjPuONhe.mjs";
4
- import { builtinModules } from "node:module";
5
- import path, { dirname, normalize, sep } from "node:path";
3
+ import { LogLevels, createLogger, debounce, generateColor, globalLogger, matchPattern, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray, version } from "./package-BPB-NGqU.mjs";
4
+ import { builtinModules, isBuiltin } from "node:module";
5
+ import path, { dirname, join, normalize, sep } from "node:path";
6
6
  import process from "node:process";
7
7
  import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import { blue, bold, dim, green, underline } from "ansis";
9
- import { build } from "rolldown";
9
+ import { VERSION, build } from "rolldown";
10
10
  import { exec } from "tinyexec";
11
11
  const treeKill = __cjs_require("tree-kill");
12
12
  import child_process from "node:child_process";
13
13
  import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
14
14
  import { tmpdir } from "node:os";
15
- import { promisify } from "node:util";
15
+ import util, { promisify } from "node:util";
16
16
  const Debug = __cjs_require("debug");
17
17
  const coerce = __cjs_require("semver/functions/coerce.js");
18
18
  const satisfies = __cjs_require("semver/functions/satisfies.js");
@@ -131,8 +131,7 @@ async function attw(options) {
131
131
  });
132
132
  const parsed = JSON.parse(tarballInfo);
133
133
  if (!Array.isArray(parsed) || !parsed[0]?.filename) throw new Error("Invalid npm pack output format");
134
- const tarballPath = path.join(tempDir, parsed[0].filename);
135
- const tarball = await readFile(tarballPath);
134
+ const tarball = await readFile(path.join(tempDir, parsed[0].filename));
136
135
  const pkg = attwCore.createPackageFromTarballData(tarball);
137
136
  const checkResult = await attwCore.checkPackage(pkg, attwOptions);
138
137
  if (checkResult.types !== false && checkResult.problems.length) {
@@ -165,8 +164,8 @@ async function attw(options) {
165
164
  function warnLegacyCJS(config) {
166
165
  if (!config.format.includes("cjs") || !config.target) return;
167
166
  if (config.target.some((t) => {
168
- const version = coerce(t.split("node")[1]);
169
- return version && satisfies(version, ">=23.0.0 || >=22.12.0");
167
+ const version$1 = coerce(t.split("node")[1]);
168
+ return version$1 && satisfies(version$1, ">=23.0.0 || >=22.12.0");
170
169
  })) config.logger.warnOnce("We recommend using the ESM format instead of CommonJS.\nThe ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.\nLearn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here");
171
170
  }
172
171
 
@@ -354,16 +353,19 @@ const debug$5 = Debug("tsdown:publint");
354
353
  async function publint(options) {
355
354
  if (!options.publint) return;
356
355
  if (!options.pkg) {
357
- options.logger.warn("publint is enabled but package.json is not found");
356
+ options.logger.warn(prettyName(options.name), "publint is enabled but package.json is not found");
358
357
  return;
359
358
  }
360
359
  const t = performance.now();
361
360
  debug$5("Running publint");
362
361
  const { publint: publint$1 } = await import("publint");
363
362
  const { formatMessage } = await import("publint/utils");
364
- const { messages } = await publint$1(options.publint === true ? {} : options.publint);
363
+ const { messages } = await publint$1({
364
+ ...options.publint === true ? {} : options.publint,
365
+ pkgDir: path.dirname(options.pkg.packageJsonPath)
366
+ });
365
367
  debug$5("Found %d issues", messages.length);
366
- if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
368
+ if (!messages.length) options.logger.success(prettyName(options.name), `No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
367
369
  let hasError = false;
368
370
  for (const message of messages) {
369
371
  hasError ||= message.type === "error";
@@ -373,7 +375,7 @@ async function publint(options) {
373
375
  warning: "warn",
374
376
  suggestion: "info"
375
377
  }[message.type];
376
- options.logger[logType](formattedMessage);
378
+ options.logger[logType](prettyName(options.name), formattedMessage);
377
379
  }
378
380
  if (hasError) {
379
381
  debug$5("Found errors, setting exit code to 1");
@@ -419,6 +421,7 @@ function resolveTarget(logger, target, pkg, name) {
419
421
  if (pkgTarget) target = pkgTarget;
420
422
  else return;
421
423
  }
424
+ if (typeof target === "number") throw new TypeError(`Invalid target: ${target}`);
422
425
  const targets = resolveComma(toArray(target));
423
426
  if (targets.length) logger.info(prettyName(name), `target${targets.length > 1 ? "s" : ""}: ${generateColor(name)(targets.join(", "))}`);
424
427
  return targets;
@@ -778,7 +781,7 @@ function ExternalPlugin({ pkg, noExternal, inlineOnly, skipNodeModulesBundle })
778
781
  async resolveId(id, importer, extraOptions) {
779
782
  if (extraOptions.isEntry || !importer) return;
780
783
  const shouldExternal = await externalStrategy(this, id, importer, extraOptions);
781
- const nodeBuiltinModule = id.startsWith("node:") || builtinModules.includes(id);
784
+ const nodeBuiltinModule = isBuiltin(id);
782
785
  debug$2("shouldExternal: %s = %s", id, shouldExternal);
783
786
  if (shouldExternal === true || shouldExternal === "absolute") return {
784
787
  id,
@@ -832,11 +835,10 @@ function esbuildTargetToLightningCSS(target) {
832
835
  let targets;
833
836
  const matches = [...target.join(" ").toLowerCase().matchAll(TARGET_REGEX)];
834
837
  for (const match of matches) {
835
- const name = match[1];
836
- const browser = ESBUILD_LIGHTNINGCSS_MAPPING[name];
838
+ const browser = ESBUILD_LIGHTNINGCSS_MAPPING[match[1]];
837
839
  if (!browser) continue;
838
- const version = match[2];
839
- const versionInt = parseVersion(version);
840
+ const version$1 = match[2];
841
+ const versionInt = parseVersion(version$1);
840
842
  if (versionInt == null) continue;
841
843
  targets = targets || {};
842
844
  targets[browser] = versionInt;
@@ -853,8 +855,8 @@ const ESBUILD_LIGHTNINGCSS_MAPPING = {
853
855
  opera: "opera",
854
856
  safari: "safari"
855
857
  };
856
- function parseVersion(version) {
857
- const [major, minor = 0, patch = 0] = version.split("-")[0].split(".").map((v) => Number.parseInt(v, 10));
858
+ function parseVersion(version$1) {
859
+ const [major, minor = 0, patch = 0] = version$1.split("-")[0].split(".").map((v) => Number.parseInt(v, 10));
858
860
  if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) return null;
859
861
  return major << 16 | minor << 8 | patch;
860
862
  }
@@ -1165,6 +1167,38 @@ async function resolveOutputOptions(inputOptions, config, format, cjsDts) {
1165
1167
  footer: resolveChunkAddon(footer, format)
1166
1168
  }, config.outputOptions, [format, { cjsDts }]);
1167
1169
  }
1170
+ async function getDebugRolldownDir() {
1171
+ if (!debug.enabled) return;
1172
+ return await mkdtemp(join(tmpdir(), "tsdown-config-"));
1173
+ }
1174
+ async function debugBuildOptions(dir, name, format, buildOptions) {
1175
+ const outFile = join(dir, `tsdown.config.${format}.js`);
1176
+ handlePluginInspect(buildOptions.plugins);
1177
+ const serialized = util.formatWithOptions({
1178
+ depth: null,
1179
+ maxArrayLength: null,
1180
+ maxStringLength: null
1181
+ }, buildOptions);
1182
+ await writeFile(outFile, `/*
1183
+ Auto-generated rolldown config for tsdown debug purposes
1184
+ tsdown v${version}, rolldown v${VERSION}
1185
+ Generated on ${(/* @__PURE__ */ new Date()).toISOString()}
1186
+ Package name: ${name || "not specified"}
1187
+ */
1188
+
1189
+ export default ${serialized}\n`);
1190
+ debug("Wrote debug rolldown config for \"%s\" (%s) -> %s", name || "default name", format, outFile);
1191
+ }
1192
+ function handlePluginInspect(plugins) {
1193
+ if (Array.isArray(plugins)) for (const plugin of plugins) handlePluginInspect(plugin);
1194
+ else if (typeof plugins === "object" && plugins !== null && "name" in plugins) plugins[util.inspect.custom] = function(depth, options, inspect) {
1195
+ if ("_options" in plugins) return inspect({
1196
+ name: plugins.name,
1197
+ options: plugins._options
1198
+ }, options);
1199
+ else return `"rolldown plugin: ${plugins.name}"`;
1200
+ };
1201
+ }
1168
1202
 
1169
1203
  //#endregion
1170
1204
  //#region src/features/shortcuts.ts
@@ -1317,6 +1351,7 @@ async function buildSingle(config, clean) {
1317
1351
  let hasErrors = false;
1318
1352
  const isMultiFormat = formats.length > 1;
1319
1353
  const chunks = {};
1354
+ const debugRolldownDir = await getDebugRolldownDir();
1320
1355
  await Promise.all(formats.map(async (format) => {
1321
1356
  try {
1322
1357
  const buildOptions = await getBuildOptions(config, format, isMultiFormat, false);
@@ -1324,6 +1359,7 @@ async function buildSingle(config, clean) {
1324
1359
  ...context,
1325
1360
  buildOptions
1326
1361
  });
1362
+ if (debugRolldownDir) await debugBuildOptions(debugRolldownDir, config.name, format, buildOptions);
1327
1363
  const { output } = await build(buildOptions);
1328
1364
  chunks[format] = output;
1329
1365
  if (format === "cjs" && dts) {
@@ -316,7 +316,15 @@ interface Options {
316
316
  globalName?: string;
317
317
  /** @default 'dist' */
318
318
  outDir?: string;
319
- /** @default false */
319
+ /**
320
+ * Whether to generate source map files.
321
+ *
322
+ * Note that this option will always be `true` if you have
323
+ * [`declarationMap`](https://www.typescriptlang.org/tsconfig/#declarationMap)
324
+ * option enabled in your `tsconfig.json`.
325
+ *
326
+ * @default false
327
+ */
320
328
  sourcemap?: Sourcemap;
321
329
  /**
322
330
  * Clean directories before build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.15.6",
3
+ "version": "0.15.8",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -69,7 +69,7 @@
69
69
  }
70
70
  },
71
71
  "dependencies": {
72
- "ansis": "^4.1.0",
72
+ "ansis": "^4.2.0",
73
73
  "cac": "^6.7.14",
74
74
  "chokidar": "^4.0.3",
75
75
  "debug": "^4.4.3",
@@ -77,8 +77,8 @@
77
77
  "empathic": "^2.0.0",
78
78
  "hookable": "^5.5.3",
79
79
  "rolldown": "latest",
80
- "rolldown-plugin-dts": "^0.16.8",
81
- "semver": "^7.7.2",
80
+ "rolldown-plugin-dts": "^0.16.12",
81
+ "semver": "^7.7.3",
82
82
  "tinyexec": "^1.0.1",
83
83
  "tinyglobby": "^0.2.15",
84
84
  "tree-kill": "^1.2.2",
@@ -86,26 +86,26 @@
86
86
  },
87
87
  "devDependencies": {
88
88
  "@arethetypeswrong/core": "^0.18.2",
89
- "@sxzz/eslint-config": "^7.2.5",
89
+ "@sxzz/eslint-config": "^7.2.7",
90
90
  "@sxzz/prettier-config": "^2.2.4",
91
91
  "@sxzz/test-utils": "^0.5.11",
92
92
  "@types/debug": "^4.1.12",
93
- "@types/node": "^24.5.2",
93
+ "@types/node": "^24.8.1",
94
94
  "@types/semver": "^7.7.1",
95
- "@unocss/eslint-plugin": "^66.5.2",
95
+ "@unocss/eslint-plugin": "^66.5.4",
96
96
  "@vueuse/core": "^13.9.0",
97
- "bumpp": "^10.2.3",
98
- "eslint": "^9.36.0",
99
- "lightningcss": "^1.30.1",
97
+ "bumpp": "^10.3.1",
98
+ "eslint": "^9.38.0",
99
+ "lightningcss": "^1.30.2",
100
100
  "pkg-types": "^2.3.0",
101
101
  "prettier": "^3.6.2",
102
- "publint": "^0.3.13",
103
- "rolldown-plugin-require-cjs": "^0.3.0",
102
+ "publint": "^0.3.14",
103
+ "rolldown-plugin-require-cjs": "^0.3.1",
104
104
  "tsx": "^4.20.6",
105
- "typescript": "~5.9.2",
106
- "unocss": "^66.5.2",
105
+ "typescript": "~5.9.3",
106
+ "unocss": "^66.5.4",
107
107
  "unplugin-lightningcss": "^0.4.3",
108
- "unplugin-unused": "^0.5.3",
108
+ "unplugin-unused": "^0.5.4",
109
109
  "vite": "npm:rolldown-vite@latest",
110
110
  "vitest": "^3.2.4"
111
111
  },
@@ -121,7 +121,7 @@
121
121
  "test": "vitest",
122
122
  "typecheck": "tsc --noEmit",
123
123
  "format": "prettier --cache --write .",
124
- "release": "bumpp",
124
+ "release": "bumpp -r",
125
125
  "docs:dev": "pnpm -C docs run dev",
126
126
  "docs:build": "pnpm -C docs run build",
127
127
  "docs:preview": "pnpm -C docs run preview",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.15.6";
3
-
4
- //#endregion
5
- export { version };