tsdown 0.11.9 → 0.11.11

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 "./index-B5B9KM9d.js";
1
+ import { UserConfig, UserConfigFn } from "./types-DnZA5gez.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 "./index-B5B9KM9d.js";
2
- import { defineConfig$1 as defineConfig } from "./config-Cyqx6Xup.js";
1
+ import { UserConfig, UserConfigFn } from "./types-DnZA5gez.js";
2
+ import { defineConfig$1 as defineConfig } from "./config-BMza8hkb.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 "./index-B5B9KM9d.js";
2
- import { defineConfig$1 as defineConfig } from "./config-Cyqx6Xup.js";
1
+ import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./types-DnZA5gez.js";
2
+ import { defineConfig$1 as defineConfig } from "./config-BMza8hkb.js";
3
3
  import "ansis";
4
4
  import { InternalModuleFormat } from "rolldown";
5
5
 
package/dist/index.js CHANGED
@@ -5,10 +5,10 @@ import path from "node:path";
5
5
  import process from "node:process";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
7
7
  import { blue, bold, dim, green, underline } from "ansis";
8
- import Debug from "debug";
9
8
  import { build as build$1 } from "rolldown";
10
9
  import { transformPlugin } from "rolldown/experimental";
11
10
  import { exec } from "tinyexec";
11
+ import Debug from "debug";
12
12
  import { glob } from "tinyglobby";
13
13
  import { readFile } from "node:fs/promises";
14
14
  import { createHooks } from "hookable";
@@ -292,6 +292,53 @@ function shortcuts(restart) {
292
292
  rl.on("line", onInput);
293
293
  }
294
294
 
295
+ //#endregion
296
+ //#region src/features/target.ts
297
+ function resolveTarget(target, pkg, name) {
298
+ if (target === false) return;
299
+ if (target == null) {
300
+ const pkgTarget = resolvePackageTarget(pkg);
301
+ if (pkgTarget) target = pkgTarget;
302
+ else return;
303
+ }
304
+ const targets = resolveComma(toArray(target));
305
+ if (targets.length) logger.info(prettyName(name), `target${targets.length > 1 ? "s" : ""}: ${generateColor(name)(targets.join(", "))}`);
306
+ return targets;
307
+ }
308
+ function resolvePackageTarget(pkg) {
309
+ const nodeVersion = pkg?.engines?.node;
310
+ if (!nodeVersion) return;
311
+ const nodeMinVersion = minVersion(nodeVersion);
312
+ if (!nodeMinVersion) return;
313
+ if (nodeMinVersion.version === "0.0.0") return;
314
+ return `node${nodeMinVersion.version}`;
315
+ }
316
+ let warned = false;
317
+ function RuntimeHelperCheckPlugin(targets) {
318
+ return {
319
+ name: "tsdown:runtime-helper-check",
320
+ resolveId: {
321
+ filter: { id: /^@oxc-project\/runtime/ },
322
+ async handler(id, ...args) {
323
+ const EXTERNAL = {
324
+ id,
325
+ external: true
326
+ };
327
+ if (warned) return EXTERNAL;
328
+ const resolved = await this.resolve(id, ...args);
329
+ if (!resolved) {
330
+ if (!warned) {
331
+ warned = true;
332
+ logger.warn(`The target environment (${targets.join(", ")}) requires runtime helpers from ${blue`@oxc-project/runtime`}. Please install it to ensure all necessary polyfills are included.\nFor more information, visit: https://tsdown.dev/options/target#runtime-helpers`);
333
+ }
334
+ return EXTERNAL;
335
+ }
336
+ return resolved;
337
+ }
338
+ }
339
+ };
340
+ }
341
+
295
342
  //#endregion
296
343
  //#region src/features/watch.ts
297
344
  const endsWithConfig = /[\\/](?:package\.json|tsdown\.config.*)$/;
@@ -308,7 +355,8 @@ async function watchBuild(options, configFiles, rebuild, restart) {
308
355
  ignored: [
309
356
  /[\\/]\.git[\\/]/,
310
357
  /[\\/]node_modules[\\/]/,
311
- options.outDir
358
+ options.outDir,
359
+ ...toArray(options.ignoreWatch)
312
360
  ]
313
361
  });
