tsdown 0.11.0 → 0.11.1

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-7rAywKbw.js";
1
+ import { UserConfig, UserConfigFn } from "./options-DS32cUm1.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-7rAywKbw.js";
2
- import { defineConfig$1 as defineConfig } from "./config-B-A_eh0M.js";
1
+ import { UserConfig, UserConfigFn } from "./options-DS32cUm1.js";
2
+ import { defineConfig$1 as defineConfig } from "./config-BnSqG_Bk.js";
3
3
  export { UserConfig, UserConfigFn, defineConfig };
@@ -19,7 +19,10 @@ function debounce(fn, wait) {
19
19
  }, wait);
20
20
  };
21
21
  }
22
+ function slash(string) {
23
+ return string.replaceAll("\\", "/");
24
+ }
22
25
  const noop = (v) => v;
23
26
 
24
27
  //#endregion
25
- export { debounce, noop, resolveComma, toArray };
28
+ export { debounce, noop, resolveComma, slash, toArray };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./options-7rAywKbw.js";
2
- import { defineConfig$1 as defineConfig } from "./config-B-A_eh0M.js";
1
+ import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./options-DS32cUm1.js";
2
+ import { defineConfig$1 as defineConfig } from "./config-BnSqG_Bk.js";
3
3
 
4
4
  //#region src/utils/logger.d.ts
5
5
  declare class Logger {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineConfig } from "./config-yiJy1jd0.js";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson } from "./plugins-xuho_Cqn.js";
3
- import { logger } from "./logger-DKXLpcNj.js";
4
- import { debounce, resolveComma, toArray } from "./general-nv5tYplM.js";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson } from "./plugins-BPU33dye.js";
3
+ import { debounce, resolveComma, slash, toArray } from "./general-CPYs4M61.js";
4
+ import { logger } from "./logger-DYeY_1KP.js";
5
5
  import path from "node:path";
6
6
  import process from "node:process";
7
7
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -44,9 +44,10 @@ async function cleanOutDir(configs) {
44
44
  }));
45
45
  debug$3("Removed %d files", removes.size);
46
46
  }
47
- function resolveClean(clean, outDir) {
48
- if (clean === true) clean = [outDir];
47
+ function resolveClean(clean, outDir, cwd) {
48
+ if (clean === true) clean = [slash(outDir)];
49
49
  else if (!clean) clean = [];
50
+ if (clean.some((item) => path.resolve(item) === cwd)) throw new Error("Cannot clean the current working directory. Please specify a different path to clean option.");
50
51
  return clean;
51
52
  }
52
53
 
@@ -142,7 +143,7 @@ function resolveJsOutputExtension(packageType, format, fixedExtension) {
142
143
  default: return "js";
143
144
  }
144
145
  }
