tsdown 0.14.1 → 0.14.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/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  <img src="./docs/public/og-image.svg" alt="tsdown" width="100%" /><br>
2
2
 
3
- # tsdown [![npm](https://img.shields.io/npm/v/tsdown.svg)](https://npmjs.com/package/tsdown) [![Unit Test](https://github.com/rolldown/tsdown/actions/workflows/tests.yml/badge.svg)](https://github.com/rolldown/tsdown/actions/workflows/tests.yml) [![tsdown-starter-stackblitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/github/rolldown/tsdown-starter-stackblitz)
3
+ # tsdown
4
+
5
+ [![npm version][npm-version-src]][npm-version-href]
6
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
+ [![Unit Test][unit-test-src]][unit-test-href]
8
+ [![tsdown Starter StackBlitz][tsdown-starter-stackblitz-src]][tsdown-starter-stackblitz-href]
4
9
 
5
10
  ✨ The elegant bundler for libraries powered by [Rolldown](https://github.com/rolldown/rolldown).
6
11
 
@@ -53,3 +58,14 @@ This project also partially contains code derived or copied from the following p
53
58
  ## Licenses
54
59
 
55
60
  This project is licensed under the [MIT License](LICENSE).
61
+
62
+ <!-- Badges -->
63
+
64
+ [npm-version-src]: https://img.shields.io/npm/v/tsdown.svg
65
+ [npm-version-href]: https://npmjs.com/package/tsdown
66
+ [npm-downloads-src]: https://img.shields.io/npm/dm/tsdown
67
+ [npm-downloads-href]: https://www.npmcharts.com/compare/tsdown?interval=30
68
+ [unit-test-src]: https://github.com/rolldown/tsdown/actions/workflows/unit-test.yml/badge.svg
69
+ [unit-test-href]: https://github.com/rolldown/tsdown/actions/workflows/unit-test.yml
70
+ [tsdown-starter-stackblitz-src]: https://developer.stackblitz.com/img/open_in_stackblitz_small.svg
71
+ [tsdown-starter-stackblitz-href]: https://stackblitz.com/github/rolldown/tsdown-starter-stackblitz
@@ -1,4 +1,4 @@
1
- import { UserConfig, UserConfigFn } from "./types-BMMC0pbr.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-cXo_SNGd.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-BMMC0pbr.mjs";
2
- import { defineConfig } from "./config-77IY7Jdj.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-cXo_SNGd.mjs";
2
+ import { defineConfig } from "./config-DwMASPo6.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, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-BMMC0pbr.mjs";
2
- import { defineConfig } from "./config-77IY7Jdj.mjs";
1
+ import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-cXo_SNGd.mjs";
2
+ import { defineConfig } from "./config-DwMASPo6.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-XtWW9dvn.mjs";
2
+ import { build, buildSingle, shimFile } from "./src-BhIGOkxO.mjs";
3
3
  import { globalLogger } from "./logger-CGMSjTLn.mjs";
4
4
 
5
5
  export { build, buildSingle, defineConfig, globalLogger, shimFile };
@@ -1,5 +1,5 @@
1
1
  import { globalLogger } from "./logger-CGMSjTLn.mjs";
2
- import { version } from "./package-hNMMm6hX.mjs";
2
+ import { version } from "./package-DOwY1eta.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";
@@ -33,6 +33,11 @@ async function migrate({ cwd, dryRun }) {
33
33
  process.exitCode = 1;
34
34
  }
35
35
  }
