tsdown 0.6.3 → 0.6.5

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
@@ -27,6 +27,14 @@ export default defineConfig({
27
27
  })
28
28
  ```
29
29
 
30
+ ## Migrate from tsup
31
+
32
+ ```bash
33
+ npx tsdown migrate
34
+ ```
35
+
36
+ Please make sure to commit your changes before migrating.
37
+
30
38
  ## Credits
31
39
 
32
40
  This project also partially contains code derived or copied from [tsup](https://github.com/egoist/tsup).
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import { transformPlugin } from "rolldown/experimental";
9
9
  import { access, readdir, rm, stat } from "node:fs/promises";
10
10
  import Debug from "debug";
11
11
  import { glob } from "tinyglobby";
12
+ import { ResolverFactory } from "oxc-resolver";
12
13
  import { rollup } from "rollup";
13
14
  import DtsPlugin from "rollup-plugin-dts";
14
15
  import { readPackageJSON } from "pkg-types";
@@ -68,16 +69,47 @@ const TEMP_DTS_DIR = ".tsdown-types";
68
69
  function getTempDtsDir(format) {
69
70
  return `${TEMP_DTS_DIR}-${format}`;
70
71
  }
71
- async function bundleDts(options, jsExtension, format) {
72
+ let resolver;
73
+ async function bundleDts(options, jsExtension, format, pkg) {
72
74
  const ext = jsExtension.replace("j", "t");
73
75
  const dtsOutDir = path.resolve(options.outDir, getTempDtsDir(format));
74
76
  const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path.resolve(dtsOutDir, `${key}.d.${ext}`)]));
77
+ resolver ||= new ResolverFactory({
78
+ mainFields: ["types"],
79
+ conditionNames: [
80
+ "types",
81
+ "typings",
82
+ "import",
83
+ "require"
84
+ ],
85
+ extensions: [".d.ts", ".ts"],
86
+ modules: ["node_modules", "node_modules/@types"]
87
+ });
75
88
  const build$2 = await rollup({
76
89
  input: dtsEntry,
90
+ external: options.external,
77
91
  onLog(level, log, defaultHandler) {
78
92
  if (log.code !== "EMPTY_BUNDLE" && log.code !== "UNRESOLVED_IMPORT") defaultHandler(level, log);
79
93
  },
80
- plugins: [DtsPlugin()]
94
+ plugins: [
95
+ ExternalPlugin(options, pkg),
96
+ {
97
+ name: "resolve-dts",
98
+ async resolveId(id, importer) {
99
+ if (id[0] === "." || path.isAbsolute(id)) return;
100
+ if (/\0/.test(id)) return;
101
+ const directory = importer ? path.dirname(importer) : process.cwd();
102
+ const { path: resolved } = await resolver.async(directory, id);
103
+ if (!resolved) return;
104
+ if (/[cm]?jsx?$/.test(resolved)) {
105
+ const dts = resolved.replace(/\.([cm]?)jsx?$/, ".d.$1ts");
106
+ return await fsExists(dts) ? dts : undefined;
107
+ }
108
+ return resolved;
109
+ }
110
+ },
111
+ DtsPlugin()
112
+ ]
81
113
  });
82
114
  let outDir = options.outDir;
83
115
  const extraOutdir = options.dts.extraOutdir;
@@ -134,9 +166,9 @@ function resolveOutputExtension(pkg, format, fixedExtension) {
134
166
  //#region src/features/publint.ts
135
167
  const debug$1 = Debug("tsdown:publint");
136
168
  async function publint(pkg) {
169
+ debug$1("Running publint");
137
170
  const { publint: publint$1 } = await import("publint");
138
171
  const { formatMessage } = await import("publint/utils");
139
- debug$1("Running publint");
140
172
  const { messages } = await publint$1();
141
173
  debug$1("Found %d issues", messages.length);
142
174
  if (!messages.length) logger.success("No publint issues found");
@@ -473,7 +505,7 @@ async function buildSingle(config) {
473
505
  ...inputOptions,
474
506
  output: outputOptions
475
507
  });
476
- if (config.dts && config.bundleDts) await bundleDts(config, extension, format$1);
508
+ if (config.dts && config.bundleDts) await bundleDts(config, extension, format$1, pkg);
477
509
  }));
478
510
  if (config.publint) if (pkg) await publint(pkg);
479
511
  else logger.warn("publint is enabled but package.json is not found");
@@ -1,4 +1,4 @@
1
- import { version } from "./package-COmVwFsw.js";
1
+ import { version } from "./package-DgHGX-l-.js";
2
2
  import process from "node:process";
3
3
  import { readFile, unlink, writeFile } from "node:fs/promises";
4
4
  import consola from "consola";
@@ -0,0 +1,6 @@
1
+
2
+ //#region package.json
3
+ var version = "0.6.5";
4
+
5
+ //#endregion
6
+ export { version };
package/dist/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { logger, setSilent } from "./logger-4bmpqibt.js";
2
- import { version } from "./package-COmVwFsw.js";
2
+ import { version } from "./package-DgHGX-l-.js";
3
3
  import process from "node:process";
4
4
  import { VERSION } from "rolldown";
5
5
  import { dim } from "ansis";
@@ -16,7 +16,7 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
16
16
  await build$1(flags);
17
17
  });
18
18
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
19
- const { migrate } = await import("./migrate-DjS7871z.js");
19
+ const { migrate } = await import("./migrate-Dcr9ta0c.js");
20
20
  await migrate(args);
21
21
  });
22
22
  async function runCLI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "An even faster bundler powered by Rolldown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -13,6 +13,7 @@
13
13
  "url": "git+https://github.com/sxzz/tsdown.git"
14
14
  },
15
15
  "author": "三咲智子 Kevin Deng <sxzz@sxzz.moe>",
16
+ "funding": "https://github.com/sponsors/sxzz",
16
17
  "files": [
17
18
  "dist",
18
19
  "esm-shims.js"
@@ -59,34 +60,35 @@
59
60
  "consola": "^3.4.0",
60
61
  "debug": "^4.4.0",
61
62
  "diff": "^7.0.0",
63
+ "oxc-resolver": "^5.0.0",
62
64
  "pkg-types": "^2.1.0",
63
65
  "rolldown": "^1.0.0-beta.3",
64
- "rollup": "^4.34.9",
66
+ "rollup": "^4.35.0",
65
67
  "rollup-plugin-dts": "^6.1.1",
66
68
  "tinyglobby": "^0.2.12",
67
- "unconfig": "^7.3.0",
68
- "unplugin-isolated-decl": "^0.13.0"
69
+ "unconfig": "^7.3.1",
70
+ "unplugin-isolated-decl": "^0.13.2"
69
71
  },
70
72
  "devDependencies": {
71
- "@sxzz/eslint-config": "^5.2.0",
72
- "@sxzz/prettier-config": "^2.2.0",
73
+ "@sxzz/eslint-config": "^6.0.1",
74
+ "@sxzz/prettier-config": "^2.2.1",
73
75
  "@sxzz/test-utils": "^0.5.1",
74
76
  "@types/debug": "^4.1.12",
75
77
  "@types/diff": "^7.0.1",
76
- "@types/node": "^22.13.9",
78
+ "@types/node": "^22.13.10",
77
79
  "bumpp": "^10.0.3",
78
- "eslint": "^9.21.0",
79
- "oxc-transform": "^0.55.0",
80
+ "eslint": "^9.22.0",
81
+ "oxc-transform": "^0.56.5",
80
82
  "prettier": "^3.5.3",
81
- "publint": "^0.3.8",
83
+ "publint": "^0.3.9",
82
84
  "tinyexec": "^0.3.2",
83
85
  "tsup": "^8.4.0",
84
86
  "tsx": "^4.19.3",
85
87
  "typescript": "~5.8.2",
86
- "unplugin-ast": "^0.14.1",
88
+ "unplugin-ast": "^0.14.2",
87
89
  "unplugin-unused": "^0.4.3",
88
- "vite": "^6.2.0",
89
- "vitest": "^3.0.7"
90
+ "vite": "^6.2.1",
91
+ "vitest": "^3.0.8"
90
92
  },
91
93
  "engines": {
92
94
  "node": ">=18.0.0"
@@ -1,6 +0,0 @@
1
-
2
- //#region package.json
3
- var version = "0.6.3";
4
-
5
- //#endregion
6
- export { version };