tsdown 0.12.4 → 0.12.5

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.
@@ -27,7 +27,6 @@ declare const logger: Logger;
27
27
  //#region src/features/hooks.d.ts
28
28
  interface BuildContext {
29
29
  options: ResolvedOptions;
30
- pkg?: PackageJson;
31
30
  hooks: Hookable<TsdownHooks>;
32
31
  }
33
32
  interface RolldownContext {
@@ -271,7 +270,7 @@ interface Options$3 {
271
270
  /**
272
271
  * You can specify command to be executed after a successful build, specially useful for Watch mode
273
272
  */
274
- onSuccess?: string | ((config: ResolvedOptions) => void | Promise<void>);
273
+ onSuccess?: string | ((config: ResolvedOptions, signal: AbortSignal) => void | Promise<void>);
275
274
  /**
276
275
  * Skip bundling `node_modules`.
277
276
  * @default false
@@ -395,4 +394,4 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
395
394
  */
396
395
  declare function defineConfig(options: UserConfig | UserConfigFn): UserConfig | UserConfigFn;
397
396
  //#endregion
398
- export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build$1 as build, buildSingle, defineConfig as defineConfig$1, logger, pkgRoot };
397
+ export { BuildContext, Options$3 as Options, ReportPlugin, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build$1 as build, buildSingle, defineConfig, logger, pkgRoot };
package/dist/config.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { UserConfig, UserConfigFn, defineConfig$1 as defineConfig } from "./config-DcChLYA_.js";
1
+ import { UserConfig, UserConfigFn, defineConfig } from "./config-RMenra1a.js";
2
2
  export { UserConfig, UserConfigFn, defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig$1 as defineConfig, logger, pkgRoot } from "./config-DcChLYA_.js";
1
+ import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot } from "./config-RMenra1a.js";
2
2
  export { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { defineConfig } from "./config-yiJy1jd0.js";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-BK9K-20W.js";
3
- import { debounce, generateColor, logger$1 as logger, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-CS4H_tpu.js";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-BgxE5Awo.js";
3
+ import { debounce, generateColor, logger, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-BMB8Jggq.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
8
  import { build as build$1 } from "rolldown";
9
9
  import { exec } from "tinyexec";
10
- import debug from "debug";
10
+ import Debug from "debug";
11
11
  import { glob } from "tinyglobby";
12
12
  import { readFile, writeFile } from "node:fs/promises";
13
13
  import { RE_DTS } from "rolldown-plugin-dts";
@@ -19,10 +19,10 @@ 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
- const removes = new Set();
25
+ const removes = /* @__PURE__ */ new Set();
26
26
  for (const config of configs) {
27
27
  if (!config.clean.length) continue;
28
28
  const files = await glob(config.clean, {
@@ -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)];
@@ -93,7 +93,7 @@ async function generateExports(pkg, outDir, chunks, { devExports, all, customExp
93
93
  const pkgRoot$1 = path.dirname(pkgJsonPath);
94
94
  const outDirRelative = slash(path.relative(pkgRoot$1, outDir));
95
95
  let main, module, cjsTypes, esmTypes;
96
- const exportsMap = new Map();
96
+ const exportsMap = /* @__PURE__ */ new Map();
97
97
  for (const [format, chunksByFormat] of Object.entries(chunks)) {
98
98
  if (format !== "es" && format !== "cjs") continue;
99
99
  const onlyOneEntry = chunksByFormat.filter((chunk) => chunk.type === "chunk" && chunk.isEntry && !RE_DTS.test(chunk.fileName)).length === 1;
@@ -174,13 +174,12 @@ function exportMeta(exports, all) {
174
174
 
175
175
  //#endregion
176
176
  //#region src/features/hooks.ts
177
- async function createHooks$1(options, pkg) {
177
+ async function createHooks$1(options) {
178
178
  const hooks = createHooks();
179
179
  if (typeof options.hooks === "object") hooks.addHooks(options.hooks);
180
180
  else if (typeof options.hooks === "function") await options.hooks(hooks);
181
181
  const context = {
182
182
  options,
183
- pkg,
184
183
  hooks
185
184
  };
186
185
  return {
@@ -242,11 +241,11 @@ async function LightningCSSPlugin(options) {
242
241
 
243
242
  //#endregion
244
243
  //#region src/utils/package.ts
245
- const debug$3 = debug("tsdown:package");
244
+ const debug$2 = Debug("tsdown:package");
246
245
  async function readPackageJson(dir) {
247
246
  const packageJsonPath = up({ cwd: dir });
248
247
  if (!packageJsonPath) return;
249
- debug$3("Reading package.json:", packageJsonPath);
248
+ debug$2("Reading package.json:", packageJsonPath);
250
249
  const contents = await readFile(packageJsonPath, "utf8");
251
250
  return {
252
251
  ...JSON.parse(contents),
@@ -307,7 +306,7 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
307
306
 
308
307
  //#endregion
309
308
  //#region src/features/publint.ts
310
- const debug$2 = debug("tsdown:publint");
309
+ const debug$1 = Debug("tsdown:publint");
311
310
  async function publint(options) {
312
311
  if (!options.publint) return;
313
312
  if (!options.pkg) {
@@ -315,11 +314,11 @@ async function publint(options) {
315
314
  return;
316
315
  }
317
316
  const t = performance.now();
318
- debug$2("Running publint");
317
+ debug$1("Running publint");
319
318
  const { publint: publint$1 } = await import("publint");
320
319
  const { formatMessage } = await import("publint/utils");
321
320
  const { messages } = await publint$1(options.publint === true ? {} : options.publint);
322
- debug$2("Found %d issues", messages.length);
321
+ debug$1("Found %d issues", messages.length);
323
322
  if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
324
323
  let hasError = false;
325
324
  for (const message of messages) {
@@ -333,7 +332,7 @@ async function publint(options) {
333
332
  logger[logType](formattedMessage);
334
333
  }
335
334
  if (hasError) {
336
- debug$2("Found errors, setting exit code to 1");
335
+ debug$1("Found errors, setting exit code to 1");
337
336
  process.exitCode = 1;
338
337
  }
339
338
  }
@@ -381,7 +380,7 @@ function shortcuts(restart) {
381
380
  }
382
381
  ];
383
382
  if (input === "h") {
384
- const loggedKeys = new Set();
383
+ const loggedKeys = /* @__PURE__ */ new Set();
385
384
  logger.info(" Shortcuts");
386
385
  for (const shortcut$1 of SHORTCUTS) {
387
386
  if (loggedKeys.has(shortcut$1.key)) continue;
@@ -624,7 +623,7 @@ async function loadConfigFile(options, workspace) {
624
623
 
625
624
  //#endregion
626
625
  //#region src/options/index.ts
627
- const debug$1 = debug("tsdown:options");
626
+ const debug = Debug("tsdown:options");
628
627
  const DEFAULT_EXCLUDE_WORKSPACE = [
629
628
  "**/node_modules/**",
630
629
  "**/dist/**",
@@ -633,20 +632,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
633
632
  ];
634
633
  async function resolveOptions(options) {
635
634
  const files = [];
636
- debug$1("options %O", options);
637
- debug$1("loading config file: %s", options.config);
635
+ debug("options %O", options);
636
+ debug("loading config file: %s", options.config);
638
637
  const { configs: rootConfigs, file } = await loadConfigFile(options);
639
638
  if (file) {
640
639
  files.push(file);
641
- debug$1("loaded root config file %s", file);
642
- debug$1("root configs %o", rootConfigs);
643
- } else debug$1("no root config file found");
640
+ debug("loaded root config file %s", file);
641
+ debug("root configs %o", rootConfigs);
642
+ } else debug("no root config file found");
644
643
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
645
644
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
646
645
  if (workspaceFiles) files.push(...workspaceFiles);
647
646
  return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
648
647
  }))).flat();
649
- debug$1("resolved configs %O", configs);
648
+ debug("resolved configs %O", configs);
650
649
  return {
651
650
  configs,
652
651
  files
@@ -688,16 +687,16 @@ async function resolveWorkspace(config, options) {
688
687
  }
689
688
  const files = [];
690
689
  const configs = (await Promise.all(packages.map(async (cwd) => {
691
- debug$1("loading workspace config %s", cwd);
690
+ debug("loading workspace config %s", cwd);
692
691
  const { configs: configs$1, file } = await loadConfigFile({
693
692
  ...options,
694
693
  config: workspaceConfig,
695
694
  cwd
696
695
  }, cwd);
697
696
  if (file) {
698
- debug$1("loaded workspace config file %s", file);
697
+ debug("loaded workspace config file %s", file);
699
698
  files.push(file);
700
- } else debug$1("no workspace config file found in %s", cwd);
699
+ } else debug("no workspace config file found in %s", cwd);
701
700
  return configs$1.map((config$1) => ({
702
701
  ...normalized,
703
702
  cwd,
@@ -816,14 +815,14 @@ const pkgRoot = path.resolve(dirname$1, "..");
816
815
  */
817
816
  async function buildSingle(config, clean) {
818
817
  const { format: formats, dts, watch, onSuccess } = config;
819
- let onSuccessCleanup;
818
+ let ab;
820
819
  const { hooks, context } = await createHooks$1(config);
821
820
  await rebuild(true);
822
821
  if (watch) return () => rebuild();
823
822
  async function rebuild(first) {
824
823
  const startTime = performance.now();
825
824
  await hooks.callHook("build:prepare", context);
826
- onSuccessCleanup?.();
825
+ ab?.abort();
827
826
  await clean();
828
827
  let hasErrors = false;
829
828
  const isMultiFormat = formats.length > 1;
@@ -856,16 +855,19 @@ async function buildSingle(config, clean) {
856
855
  await copy(config);
857
856
  await hooks.callHook("build:done", context);
858
857
  logger.success(prettyName(config.name), `${first ? "Build" : "Rebuild"} complete in ${green(`${Math.round(performance.now() - startTime)}ms`)}`);
858
+ ab = new AbortController();
859
859
  if (typeof onSuccess === "string") {
860
- const p = exec(onSuccess, [], { nodeOptions: {
861
- shell: true,
862
- stdio: "inherit"
863
- } });
860
+ const p = exec(onSuccess, [], {
861
+ nodeOptions: {
862
+ shell: true,
863
+ stdio: "inherit"
864
+ },
865
+ signal: ab.signal
866
+ });
864
867
  p.then(({ exitCode }) => {
865
868
  if (exitCode) process.exitCode = exitCode;
866
869
  });
867
- onSuccessCleanup = () => p.kill("SIGTERM");
868
- } else await onSuccess?.(config);
870
+ } else await onSuccess?.(config, ab.signal);
869
871
  }
870
872
  }
871
873
  async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
@@ -71,7 +71,7 @@ function prettyFormat(format) {
71
71
  }
72
72
  return formatColor(`[${formatText}]`);
73
73
  }
74
- const colors = new Map();
74
+ const colors = /* @__PURE__ */ new Map();
75
75
  function generateColor(name = "default") {
76
76
  if (colors.has(name)) return colors.get(name);
77
77
  let color;
@@ -117,4 +117,4 @@ function hue2rgb(p, q, t) {
117
117
  }
118
118
 
119
119
  //#endregion
120
- export { debounce, generateColor, logger as logger$1, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray };
120
+ export { debounce, generateColor, logger, noop, prettyFormat, prettyName, resolveComma, resolveRegex, slash, toArray };
@@ -1,5 +1,5 @@
1
- import { logger$1 as logger } from "./logger-CS4H_tpu.js";
2
- import { version } from "./package-DHv574be.js";
1
+ import { logger } from "./logger-BMB8Jggq.js";
2
+ import { version } from "./package-BQ8czGAY.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.12.5";
3
+
4
+ //#endregion
5
+ export { version };
@@ -1,7 +1,8 @@
1
- import { logger$1 as logger, noop, prettyFormat, prettyName, toArray } from "./logger-CS4H_tpu.js";
1
+ import { logger, noop, prettyFormat, prettyName, toArray } from "./logger-BMB8Jggq.js";
2
+ import { isBuiltin } from "node:module";
2
3
  import path, { dirname, normalize, sep } from "node:path";
3
4
  import { bold, dim, green, underline } from "ansis";
4
- import debug from "debug";
5
+ import Debug from "debug";
5
6
  import { access, chmod, cp, rm, stat } from "node:fs/promises";
6
7
  import { RE_DTS } from "rolldown-plugin-dts";
7
8
  import { Buffer } from "node:buffer";
@@ -48,7 +49,7 @@ function lowestCommonAncestor(...filepaths) {
48
49
 
49
50
  //#endregion
50
51
  //#region src/features/external.ts
51
- const debug$2 = debug("tsdown:external");
52
+ const debug$1 = Debug("tsdown:external");
52
53
  function ExternalPlugin(options) {
53
54
  const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
54
55
  return {
@@ -71,10 +72,11 @@ function ExternalPlugin(options) {
71
72
  }
72
73
  if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
73
74
  if (shouldExternal) {
74
- debug$2("External dependency:", id);
75
+ debug$1("External dependency:", id);
75
76
  return {
76
77
  id,
77
- external: shouldExternal
78
+ external: shouldExternal,
79
+ moduleSideEffects: id.startsWith("node:") || isBuiltin(id) ? false : void 0
78
80
  };
79
81
  }
80
82
  }
@@ -120,7 +122,7 @@ function formatBytes(bytes) {
120
122
 
121
123
  //#endregion
122
124
  //#region src/features/report.ts
123
- const debug$1 = debug("tsdown:report");
125
+ const debug = Debug("tsdown:report");
124
126
  const brotliCompressAsync = promisify(brotliCompress);
125
127
  const gzipAsync = promisify(gzip);
126
128
  function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
@@ -161,19 +163,19 @@ function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
161
163
  };
162
164
  }
163
165
  async function calcSize(options, chunk) {
164
- debug$1(`Calculating size for`, chunk.fileName);
166
+ debug(`Calculating size for`, chunk.fileName);
165
167
  const content = chunk.type === "chunk" ? chunk.code : chunk.source;
166
168
  const raw = Buffer.byteLength(content, "utf8");
167
- debug$1("[size]", chunk.fileName, raw);
169
+ debug("[size]", chunk.fileName, raw);
168
170
  let gzip$1 = Infinity;
169
171
  let brotli = Infinity;
170
- if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
172
+ if (raw > (options.maxCompressSize ?? 1e6)) debug(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
171
173
  else {
172
174
  gzip$1 = (await gzipAsync(content)).length;
173
- debug$1("[gzip]", chunk.fileName, gzip$1);
175
+ debug("[gzip]", chunk.fileName, gzip$1);
174
176
  if (options.brotli) {
175
177
  brotli = (await brotliCompressAsync(content)).length;
176
- debug$1("[brotli]", chunk.fileName, brotli);
178
+ debug("[brotli]", chunk.fileName, brotli);
177
179
  }
178
180
  }
179
181
  return {
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./config-DcChLYA_.js";
1
+ import { ReportPlugin, ResolvedOptions } from "./config-RMenra1a.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-BK9K-20W.js";
2
- import "./logger-CS4H_tpu.js";
1
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-BgxE5Awo.js";
2
+ import "./logger-BMB8Jggq.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
- import { logger$1 as logger, resolveComma, toArray } from "./logger-CS4H_tpu.js";
3
- import { version } from "./package-DHv574be.js";
2
+ import { logger, resolveComma, toArray } from "./logger-BMB8Jggq.js";
3
+ import { version } from "./package-BQ8czGAY.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
@@ -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-BD_TCCI8.js");
25
+ const { migrate } = await import("./migrate-nO5Up2ZS.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.12.4",
3
+ "version": "0.12.5",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -63,15 +63,15 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "ansis": "^4.0.0",
66
+ "ansis": "^4.1.0",
67
67
  "cac": "^6.7.14",
68
68
  "chokidar": "^4.0.3",
69
69
  "debug": "^4.4.1",
70
70
  "diff": "^8.0.2",
71
71
  "empathic": "^1.1.0",
72
72
  "hookable": "^5.5.3",
73
- "rolldown": "1.0.0-beta.9-commit.273d50e",
74
- "rolldown-plugin-dts": "^0.13.5",
73
+ "rolldown": "1.0.0-beta.10-commit.87188ed",
74
+ "rolldown-plugin-dts": "^0.13.6",
75
75
  "semver": "^7.7.2",
76
76
  "tinyexec": "^1.0.1",
77
77
  "tinyglobby": "^0.2.14",
@@ -83,9 +83,10 @@
83
83
  "@sxzz/prettier-config": "^2.2.1",
84
84
  "@sxzz/test-utils": "^0.5.6",
85
85
  "@types/debug": "^4.1.12",
86
- "@types/node": "^22.15.21",
86
+ "@types/node": "^22.15.27",
87
87
  "@types/semver": "^7.7.0",
88
88
  "@unocss/eslint-plugin": "^66.1.2",
89
+ "@vueuse/core": "^13.3.0",
89
90
  "bumpp": "^10.1.1",
90
91
  "eslint": "^9.27.0",
91
92
  "lightningcss": "^1.30.1",
@@ -103,7 +104,7 @@
103
104
  "vitepress-plugin-group-icons": "^1.5.5",
104
105
  "vitepress-plugin-llms": "^1.3.4",
105
106
  "vitest": "^3.1.4",
106
- "vue": "^3.5.15"
107
+ "vue": "^3.5.16"
107
108
  },
108
109
  "engines": {
109
110
  "node": ">=18.0.0"
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.12.4";
3
-
4
- //#endregion
5
- export { version };