tsdown 0.11.1 → 0.11.3

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 "./options-DS32cUm1.js";
1
+ import { UserConfig, UserConfigFn } from "./options-DTjUBBGw.js";
2
2
 
3
3
  //#region src/config.d.ts
4
4
  /**
package/dist/config.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { UserConfig, UserConfigFn } from "./options-DS32cUm1.js";
2
- import { defineConfig$1 as defineConfig } from "./config-BnSqG_Bk.js";
1
+ import { UserConfig, UserConfigFn } from "./options-DTjUBBGw.js";
2
+ import { defineConfig$1 as defineConfig } from "./config-CTSjQDga.js";
3
3
  export { UserConfig, UserConfigFn, defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./options-DS32cUm1.js";
2
- import { defineConfig$1 as defineConfig } from "./config-BnSqG_Bk.js";
1
+ import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./options-DTjUBBGw.js";
2
+ import { defineConfig$1 as defineConfig } from "./config-CTSjQDga.js";
3
3
 
4
4
  //#region src/utils/logger.d.ts
5
5
  declare class Logger {
package/dist/index.js CHANGED
@@ -11,7 +11,6 @@ import { build as build$1 } from "rolldown";
11
11
  import { transformPlugin } from "rolldown/experimental";
12
12
  import { exec } from "tinyexec";
13
13
  import { glob } from "tinyglobby";
14
- import { stat } from "node:fs/promises";
15
14
  import { createHooks } from "hookable";
16
15
  import readline from "node:readline";
17
16
  import { loadConfig } from "unconfig";
@@ -59,10 +58,10 @@ async function copy(options) {
59
58
  await Promise.all(toArray(copy$1).map((dir) => {
60
59
  const from = typeof dir === "string" ? dir : dir.from;
61
60
  const to = typeof dir === "string" ? path.resolve(options.outDir, path.basename(from)) : dir.to;
62
- return cp$1(options.cwd, from, to);
61
+ return cp(options.cwd, from, to);
63
62
  }));
64
63
  }
65
- function cp$1(cwd, from, to) {
64
+ function cp(cwd, from, to) {
66
65
  return fsCopy(path.resolve(cwd, from), path.resolve(cwd, to));
67
66
  }
68
67
 
@@ -297,16 +296,19 @@ async function watchBuild(options, configFile, rebuild, restart) {
297
296
  //#region src/features/entry.ts
298
297
  async function resolveEntry(entry, cwd) {
299
298
  if (!entry || Object.keys(entry).length === 0) throw new Error(`No input files, try "tsdown <your-file>" instead`);
300
- const objectEntry = await toObjectEntry(entry, cwd);
301
- const entries = Object.values(objectEntry);
299
+ const entryMap = await toObjectEntry(entry, cwd);
300
+ const entries = Object.values(entryMap);
302
301
  if (entries.length === 0) throw new Error(`Cannot find entry: ${JSON.stringify(entry)}`);
303
- logger.info(`entry: ${blue(entries.join(", "))}`);
304
- return objectEntry;
302
+ logger.info(`entry: ${blue(entries.map((entry$1) => path.relative(cwd, entry$1)).join(", "))}`);
303
+ return entryMap;
305
304
  }
306
305
  async function toObjectEntry(entry, cwd) {
307
306
  if (typeof entry === "string") entry = [entry];
308
307
  if (!Array.isArray(entry)) return entry;
309
- const resolvedEntry = await glob(entry, { cwd });
308
+ const resolvedEntry = await glob(entry, {
309
+ cwd,
310
+ absolute: true
311
+ });
310
312
  const base = lowestCommonAncestor(...resolvedEntry);
311
313
  return Object.fromEntries(resolvedEntry.map((file) => {
312
314
  const relative = path.relative(base, file);
@@ -323,7 +325,9 @@ function resolveTarget(target, pkg) {
323
325
  if (pkgTarget) target = pkgTarget;
324
326
  else return;
325
327
  }
326
- return resolveComma(toArray(target));
328
+ const targets = resolveComma(toArray(target));
329
+ if (targets.length) logger.info(`target${targets.length > 1 ? "s" : ""}: ${blue(targets.join(", "))}`);
330
+ return targets;
327
331
  }
328
332
  function resolvePackageTarget(pkg) {
329
333
  const nodeVersion = pkg?.engines?.node;
@@ -347,9 +351,9 @@ async function resolveTsconfig(tsconfig, cwd) {
347
351
  if (original && !tsconfig) logger.warn(`No tsconfig found in ${blue(cwd)}`);
348
352
  } else {
349
353
  const tsconfigPath = path.resolve(cwd, tsconfig);
350
- const stat$1 = await fsStat(tsconfigPath);
351
- if (stat$1?.isFile()) tsconfig = tsconfigPath;
352
- else if (stat$1?.isDirectory()) {
354
+ const stat = await fsStat(tsconfigPath);
355
+ if (stat?.isFile()) tsconfig = tsconfigPath;
356
+ else if (stat?.isDirectory()) {
353
357
  tsconfig = findTsconfig(tsconfigPath);
354
358
  if (!tsconfig) logger.warn(`No tsconfig found in ${blue(tsconfigPath)}`);
355
359
  } else {
@@ -366,24 +370,26 @@ async function resolveTsconfig(tsconfig, cwd) {
366
370
  //#region src/options.ts
367
371
  const debug$1 = Debug("tsdown:options");
368
372
  async function resolveOptions(options) {
369
- const { configs: userConfigs, file, cwd } = await loadConfigFile(options);
373
+ const { configs: userConfigs, file } = await loadConfigFile(options);
370
374
  if (userConfigs.length === 0) userConfigs.push({});
371
- debug$1("Loaded config file %s from %s", file, cwd);
372
- debug$1("User configs %o", userConfigs);
375
+ if (file) {
376
+ debug$1("Loaded config file %s", file);
377
+ debug$1("User configs %o", userConfigs);
378
+ }
373
379
  const configs = await Promise.all(userConfigs.map(async (subConfig) => {
374
380
  const subOptions = {
375
381
  ...subConfig,
376
382
  ...options
377
383
  };
378
- let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash } = subOptions;
384
+ let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd() } = subOptions;
379
385
  outDir = path.resolve(outDir);
380
386
  clean = resolveClean(clean, outDir, cwd);
381
387
  const pkg = await readPackageJson(cwd);
382
388
  entry = await resolveEntry(entry, cwd);
383
389
  if (dts == null) dts = !!(pkg?.types || pkg?.typings);
390
+ target = resolveTarget(target, pkg);
384
391
  tsconfig = await resolveTsconfig(tsconfig, cwd);
385
392
  if (publint$1 === true) publint$1 = {};
386
- target = resolveTarget(target, pkg);
387
393
  if (publicDir) if (copy$1) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
388
394
  else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
389
395
  if (fromVite) {
@@ -431,15 +437,12 @@ async function resolveOptions(options) {
431
437
  }
432
438
  let loaded = false;
433
439
  async function loadConfigFile(options) {
434
- let cwd = process.cwd();
440
+ let cwd = options.cwd || process.cwd();
435
441
  let overrideConfig = false;
436
442
  let { config: filePath } = options;
437
- if (filePath === false) return {
438
- configs: [],
439
- cwd
440
- };
443
+ if (filePath === false) return { configs: [] };
441
444
  if (typeof filePath === "string") {
442
- const stats = await stat(filePath).catch(() => null);
445
+ const stats = await fsStat(filePath);
443
446
  if (stats) {
444
447
  const resolved = path.resolve(filePath);
445
448
  if (stats.isFile()) {
@@ -484,8 +487,7 @@ async function loadConfigFile(options) {
484
487
  if (typeof config === "function") config = await config(options);
485
488
  return {
486
489
  configs: toArray(config),
487
- file,
488
- cwd
490
+ file
489
491
  };
490
492
  }
491
493
  async function loadViteConfig(prefix, cwd) {
@@ -1,5 +1,5 @@
1
1
  import { logger } from "./logger-DYeY_1KP.js";
2
- import { version } from "./package-CtZQ6FbS.js";
2
+ import { version } from "./package-CSh-i54i.js";
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";
@@ -252,6 +252,11 @@ interface Options$3 {
252
252
  * @default true
253
253
  */
