tsdown 0.11.10 → 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
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from "./config-yiJy1jd0.js";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-AcF8M16F.js";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-G7Z0rtO5.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";
@@ -8,7 +8,7 @@ import { blue, bold, dim, green, underline } from "ansis";
8
8
  import { build as build$1 } from "rolldown";
9
9
  import { transformPlugin } from "rolldown/experimental";
10
10
  import { exec } from "tinyexec";
11
- import debug from "debug";
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$4 = debug("tsdown:clean");
22
+ const debug$3 = 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$4("Removing", file);
42
+ debug$3("Removing", file);
43
43
  await fsRemove(file);
44
44
  }));
45
- debug$4("Removed %d files", removes.size);
45
+ debug$3("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$3 = debug("tsdown:package");
139
+ const debug$2 = Debug("tsdown:package");
140
140
  async function readPackageJson(dir) {
141
141
  const packageJsonPath = up({ cwd: dir });
142
142
  if (!packageJsonPath) return;
143
- debug$3("Reading package.json:", packageJsonPath);
143
+ debug$2("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$2 = debug("tsdown:publint");
201
+ const debug$1 = 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$2("Running publint");
209
+ debug$1("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$2("Found %d issues", messages.length);
213
+ debug$1("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$2("Found errors, setting exit code to 1");
227
+ debug$1("Found errors, setting exit code to 1");
228
228
  process.exitCode = 1;
229
229
  }
230
230
  }
@@ -355,7 +355,8 @@ async function watchBuild(options, configFiles, rebuild, restart) {
355
355
  ignored: [
356
356
  /[\\/]\.git[\\/]/,
357
357
  /[\\/]node_modules[\\/]/,
358
- options.outDir
358
+ options.outDir,
359
+ ...toArray(options.ignoreWatch)
359
360
  ]
360
361
  });
361
362
  watcher.on("all", (type, file) => {
@@ -513,7 +514,7 @@ async function loadConfigFile(options, workspace) {
513
514
 
514
515
  //#endregion
515
516
  //#region src/options/index.ts
516
- const debug$1 = debug("tsdown:options");
517
+ const debug = Debug("tsdown:options");
517
518
  const DEFAULT_EXCLUDE_WORKSPACE = [
518
519
  "**/node_modules/**",
519
520
  "**/dist/**",
@@ -522,20 +523,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
522
523
  ];
523
524
  async function resolveOptions(options) {
524
525
  const files = [];
525
- debug$1("options %O", options);
526
- debug$1("loading config file: %s", options.config);
526
+ debug("options %O", options);
527
+ debug("loading config file: %s", options.config);
527
528
  const { configs: rootConfigs, file } = await loadConfigFile(options);
528
529
  if (file) {
529
530
  files.push(file);
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");
531
+ debug("loaded root config file %s", file);
532
+ debug("root configs %o", rootConfigs);
533
+ } else debug("no root config file found");
533
534
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
534
535
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
535
536
  if (workspaceFiles) files.push(...workspaceFiles);
536
- return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry?.length).map((config) => resolveConfig(config)));
537
+ return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
537
538
  }))).flat();
538
- debug$1("resolved configs %O", configs);
539
+ debug("resolved configs %O", configs);
539
540
  return {
540
541
  configs,
541
542
  files
@@ -577,16 +578,16 @@ async function resolveWorkspace(config, options) {
577
578
  }
578
579
  const files = [];
579
580
  const configs = (await Promise.all(packages.map(async (cwd) => {
580
- debug$1("loading workspace config %s", cwd);
581
+ debug("loading workspace config %s", cwd);
581
582
  const { configs: configs$1, file } = await loadConfigFile({
582
583
  ...options,
583
584
  config: workspaceConfig,
584
585
  cwd
585
586
  }, cwd);
586
587
  if (file) {
587
- debug$1("loaded workspace config file %s", file);
588
+ debug("loaded workspace config file %s", file);
588
589
  files.push(file);
589
- } else debug$1("no workspace config file found in %s", cwd);
590
+ } else debug("no workspace config file found in %s", cwd);
590
591
  return configs$1.map((config$1) => ({
591
592
  ...normalized,
592
593
  cwd,
@@ -599,7 +600,7 @@ async function resolveWorkspace(config, options) {
599
600
  };
600
601
  }
601
602
  async function resolveConfig(userConfig) {
602
- 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;
603
604
  outDir = path.resolve(cwd, outDir);
604
605
  clean = resolveClean(clean, outDir, cwd);
605
606
  const pkg = await readPackageJson(cwd);
@@ -636,6 +637,7 @@ async function resolveConfig(userConfig) {
636
637
  report: report === true ? {} : report,
637
638
  unused,
638
639
  watch,
640
+ ignoreWatch,
639
641
  shims,
640
642
  skipNodeModulesBundle,
641
643
  publint: publint$1,
@@ -1,5 +1,5 @@
1
1
  import { logger } from "./logger-BdIBA2vO.js";
2
- import { version } from "./package-DNOe3jsX.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 };
@@ -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$2 = debug("tsdown:external");
50
+ const debug$1 = 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$2("External dependency:", id);
73
+ debug$1("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$1 = debug("tsdown:report");
122
+ const debug = 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$1(`Calculating size for`, chunk.fileName);
164
+ debug(`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$1("[size]", chunk.fileName, raw);
167
+ debug("[size]", chunk.fileName, raw);
168
168
  let gzip$1 = Infinity;
169
169
  let brotli = Infinity;
170
- if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
170
+ if (raw > (options.maxCompressSize ?? 1e6)) debug(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
171
171
  else {
172
172
  gzip$1 = (await gzipAsync(content)).length;
173
- debug$1("[gzip]", chunk.fileName, gzip$1);
173
+ debug("[gzip]", chunk.fileName, gzip$1);
174
174
  if (options.brotli) {
175
175
  brotli = (await brotliCompressAsync(content)).length;
176
- debug$1("[brotli]", chunk.fileName, brotli);
176
+ debug("[brotli]", chunk.fileName, brotli);
177
177
  }
178
178
  }
179
179
  return {
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/plugins.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-AcF8M16F.js";
1
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-G7Z0rtO5.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-DNOe3jsX.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
7
  import { VERSION } from "rolldown";
8
- import debug from "debug";
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 [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) => {
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-Bt-9GxhE.js");
25
+ const { migrate } = await import("./migrate-BsizCuv-.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();
@@ -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.10",
3
+ "version": "0.11.11",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.11.10";
3
-
4
- //#endregion
5
- export { version };