314
362
  watcher.on("all", (type, file) => {
@@ -348,28 +396,6 @@ async function toObjectEntry(entry, cwd) {
348
396
  }));
349
397
  }
350
398
 
351
- //#endregion
352
- //#region src/features/target.ts
353
- function resolveTarget(target, pkg, name) {
354
- if (target === false) return;
355
- if (target == null) {
356
- const pkgTarget = resolvePackageTarget(pkg);
357
- if (pkgTarget) target = pkgTarget;
358
- else return;
359
- }
360
- const targets = resolveComma(toArray(target));
361
- if (targets.length) logger.info(prettyName(name), `target${targets.length > 1 ? "s" : ""}: ${generateColor(name)(targets.join(", "))}`);
362
- return targets;
363
- }
364
- function resolvePackageTarget(pkg) {
365
- const nodeVersion = pkg?.engines?.node;
366
- if (!nodeVersion) return;
367
- const nodeMinVersion = minVersion(nodeVersion);
368
- if (!nodeMinVersion) return;
369
- if (nodeMinVersion.version === "0.0.0") return;
370
- return `node${nodeMinVersion.version}`;
371
- }
372
-
373
399
  //#endregion
374
400
  //#region src/features/tsconfig.ts
375
401
  function findTsconfig(cwd, name = "tsconfig.json") {
@@ -508,7 +534,7 @@ async function resolveOptions(options) {
508
534
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
509
535
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
510
536
  if (workspaceFiles) files.push(...workspaceFiles);
511
- return Promise.all(workspaceConfigs.map((config) => resolveConfig(config)));
537
+ return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
512
538
  }))).flat();
513
539
  debug("resolved configs %O", configs);
514
540
  return {
@@ -574,7 +600,7 @@ async function resolveWorkspace(config, options) {
574
600
  };
575
601
  }
576
602
  async function resolveConfig(userConfig) {
577
- 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(), name, workspace } = userConfig;
603
+ let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch = [], shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace } = userConfig;
578
604
  outDir = path.resolve(cwd, outDir);
579
605
  clean = resolveClean(clean, outDir, cwd);
580
606
  const pkg = await readPackageJson(cwd);
@@ -611,6 +637,7 @@ async function resolveConfig(userConfig) {
611
637
  report: report === true ? {} : report,
612
638
  unused,
613
639
  watch,
640
+ ignoreWatch,
614
641
  shims,
615
642
  skipNodeModulesBundle,
616
643
  publint: publint$1,
@@ -745,7 +772,7 @@ async function getBuildOptions(config, format, cjsDts, isMultiFormat) {
745
772
  include: /\.[cm]?[jt]sx?$/,
746
773
  exclude: /\.d\.[cm]?ts$/,
747
774
  transformOptions: { target }
748
- }));
775
+ }), RuntimeHelperCheckPlugin(target));
749
776
  plugins.push(ShebangPlugin(cwd, name, isMultiFormat));
750
777
  }
751
778
  if (report && !logger.silent) plugins.push(ReportPlugin(report, cwd, cjsDts, name, isMultiFormat));
@@ -1,5 +1,5 @@
1
1
  import { logger } from "./logger-BdIBA2vO.js";
2
- import { version } from "./package-BbnQTn6e.js";
2
+ import { version } from "./package-bNkOwuDn.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";
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.11.11";
3
+
4
+ //#endregion
5
+ export { version };
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./index-B5B9KM9d.js";
1
+ import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./types-DnZA5gez.js";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/run.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { logger, resolveComma, toArray } from "./logger-BdIBA2vO.js";
3
- import { version } from "./package-BbnQTn6e.js";
3
+ import { version } from "./package-bNkOwuDn.js";
4
4
  import module from "node:module";
5
5
  import process from "node:process";
6
6
  import { dim } from "ansis";
7
- import Debug from "debug";
8
7
  import { VERSION } from "rolldown";
8
+ import Debug from "debug";
9
9
  import { cac } from "cac";
10
10
 
11
11
  //#region src/cli.ts