254
254
  hash?: boolean;
255
+ /**
256
+ * The working directory of the config file.
257
+ * @default process.cwd()
258
+ */
259
+ cwd?: string;
255
260
  }
256
261
  /**
257
262
  * Options without specifying config file path.
@@ -265,9 +270,6 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir">,
265
270
  dts: false | Options$1;
266
271
  report: false | ReportOptions;
267
272
  tsconfig: string | false;
268
- cwd: string;
269
273
  pkg?: PackageJson;
270
- }>, "config" | "fromVite">;
271
-
272
- //#endregion
274
+ }>, "config" | "fromVite">; //#endregion
273
275
  export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn };
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.11.3";
3
+
4
+ //#endregion
5
+ export { version };
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options-DS32cUm1.js";
1
+ import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options-DTjUBBGw.js";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/run.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { resolveComma, toArray } from "./general-CPYs4M61.js";
3
3
  import { logger } from "./logger-DYeY_1KP.js";
4
- import { version } from "./package-CtZQ6FbS.js";
4
+ import { version } from "./package-CSh-i54i.js";
5
+ import module from "node:module";
5
6
  import process from "node:process";
6
7
  import { dim } from "ansis";
7
8
  import Debug from "debug";
8
9
  import { VERSION } from "rolldown";
9
- import module from "node:module";
10
10
  import { cac } from "cac";
11
11
 
12
12
  //#region src/cli.ts
@@ -20,7 +20,7 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
20
20
  await build$1(flags);
21
21
  });
22
22
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
23
- const { migrate } = await import("./migrate-CB-PFTao.js");
23
+ const { migrate } = await import("./migrate-D_oMCa9B.js");
24
24
  await migrate(args);
25
25
  });
26
26
  async function runCLI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "peerDependencies": {
45
45
  "publint": "^0.3.0",
46
- "unplugin-lightningcss": "^0.3.3",
47
- "unplugin-unused": "^0.4.0"
46
+ "unplugin-lightningcss": "^0.4.0",
47
+ "unplugin-unused": "^0.5.0"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "publint": {
@@ -58,15 +58,15 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "ansis": "^3.17.0",
61
+ "ansis": "^4.0.0",
62
62
  "cac": "^6.7.14",
63
63
  "chokidar": "^4.0.3",
64
64
  "debug": "^4.4.0",
65
65
  "diff": "^7.0.0",
66
66
  "empathic": "^1.1.0",
67
67
  "hookable": "^5.5.3",
68
- "rolldown": "1.0.0-beta.8-commit.534fde3",
69
- "rolldown-plugin-dts": "^0.11.1",
68
+ "rolldown": "1.0.0-beta.8-commit.05b3e10",
69
+ "rolldown-plugin-dts": "^0.11.4",
70
70
  "semver": "^7.7.1",
71
71
  "tinyexec": "^1.0.1",
72
72
  "tinyglobby": "^0.2.13",
@@ -74,14 +74,14 @@
74
74
  },
75
75
  "devDependencies": {
76
76
  "@oxc-node/core": "^0.0.27",
77
- "@sxzz/eslint-config": "^6.2.0",
77
+ "@sxzz/eslint-config": "^7.0.1",
78
78
  "@sxzz/prettier-config": "^2.2.1",
79
79
  "@sxzz/test-utils": "^0.5.6",
80
80
  "@types/debug": "^4.1.12",
81
81
  "@types/diff": "^7.0.2",
82
- "@types/node": "^22.15.14",
82
+ "@types/node": "^22.15.17",
83
83
  "@types/semver": "^7.7.0",
84
- "@unocss/eslint-plugin": "^66.1.0",
84
+ "@unocss/eslint-plugin": "^66.1.1",
85
85
  "bumpp": "^10.1.0",
86
86
  "eslint": "^9.26.0",
87
87
  "lightningcss": "^1.29.3",
@@ -92,9 +92,9 @@
92
92
  "typedoc": "^0.28.4",
93
93
  "typedoc-plugin-markdown": "^4.6.3",
94
94
  "typescript": "~5.8.3",
95
- "unocss": "^66.1.0",
96
- "unplugin-lightningcss": "^0.3.3",
97
- "unplugin-unused": "^0.4.4",
95
+ "unocss": "^66.1.1",
96
+ "unplugin-lightningcss": "^0.4.0",
97
+ "unplugin-unused": "^0.5.0",
98
98
  "vite": "^6.3.5",
99
99
  "vitepress": "^1.6.3",
100
100
  "vitepress-plugin-group-icons": "^1.5.2",
@@ -107,7 +107,7 @@
107
107
  },
108
108
  "prettier": "@sxzz/prettier-config",
109
109
  "scripts": {
110
- "lint": "eslint --cache .",
110
+ "lint": "eslint --cache --max-warnings 0 .",
111
111
  "lint:fix": "pnpm run lint --fix",
112
112
  "build": "node --import @oxc-node/core/register ./src/run.ts",
113
113
  "dev": "node --import @oxc-node/core/register ./src/run.ts",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.11.1";
3
-
4
- //#endregion
5
- export { version };