tsdown 0.11.9 → 0.11.10

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/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { defineConfig } from "./config-yiJy1jd0.js";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-G7Z0rtO5.js";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-AcF8M16F.js";
3
3
  import { debounce, generateColor, logger, prettyName, resolveComma, slash, toArray } from "./logger-BdIBA2vO.js";
4
4
  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";
@@ -19,7 +19,7 @@ import { up as up$1 } from "empathic/find";
19
19
  import { loadConfig } from "unconfig";
20
20
 
21
21
  //#region src/features/clean.ts
22
- const debug$3 = Debug("tsdown:clean");
22
+ const debug$4 = debug("tsdown:clean");
23
23
  const RE_LAST_SLASH = /[/\\]$/;
24
24
  async function cleanOutDir(configs) {
25
25
  const removes = new Set();
@@ -39,10 +39,10 @@ async function cleanOutDir(configs) {
39
39
  if (!removes.size) return;
40
40
  logger.info(`Cleaning ${removes.size} files`);
41
41
  await Promise.all([...removes].map(async (file) => {
42
- debug$3("Removing", file);
42
+ debug$4("Removing", file);
43
43
  await fsRemove(file);
44
44
  }));
45
- debug$3("Removed %d files", removes.size);
45
+ debug$4("Removed %d files", removes.size);
46
46
  }
47
47
  function resolveClean(clean, outDir, cwd) {
48
48
  if (clean === true) clean = [slash(outDir)];
@@ -136,11 +136,11 @@ async function LightningCSSPlugin(options) {
136
136
 
137
137
  //#endregion
138
138
  //#region src/utils/package.ts
139
- const debug$2 = Debug("tsdown:package");
139
+ const debug$3 = debug("tsdown:package");
140
140
  async function readPackageJson(dir) {
141
141
  const packageJsonPath = up({ cwd: dir });
142
142
  if (!packageJsonPath) return;
143
- debug$2("Reading package.json:", packageJsonPath);
143
+ debug$3("Reading package.json:", packageJsonPath);
144
144
  const contents = await readFile(packageJsonPath, "utf8");
145
145
  return JSON.parse(contents);
146
146
  }
@@ -198,7 +198,7 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
198
198
 
199
199
  //#endregion
200
200
  //#region src/features/publint.ts
201
- const debug$1 = Debug("tsdown:publint");
201
+ const debug$2 = debug("tsdown:publint");
202
202
  async function publint(options) {
203
203
  if (!options.publint) return;
204
204
  if (!options.pkg) {
@@ -206,11 +206,11 @@ async function publint(options) {
206
206
  return;
207
207
  }
208
208
  const t = performance.now();
209
- debug$1("Running publint");
209
+ debug$2("Running publint");
210
210
  const { publint: publint$1 } = await import("publint");
211
211
  const { formatMessage } = await import("publint/utils");
212
212
  const { messages } = await publint$1(options.publint === true ? {} : options.publint);
213
- debug$1("Found %d issues", messages.length);
213
+ debug$2("Found %d issues", messages.length);
214
214
  if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
215
215
  let hasError = false;
216
216
  for (const message of messages) {
@@ -224,7 +224,7 @@ async function publint(options) {
224
224
  logger[logType](formattedMessage);
225
225
  }
226
226
  if (hasError) {
227
- debug$1("Found errors, setting exit code to 1");
227
+ debug$2("Found errors, setting exit code to 1");
228
228
  process.exitCode = 1;
229
229
  }
230
230
  }
@@ -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.*)$/;
@@ -348,28 +395,6 @@ async function toObjectEntry(entry, cwd) {
348
395
  }));
349
396
  }
350
397
 
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
398
  //#endregion
374
399
  //#region src/features/tsconfig.ts
375
400
  function findTsconfig(cwd, name = "tsconfig.json") {
@@ -488,7 +513,7 @@ async function loadConfigFile(options, workspace) {
488
513
 
489
514
  //#endregion
490
515
  //#region src/options/index.ts
491
- const debug = Debug("tsdown:options");
516
+ const debug$1 = debug("tsdown:options");
492
517
  const DEFAULT_EXCLUDE_WORKSPACE = [
493
518
  "**/node_modules/**",
494
519
  "**/dist/**",
@@ -497,20 +522,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
497
522
  ];
498
523
  async function resolveOptions(options) {
499
524
  const files = [];
500
- debug("options %O", options);
501
- debug("loading config file: %s", options.config);
525
+ debug$1("options %O", options);
526
+ debug$1("loading config file: %s", options.config);
502
527
  const { configs: rootConfigs, file } = await loadConfigFile(options);
503
528
  if (file) {
504
529
  files.push(file);
505
- debug("loaded root config file %s", file);
506
- debug("root configs %o", rootConfigs);
507
- } else debug("no root config file found");
530
+ debug$1("loaded root config file %s", file);
531
+ debug$1("root configs %o", rootConfigs);
532
+ } else debug$1("no root config file found");
508
533
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
509
534
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
510
535
  if (workspaceFiles) files.push(...workspaceFiles);
511
- return Promise.all(workspaceConfigs.map((config) => resolveConfig(config)));
536
+ return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry?.length).map((config) => resolveConfig(config)));
512
537
  }))).flat();