@@ -14,7 +14,7 @@ cli.help().version(version);
14
14
  cli.command("[...files]", "Bundle files", {
15
15
  ignoreOptionDefaultValue: true,
16
16
  allowUnknownOptions: true
17
- }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [scope]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--silent", "Suppress non-error logs").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("-W, --workspace [dir]", "Enable workspace mode").option("-f, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").action(async (input, flags) => {
17
+ }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory").option("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--silent", "Suppress non-error logs").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("-W, --workspace [dir]", "Enable workspace mode").option("-f, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").action(async (input, flags) => {
18
18
  logger.setSilent(!!flags.silent);
19
19
  logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
20
20
  const { build: build$1 } = await import("./index.js");
@@ -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-CDIgKGak.js");
25
+ const { migrate } = await import("./migrate-BsizCuv-.js");
26
26
  await migrate(args);
27
27
  });
28
28
  async function runCLI() {
@@ -89,7 +89,7 @@ interface ReportOptions {
89
89
  declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: boolean, name?: string, isMultiFormat?: boolean): Plugin;
90
90
 
91
91
  //#endregion
92
- //#region src/options/index.d.ts
92
+ //#region src/options/types.d.ts
93
93
  type Sourcemap = boolean | "inline" | "hidden";
94
94
  type Format = Exclude<ModuleFormat, "experimental-app">;
95
95
  type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
@@ -204,6 +204,7 @@ interface Options$3 {
204
204
  config?: boolean | string;
205
205
  /** @default false */
206
206
  watch?: boolean | string | string[];
207
+ ignoreWatch?: string | string[];
207
208
  /**
208
209
  * You can specify command to be executed after a successful build, specially useful for Watch mode
209
210
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.11.9",
3
+ "version": "0.11.11",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -65,12 +65,12 @@
65
65
  "ansis": "^4.0.0",
66
66
  "cac": "^6.7.14",
67
67
  "chokidar": "^4.0.3",
68
- "debug": "^4.4.0",
69
- "diff": "^8.0.0",
68
+ "debug": "^4.4.1",
69
+ "diff": "^8.0.1",
70
70
  "empathic": "^1.1.0",
71
71
  "hookable": "^5.5.3",
72
72
  "rolldown": "1.0.0-beta.8-commit.d95f99e",
73
- "rolldown-plugin-dts": "^0.12.1",
73
+ "rolldown-plugin-dts": "^0.13.1",
74
74
  "semver": "^7.7.2",
75
75
  "tinyexec": "^1.0.1",
76
76
  "tinyglobby": "^0.2.13",
@@ -82,28 +82,28 @@
82
82
  "@sxzz/prettier-config": "^2.2.1",
83
83
  "@sxzz/test-utils": "^0.5.6",
84
84
  "@types/debug": "^4.1.12",
85
- "@types/node": "^22.15.17",
85
+ "@types/node": "^22.15.18",
86
86
  "@types/semver": "^7.7.0",
87
- "@unocss/eslint-plugin": "^66.1.1",
88
- "bumpp": "^10.1.0",
89
- "eslint": "^9.26.0",
90
- "lightningcss": "^1.30.0",
87
+ "@unocss/eslint-plugin": "^66.1.2",
88
+ "bumpp": "^10.1.1",
89
+ "eslint": "^9.27.0",
90
+ "lightningcss": "^1.30.1",
91
91
  "pkg-types": "^2.1.0",
92
92
  "prettier": "^3.5.3",
93
93
  "publint": "^0.3.12",
94
- "tsup": "^8.4.0",
94
+ "tsup": "^8.5.0",
95
95
  "typedoc": "^0.28.4",
96
96
  "typedoc-plugin-markdown": "^4.6.3",
97
97
  "typescript": "~5.8.3",
98
- "unocss": "^66.1.1",
98
+ "unocss": "^66.1.2",
99
99
  "unplugin-lightningcss": "^0.4.0",
100
100
  "unplugin-unused": "^0.5.0",
101
101
  "vite": "^6.3.5",
102
102
  "vitepress": "^1.6.3",
103
- "vitepress-plugin-group-icons": "^1.5.2",
103
+ "vitepress-plugin-group-icons": "^1.5.5",
104
104
  "vitepress-plugin-llms": "^1.1.4",
105
105
  "vitest": "^3.1.3",
106
- "vue": "^3.5.13"
106
+ "vue": "^3.5.14"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=18.0.0"
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.11.9";
3
-
4
- //#endregion
5
- export { version };