145
- function resolveChunkFilename({ outExtensions, fixedExtension, pkg }, inputOptions, format) {
146
+ function resolveChunkFilename({ outExtensions, fixedExtension, pkg, hash }, inputOptions, format) {
146
147
  const packageType = getPackageType(pkg);
147
148
  let jsExtension;
148
149
  let dtsExtension;
@@ -157,7 +158,7 @@ function resolveChunkFilename({ outExtensions, fixedExtension, pkg }, inputOptio
157
158
  }
158
159
  jsExtension ||= `.${resolveJsOutputExtension(packageType, format, fixedExtension)}`;
159
160
  const suffix = format === "iife" || format === "umd" ? `.${format}` : "";
160
- return [createChunkFilename(`[name]${suffix}`, jsExtension, dtsExtension), createChunkFilename(`[name]${suffix}-[hash]`, jsExtension, dtsExtension)];
161
+ return [createChunkFilename(`[name]${suffix}`, jsExtension, dtsExtension), createChunkFilename(`[name]${suffix}${hash ? "-[hash]" : ""}`, jsExtension, dtsExtension)];
161
162
  }
162
163
  function createChunkFilename(basename, jsExtension, dtsExtension) {
163
164
  if (!dtsExtension) return `${basename}${jsExtension}`;
@@ -265,9 +266,8 @@ function shortcuts(restart) {
265
266
  //#region src/features/watch.ts
266
267
  const endsWithPackageJson = /[\\/]package\.json$/;
267
268
  async function watchBuild(options, configFile, rebuild, restart) {
268
- const cwd = process.cwd();
269
- if (typeof options.watch === "boolean" && options.outDir === cwd) throw new Error(`Watch is enabled, but output directory is the same as the current working directory.Please specify a different watch directory using ${blue`watch`} option,or set ${blue`outDir`} to a different directory.`);
270
- const files = toArray(typeof options.watch === "boolean" ? cwd : options.watch);
269
+ if (typeof options.watch === "boolean" && options.outDir === options.cwd) throw new Error(`Watch is enabled, but output directory is the same as the current working directory.Please specify a different watch directory using ${blue`watch`} option,or set ${blue`outDir`} to a different directory.`);
270
+ const files = toArray(typeof options.watch === "boolean" ? options.cwd : options.watch);
271
271
  logger.info(`Watching for changes in ${files.join(", ")}`);
272
272
  if (configFile) files.push(configFile);
273
273
  const { watch } = await import("chokidar");
@@ -317,7 +317,8 @@ async function toObjectEntry(entry, cwd) {
317
317
  //#endregion
318
318
  //#region src/features/target.ts
319
319
  function resolveTarget(target, pkg) {
320
- if (!target) {
320
+ if (target === false) return;
321
+ if (target == null) {
321
322
  const pkgTarget = resolvePackageTarget(pkg);
322
323
  if (pkgTarget) target = pkgTarget;
323
324
  else return;
@@ -374,11 +375,11 @@ async function resolveOptions(options) {
374
375
  ...subConfig,
375
376
  ...options
376
377
  };
377
- 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 } = subOptions;
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;
378
379
  outDir = path.resolve(outDir);
379
- entry = await resolveEntry(entry, cwd);
380
- clean = resolveClean(clean, outDir);
380
+ clean = resolveClean(clean, outDir, cwd);
381
381
  const pkg = await readPackageJson(cwd);
382
+ entry = await resolveEntry(entry, cwd);
382
383
  if (dts == null) dts = !!(pkg?.types || pkg?.typings);
383
384
  tsconfig = await resolveTsconfig(tsconfig, cwd);
384
385
  if (publint$1 === true) publint$1 = {};
@@ -418,7 +419,8 @@ async function resolveOptions(options) {
418
419
  cwd,
419
420
  env,
420
421
  pkg,
421
- copy: publicDir || copy$1
422
+ copy: publicDir || copy$1,
423
+ hash: hash ?? true
422
424
  };
423
425
  return config;
424
426
  }));
@@ -1,5 +1,5 @@
1
- import { logger } from "./logger-DKXLpcNj.js";
2
- import { version } from "./package-r0-JZYQB.js";
1
+ import { logger } from "./logger-DYeY_1KP.js";
2
+ import { version } from "./package-CtZQ6FbS.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";
@@ -143,7 +143,7 @@ interface Options$3 {
143
143
  * { "target": ["node18", "es2020"] }
144
144
  * ```
145
145
  */
146
- target?: string | string[];
146
+ target?: string | string[] | false;
147
147
  define?: Record<string, string>;
148
148
  /** @default false */
149
149
  shims?: boolean;
@@ -247,6 +247,11 @@ interface Options$3 {
247
247
  * import('node:fs'); // becomes import('fs')
248
248
  */
249
249
  removeNodeProtocol?: boolean;
250
+ /**
251
+ * If enabled, appends hash to chunk filenames.
252
+ * @default true
253
+ */
254
+ hash?: boolean;
250
255
  }
251
256
  /**
252
257
  * Options without specifying config file path.
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.11.1";
3
+
4
+ //#endregion
5
+ export { version };
@@ -1,5 +1,5 @@
1
- import { logger } from "./logger-DKXLpcNj.js";
2
- import { noop, resolveComma, toArray } from "./general-nv5tYplM.js";
1
+ import { noop, resolveComma, toArray } from "./general-CPYs4M61.js";
2
+ import { logger } from "./logger-DYeY_1KP.js";
3
3
  import path, { dirname, normalize, sep } from "node:path";
4
4
  import { blue, bold, dim, green, underline, yellow } from "ansis";
5
5
  import Debug from "debug";
@@ -50,14 +50,12 @@ function lowestCommonAncestor(...filepaths) {
50
50
  //#endregion
51
51
  //#region src/features/external.ts
52
52
  const debug$2 = Debug("tsdown:external");
53
- const RE_DTS$1 = /\.d\.[cm]?ts$/;
54
53
  function ExternalPlugin(options) {
55
54
  const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
56
55
  return {
57
56
  name: "tsdown:external",
58
- async resolveId(id, importer, { isEntry }) {
59
- if (isEntry) return;
60
- if (importer && RE_DTS$1.test(importer)) return;
57
+ async resolveId(id, importer, extraOptions) {
58
+ if (extraOptions.isEntry) return;
61
59
  const { noExternal } = options;
62
60
  if (typeof noExternal === "function" && noExternal(id, importer)) return;
63
61
  if (noExternal) {
@@ -68,8 +66,8 @@ function ExternalPlugin(options) {
68
66
  }
69
67
  let shouldExternal = false;
70
68
  if (options.skipNodeModulesBundle) {
71
- const resolved = await this.resolve(id);
72
- if (!resolved) return;
69
+ const resolved = await this.resolve(id, importer, extraOptions);
70
+ if (!resolved) return resolved;
73
71
  shouldExternal = resolved.external || /[\\/]node_modules[\\/]/.test(resolved.id);
74
72
  }
75
73
  if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options-7rAywKbw.js";
1
+ import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options-DS32cUm1.js";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/plugins.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-xuho_Cqn.js";
2
- import "./logger-DKXLpcNj.js";
3
- import "./general-nv5tYplM.js";
1
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-BPU33dye.js";
2
+ import "./general-CPYs4M61.js";
3
+ import "./logger-DYeY_1KP.js";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { logger } from "./logger-DKXLpcNj.js";
3
- import { resolveComma, toArray } from "./general-nv5tYplM.js";
4
- import { version } from "./package-r0-JZYQB.js";
2
+ import { resolveComma, toArray } from "./general-CPYs4M61.js";
3
+ import { logger } from "./logger-DYeY_1KP.js";
4
+ import { version } from "./package-CtZQ6FbS.js";
5
5
  import process from "node:process";
6
6
  import { dim } from "ansis";
7
7
  import Debug from "debug";
@@ -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-BClsYfT0.js");
23
+ const { migrate } = await import("./migrate-CB-PFTao.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.0",
3
+ "version": "0.11.1",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -79,9 +79,9 @@
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.3",
82
+ "@types/node": "^22.15.14",
83
83
  "@types/semver": "^7.7.0",
84
- "@unocss/eslint-plugin": "^66.1.0-beta.13",
84
+ "@unocss/eslint-plugin": "^66.1.0",
85
85
  "bumpp": "^10.1.0",
86
86
  "eslint": "^9.26.0",
87
87
  "lightningcss": "^1.29.3",
@@ -89,17 +89,17 @@
89
89
  "prettier": "^3.5.3",
90
90
  "publint": "^0.3.12",
91
91
  "tsup": "^8.4.0",
92
- "typedoc": "^0.28.3",
92
+ "typedoc": "^0.28.4",
93
93
  "typedoc-plugin-markdown": "^4.6.3",
94
94
  "typescript": "~5.8.3",
95
- "unocss": "^66.1.0-beta.13",
95
+ "unocss": "^66.1.0",
96
96
  "unplugin-lightningcss": "^0.3.3",
97
97
  "unplugin-unused": "^0.4.4",
98
- "vite": "^6.3.4",
98
+ "vite": "^6.3.5",
99
99
  "vitepress": "^1.6.3",
100
100
  "vitepress-plugin-group-icons": "^1.5.2",
101
101
  "vitepress-plugin-llms": "^1.1.3",
102
- "vitest": "^3.1.2",
102
+ "vitest": "^3.1.3",
103
103
  "vue": "^3.5.13"
104
104
  },
105
105
  "engines": {
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.11.0";
3
-
4
- //#endregion
5
- export { version };
File without changes