513
- debug("resolved configs %O", configs);
538
+ debug$1("resolved configs %O", configs);
514
539
  return {
515
540
  configs,
516
541
  files
@@ -552,16 +577,16 @@ async function resolveWorkspace(config, options) {
552
577
  }
553
578
  const files = [];
554
579
  const configs = (await Promise.all(packages.map(async (cwd) => {
555
- debug("loading workspace config %s", cwd);
580
+ debug$1("loading workspace config %s", cwd);
556
581
  const { configs: configs$1, file } = await loadConfigFile({
557
582
  ...options,
558
583
  config: workspaceConfig,
559
584
  cwd
560
585
  }, cwd);
561
586
  if (file) {
562
- debug("loaded workspace config file %s", file);
587
+ debug$1("loaded workspace config file %s", file);
563
588
  files.push(file);
564
- } else debug("no workspace config file found in %s", cwd);
589
+ } else debug$1("no workspace config file found in %s", cwd);
565
590
  return configs$1.map((config$1) => ({
566
591
  ...normalized,
567
592
  cwd,
@@ -745,7 +770,7 @@ async function getBuildOptions(config, format, cjsDts, isMultiFormat) {
745
770
  include: /\.[cm]?[jt]sx?$/,
746
771
  exclude: /\.d\.[cm]?ts$/,
747
772
  transformOptions: { target }
748
- }));
773
+ }), RuntimeHelperCheckPlugin(target));
749
774
  plugins.push(ShebangPlugin(cwd, name, isMultiFormat));
750
775
  }
751
776
  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-DNOe3jsX.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.10";
3
+
4
+ //#endregion
5
+ export { version };
@@ -1,7 +1,7 @@
1
1
  import { logger, noop, prettyFormat, prettyName, toArray } from "./logger-BdIBA2vO.js";
2
2
  import path, { dirname, normalize, sep } from "node:path";
3
3
  import { bold, dim, green, underline } from "ansis";
4
- import Debug from "debug";
4
+ import debug from "debug";
5
5
  import { access, chmod, cp, rm, stat } from "node:fs/promises";
6
6
  import { Buffer } from "node:buffer";
7
7
  import { promisify } from "node:util";
@@ -47,7 +47,7 @@ function lowestCommonAncestor(...filepaths) {
47
47
 
48
48
  //#endregion
49
49
  //#region src/features/external.ts
50
- const debug$1 = Debug("tsdown:external");
50
+ const debug$2 = debug("tsdown:external");
51
51
  function ExternalPlugin(options) {
52
52
  const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
53
53
  return {
@@ -70,7 +70,7 @@ function ExternalPlugin(options) {
70
70
  }
71
71
  if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
72
72
  if (shouldExternal) {
73
- debug$1("External dependency:", id);
73
+ debug$2("External dependency:", id);
74
74
  return {
75
75
  id,
76
76
  external: shouldExternal
@@ -119,7 +119,7 @@ function formatBytes(bytes) {
119
119
 
120
120
  //#endregion
121
121
  //#region src/features/report.ts
122
- const debug = Debug("tsdown:report");
122
+ const debug$1 = debug("tsdown:report");
123
123
  const brotliCompressAsync = promisify(brotliCompress);
124
124
  const gzipAsync = promisify(gzip);
125
125
  const RE_DTS = /\.d\.[cm]?ts$/;
@@ -161,19 +161,19 @@ function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
161
161
  };
162
162
  }
163
163
  async function calcSize(options, chunk) {
164
- debug(`Calculating size for`, chunk.fileName);
164
+ debug$1(`Calculating size for`, chunk.fileName);
165
165
  const content = chunk.type === "chunk" ? chunk.code : chunk.source;
166
166
  const raw = Buffer.byteLength(content, "utf8");
167
- debug("[size]", chunk.fileName, raw);
167
+ debug$1("[size]", chunk.fileName, raw);
168
168
  let gzip$1 = Infinity;
169
169
  let brotli = Infinity;
170
- if (raw > (options.maxCompressSize ?? 1e6)) debug(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
170
+ if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
171
171
  else {
172
172
  gzip$1 = (await gzipAsync(content)).length;
173
- debug("[gzip]", chunk.fileName, gzip$1);
173
+ debug$1("[gzip]", chunk.fileName, gzip$1);
174
174
  if (options.brotli) {
175
175
  brotli = (await brotliCompressAsync(content)).length;
176
- debug("[brotli]", chunk.fileName, brotli);
176
+ debug$1("[brotli]", chunk.fileName, brotli);
177
177
  }
178
178
  }
179
179
  return {
package/dist/plugins.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-G7Z0rtO5.js";
1
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-AcF8M16F.js";
2
2
  import "./logger-BdIBA2vO.js";
3
3
 
4
4
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
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-DNOe3jsX.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("--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-Bt-9GxhE.js");
26
26
  await migrate(args);
27
27
  });
28
28
  async function runCLI() {
@@ -31,10 +31,10 @@ async function runCLI() {
31
31
  let namespace;
32
32
  if (cli.options.debug === true) namespace = "tsdown:*";
33
33
  else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
34
- const enabled = Debug.disable();
34
+ const enabled = debug.disable();
35
35
  if (enabled) namespace += `,${enabled}`;
36
- Debug.enable(namespace);
37
- Debug("tsdown:debug")("Debugging enabled", namespace);
36
+ debug.enable(namespace);
37
+ debug("tsdown:debug")("Debugging enabled", namespace);
38
38
  }
39
39
  try {
40
40
  await cli.runMatchedCommand();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.11.9",
3
+ "version": "0.11.10",
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 };