36
+ const DEP_FIELDS = {
37
+ dependencies: `^${version}`,
38
+ devDependencies: `^${version}`,
39
+ peerDependencies: "*"
40
+ };
36
41
  async function migratePackageJson(dryRun) {
37
42
  if (!existsSync("package.json")) {
38
43
  globalLogger.error("No package.json found");
@@ -40,22 +45,11 @@ async function migratePackageJson(dryRun) {
40
45
  }
41
46
  const pkgRaw = await readFile("package.json", "utf-8");
42
47
  let pkg = JSON.parse(pkgRaw);
43
- const semver = `^${version}`;
44
48
  let found = false;
45
- if (pkg.dependencies?.tsup) {
46
- globalLogger.info("Migrating `dependencies` to tsdown.");
49
+ for (const [field, semver] of Object.entries(DEP_FIELDS)) if (pkg[field]?.tsup) {
50
+ globalLogger.info(`Migrating \`${field}\` to tsdown.`);
47
51
  found = true;
48
- pkg.dependencies = renameKey(pkg.dependencies, "tsup", "tsdown", semver);
49
- }
50
- if (pkg.devDependencies?.tsup) {
51
- globalLogger.info("Migrating `devDependencies` to tsdown.");
52
- found = true;
53
- pkg.devDependencies = renameKey(pkg.devDependencies, "tsup", "tsdown", semver);
54
- }
55
- if (pkg.peerDependencies?.tsup) {
56
- globalLogger.info("Migrating `peerDependencies` to tsdown.");
57
- found = true;
58
- pkg.peerDependencies = renameKey(pkg.peerDependencies, "tsup", "tsdown", "*");
52
+ pkg[field] = renameKey(pkg[field], "tsup", "tsdown", semver);
59
53
  }
60
54
  if (pkg.scripts) {
61
55
  for (const key of Object.keys(pkg.scripts)) if (pkg.scripts[key].includes("tsup")) {
@@ -73,7 +67,7 @@ async function migratePackageJson(dryRun) {
73
67
  globalLogger.warn("No tsup-related fields found in package.json");
74
68
  return false;
75
69
  }
76
- const pkgStr = `${JSON.stringify(pkg, null, 2)}\n`;
70
+ const pkgStr = `${JSON.stringify(pkg, null, pkgRaw.includes(" ") ? " " : 2)}\n`;
77
71
  if (dryRun) {
78
72
  const { createPatch } = await import("diff");
79
73
  globalLogger.info("[dry-run] package.json:");
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.14.2";
3
+
4
+ //#endregion
5
+ export { version };
@@ -1,4 +1,4 @@
1
- import { Logger, ReportPlugin, ResolvedOptions } from "./types-BMMC0pbr.mjs";
1
+ import { Logger, ReportPlugin, ResolvedOptions } from "./types-cXo_SNGd.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-XtWW9dvn.mjs";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-BhIGOkxO.mjs";
3
3
  import "./logger-CGMSjTLn.mjs";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { globalLogger, resolveComma, toArray } from "./logger-CGMSjTLn.mjs";
3
- import { version } from "./package-hNMMm6hX.mjs";
3
+ import { version } from "./package-DOwY1eta.mjs";
4
4
  import module from "node:module";
5
5
  import process from "node:process";
6
6
  import { dim } from "ansis";
@@ -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-ByqyzNKc.mjs");
25
+ const { migrate } = await import("./migrate-DQpxfr1J.mjs");
26
26
  await migrate(args);
27
27
  });
28
28
  async function runCLI() {
@@ -326,6 +326,18 @@ function exportMeta(exports, all) {
326
326
  if (all) exports["./*"] = "./*";
327
327
  else exports["./package.json"] = "./package.json";
328
328
  }
329
+ function hasExportsTypes(pkg) {
330
+ const exports = pkg?.exports;
331
+ if (!exports) return false;
332
+ if (typeof exports === "object" && exports !== null && !Array.isArray(exports)) {
333
+ if ("types" in exports) return true;
334
+ if ("." in exports) {
335
+ const mainExport = exports["."];
336
+ if (typeof mainExport === "object" && mainExport !== null && "types" in mainExport) return true;
337
+ }
338
+ }
339
+ return false;
340
+ }
329
341
 
330
342
  //#endregion
331
343
  //#region src/features/hooks.ts
@@ -699,7 +711,7 @@ async function resolveConfig(userConfig) {
699
711
  const pkg = await readPackageJson(cwd);
700
712
  if (workspace) name ||= pkg?.name;
701
713
  entry = await resolveEntry(logger, entry, cwd, name);
702
- if (dts == null) dts = !!(pkg?.types || pkg?.typings);
714
+ if (dts == null) dts = !!(pkg?.types || pkg?.typings || hasExportsTypes(pkg));
703
715
  target = resolveTarget(logger, target, pkg, name);
704
716
  tsconfig = await resolveTsconfig(logger, tsconfig, cwd, name);
705
717
  if (typeof external === "string") external = resolveRegex(external);
@@ -1099,10 +1111,8 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
1099
1111
  input: entry,
1100
1112
  cwd,
1101
1113
  external,
1102
- resolve: {
1103
- alias,
1104
- tsconfigFilename: tsconfig || void 0
1105
- },
1114
+ resolve: { alias },
1115
+ tsconfig: tsconfig || void 0,
1106
1116
  treeshake,
1107
1117
  platform: cjsDts || format === "cjs" ? "node" : platform,
1108
1118
  define: {
@@ -245,6 +245,15 @@ interface Options {
245
245
  * @default true
246
246
  */
247
247
  treeshake?: boolean;
248
+ /**
249
+ * Sets how input files are processed.
250
+ * For example, use 'js' to treat files as JavaScript or 'base64' for images.
251
+ * Lets you import or require files like images or fonts.
252
+ * @example
253
+ * ```json
254
+ * { '.jpg': 'asset', '.png': 'base64' }
255
+ * ```
256
+ */
248
257
  loader?: ModuleTypes;
249
258
  /**
250
259
  * If enabled, strips the `node:` protocol prefix from import source.
@@ -275,15 +284,6 @@ interface Options {
275
284
  */
276
285
  nodeProtocol?: "strip" | boolean;
277
286
  plugins?: InputOptions["plugins"];
278
- /**
279
- * Sets how input files are processed.
280
- * For example, use 'js' to treat files as JavaScript or 'base64' for images.
281
- * Lets you import or require files like images or fonts.
282
- * @example
283
- * ```json
284
- * { '.jpg': 'asset', '.png': 'base64' }
285
- * ```
286
- */
287
287
  inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
288
288
  cjsDts: boolean;
289
289
  }) => Awaitable<InputOptions | void | null>);
@@ -392,11 +392,11 @@ interface Options {
392
392
  */
393
393
  onSuccess?: string | ((config: ResolvedOptions, signal: AbortSignal) => void | Promise<void>);
394
394
  /**
395
- * Emit TypeScript declaration files (.d.ts).
395
+ * Enables generation of TypeScript declaration files (`.d.ts`).
396
396
  *
397
- * By default, this feature is auto-detected based on the presence of the `types` field in the `package.json` file.
398
- * - If the `types` field is present in `package.json`, declaration file emission is enabled.
399
- * - If the `types` field is absent, declaration file emission is disabled by default.
397
+ * By default, this option is auto-detected based on your project's `package.json`:
398
+ * - If the `types` field is present, or if the main `exports` contains a `types` entry, declaration file generation is enabled by default.
399
+ * - Otherwise, declaration file generation is disabled by default.
400
400
  */
401
401
  dts?: boolean | DtsOptions;
402
402
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -75,44 +75,36 @@
75
75
  "empathic": "^2.0.0",
76
76
  "hookable": "^5.5.3",
77
77
  "rolldown": "latest",
78
- "rolldown-plugin-dts": "^0.15.6",
78
+ "rolldown-plugin-dts": "^0.15.8",
79
79
  "semver": "^7.7.2",
80
80
  "tinyexec": "^1.0.1",
81
81
  "tinyglobby": "^0.2.14",
82
82
  "tree-kill": "^1.2.2",
83
- "unconfig": "^7.3.2"
83
+ "unconfig": "^7.3.3"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@arethetypeswrong/core": "^0.18.2",
87
- "@sxzz/eslint-config": "^7.1.2",
88
- "@sxzz/prettier-config": "^2.2.3",
89
- "@sxzz/test-utils": "^0.5.9",
87
+ "@sxzz/eslint-config": "^7.1.4",
88
+ "@sxzz/prettier-config": "^2.2.4",
89
+ "@sxzz/test-utils": "^0.5.10",
90
90
  "@types/debug": "^4.1.12",
91
- "@types/node": "^24.2.1",
91
+ "@types/node": "^24.3.0",
92
92
  "@types/semver": "^7.7.0",
93
93
  "@unocss/eslint-plugin": "^66.4.2",
94
- "@vueuse/core": "^13.6.0",
95
- "bumpp": "^10.2.2",
96
- "eslint": "^9.33.0",
94
+ "@vueuse/core": "^13.7.0",
95
+ "bumpp": "^10.2.3",
96
+ "eslint": "^9.34.0",
97
97
  "lightningcss": "^1.30.1",
98
- "oxc-minify": "^0.81.0",
99
- "pkg-types": "^2.2.0",
98
+ "pkg-types": "^2.3.0",
100
99
  "prettier": "^3.6.2",
101
100
  "publint": "^0.3.12",
102
- "tsx": "^4.20.3",
103
- "typedoc": "^0.28.10",
104
- "typedoc-plugin-markdown": "^4.8.0",
105
- "typedoc-vitepress-theme": "^1.1.2",
101
+ "tsx": "^4.20.5",
106
102
  "typescript": "~5.9.2",
107
103
  "unocss": "^66.4.2",
108
- "unplugin-lightningcss": "^0.4.1",
109
- "unplugin-unused": "^0.5.1",
104
+ "unplugin-lightningcss": "^0.4.2",
105
+ "unplugin-unused": "^0.5.2",
110
106
  "vite": "npm:rolldown-vite@latest",
111
- "vitepress": "^2.0.0-alpha.7",
112
- "vitepress-plugin-group-icons": "^1.6.2",
113
- "vitepress-plugin-llms": "^1.7.2",
114
- "vitest": "^3.2.4",
115
- "vue": "^3.5.18"
107
+ "vitest": "^3.2.4"
116
108
  },
117
109
  "engines": {
118
110
  "node": ">=20.19.0"
@@ -127,9 +119,9 @@
127
119
  "typecheck": "tsc --noEmit",
128
120
  "format": "prettier --cache --write .",
129
121
  "release": "bumpp",
130
- "docs:dev": "vitepress dev docs",
131
- "docs:build": "vitepress build docs",
132
- "docs:preview": "vitepress preview docs",
133
- "docs:generate": "tsx ./docs/.vitepress/scripts/docs-generate.ts"
122
+ "docs:dev": "pnpm -C docs run dev",
123
+ "docs:build": "pnpm -C docs run build",
124
+ "docs:preview": "pnpm -C docs run preview",
125
+ "docs:generate": "pnpm -C docs run generate"
134
126
  }
135
127
  }
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.14.1";
3
-
4
- //#endregion
5
- export { version };