tsdown 0.16.6 → 0.16.8

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 { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./index-BcO8yjl6.mjs";
1
+ import { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./index-k1oOp_n4.mjs";
2
2
 
3
3
  //#region src/config.d.ts
4
4
 
package/dist/config.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { d as UserConfig, f as UserConfigExport, p as UserConfigFn } from "./index-BcO8yjl6.mjs";
2
- import { t as defineConfig } from "./config-BNLClkOs.mjs";
1
+ import { f as UserConfig, m as UserConfigFn, p as UserConfigExport } from "./index-k1oOp_n4.mjs";
2
+ import { t as defineConfig } from "./config-qCTuQ4uL.mjs";
3
3
  export { UserConfig, UserConfigExport, UserConfigFn, defineConfig };
@@ -23,11 +23,11 @@ interface AttwOptions extends CheckPackageOptions {
23
23
  * The available profiles are:
24
24
  * - `strict`: requires all resolutions
25
25
  * - `node16`: ignores node10 resolution failures
26
- * - `esmOnly`: ignores CJS resolution failures
26
+ * - `esm-only`: ignores CJS resolution failures
27
27
  *
28
28
  * @default 'strict'
29
29
  */
30
- profile?: "strict" | "node16" | "esmOnly";
30
+ profile?: "strict" | "node16" | "esm-only";
31
31
  /**
32
32
  * The level of the check.
33
33
  *
@@ -200,6 +200,11 @@ interface Workspace {
200
200
  config?: boolean | string;
201
201
  }
202
202
  type NoExternalFn = (id: string, importer: string | undefined) => boolean | null | undefined | void;
203
+ type CIOption = "ci-only" | "local-only";
204
+ type WithEnabled<T> = boolean | undefined | CIOption | (T & {
205
+ /** @default true */
206
+ enabled?: boolean | CIOption;
207
+ });
203
208
  /**
204
209
  * Options for tsdown.
205
210
  */
@@ -330,7 +335,7 @@ interface UserConfig {
330
335
  inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
331
336
  cjsDts: boolean;
332
337
  }) => Awaitable<InputOptions | void | null>);
333
- /** @default ['es'] */
338
+ /** @default 'es' */
334
339
  format?: Format | Format[];
335
340
  globalName?: string;
336
341
  /** @default 'dist' */
@@ -423,7 +428,7 @@ interface UserConfig {
423
428
  * If true, fails the build on warnings.
424
429
  * @default false
425
430
  */
426
- failOnWarn?: boolean;
431
+ failOnWarn?: boolean | CIOption;
427
432
  /**
428
433
  * Custom logger.
429
434
  */
@@ -451,7 +456,7 @@ interface UserConfig {
451
456
  *
452
457
  * @default false
453
458
  */
454
- debug?: boolean | DebugOptions;
459
+ debug?: WithEnabled<DebugOptions>;
455
460
  /**
456
461
  * Enables generation of TypeScript declaration files (`.d.ts`).
457
462
  *
@@ -459,19 +464,19 @@ interface UserConfig {
459
464
  * - If the `types` field is present, or if the main `exports` contains a `types` entry, declaration file generation is enabled by default.
460
465
  * - Otherwise, declaration file generation is disabled by default.
461
466
  */
462
- dts?: boolean | DtsOptions;
467
+ dts?: WithEnabled<DtsOptions>;
463
468
  /**
464
469
  * Enable unused dependencies check with `unplugin-unused`
465
470
  * Requires `unplugin-unused` to be installed.
466
471
  * @default false
467
472
  */
468
- unused?: boolean | UnusedOptions;
473
+ unused?: WithEnabled<UnusedOptions>;
469
474
  /**
470
475
  * Run publint after bundling.
471
476
  * Requires `publint` to be installed.
472
477
  * @default false
473
478
  */
474
- publint?: boolean | PublintOptions;
479
+ publint?: WithEnabled<PublintOptions>;
475
480
  /**
476
481
  * Run `arethetypeswrong` after bundling.
477
482
  * Requires `@arethetypeswrong/core` to be installed.
@@ -479,12 +484,12 @@ interface UserConfig {
479
484
  * @default false
480
485
  * @see https://github.com/arethetypeswrong/arethetypeswrong.github.io
481
486
  */
482
- attw?: boolean | AttwOptions;
487
+ attw?: WithEnabled<AttwOptions>;
483
488
  /**
484
489
  * Enable size reporting after bundling.
485
490
  * @default true
486
491
  */
487
- report?: boolean | ReportOptions;
492
+ report?: WithEnabled<ReportOptions>;
488
493
  /**
489
494
  * `import.meta.glob` support.
490
495
  * @see https://vite.dev/guide/features.html#glob-import
@@ -497,7 +502,7 @@ interface UserConfig {
497
502
  * This will set the `main`, `module`, `types`, `exports` fields in `package.json`
498
503
  * to point to the generated files.
499
504
  */
500
- exports?: boolean | ExportsOptions;
505
+ exports?: WithEnabled<ExportsOptions>;
501
506
  /**
502
507
  * @deprecated Alias for `copy`, will be removed in the future.
503
508
  */
@@ -535,23 +540,28 @@ interface InlineConfig extends UserConfig {
535
540
  */
536
541
  filter?: RegExp | string | string[];
537
542
  }
538
- type UserConfigFn = (inlineConfig: InlineConfig) => Awaitable<Arrayable<UserConfig>>;
543
+ type UserConfigFn = (inlineConfig: InlineConfig, context: {
544
+ ci: boolean;
545
+ }) => Awaitable<Arrayable<UserConfig>>;
539
546
  type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
540
547
  type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "silent" | "bundle" | "removeNodeProtocol" | "logLevel" | "failOnWarn" | "customLogger">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer">, {
541
548
  format: NormalizedFormat[];
542
549
  target?: string[];
543
550
  clean: string[];
544
- dts: false | DtsOptions;
545
- report: false | ReportOptions;
546
- tsconfig: false | string;
547
551
  pkg?: PackageJson;
548
- exports: false | ExportsOptions;
549
552
  nodeProtocol: "strip" | boolean;
550
553
  logger: Logger;
551
554
  ignoreWatch: Array<string | RegExp>;
552
555
  noExternal?: NoExternalFn;
553
556
  inlineOnly?: Array<string | RegExp>;
557
+ dts: false | DtsOptions;
558
+ report: false | ReportOptions;
559
+ tsconfig: false | string;
560
+ exports: false | ExportsOptions;
554
561
  debug: false | DebugOptions;
562
+ publint: false | PublintOptions;
563
+ attw: false | AttwOptions;
564
+ unused: false | UnusedOptions;
555
565
  }>;
556
566
  //#endregion
557
- export { TsdownChunks as A, OutExtensionFactory as C, RolldownContext as D, BuildContext as E, AttwOptions as F, CopyEntry as M, CopyOptions as N, TsdownHooks as O, CopyOptionsFn as P, OutExtensionContext as S, PackageType as T, Logger as _, NormalizedFormat as a, ChunkAddonFunction as b, Sourcemap as c, UserConfig as d, UserConfigExport as f, ReportPlugin as g, ReportOptions as h, NoExternalFn as i, DebugOptions as j, ExportsOptions as k, TreeshakingOptions as l, Workspace as m, Format as n, PublintOptions as o, UserConfigFn as p, InlineConfig as r, ResolvedConfig as s, DtsOptions as t, UnusedOptions as u, globalLogger as v, OutExtensionObject as w, ChunkAddonObject as x, ChunkAddon as y };
567
+ export { TsdownHooks as A, ChunkAddonObject as C, PackageType as D, OutExtensionObject as E, CopyOptions as F, CopyOptionsFn as I, AttwOptions as L, TsdownChunks as M, DebugOptions as N, BuildContext as O, CopyEntry as P, ChunkAddonFunction as S, OutExtensionFactory as T, ReportOptions as _, NoExternalFn as a, globalLogger as b, ResolvedConfig as c, UnusedOptions as d, UserConfig as f, Workspace as g, WithEnabled as h, InlineConfig as i, ExportsOptions as j, RolldownContext as k, Sourcemap as l, UserConfigFn as m, DtsOptions as n, NormalizedFormat as o, UserConfigExport as p, Format as r, PublintOptions as s, CIOption as t, TreeshakingOptions as u, ReportPlugin as v, OutExtensionContext as w, ChunkAddon as x, Logger as y };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as TsdownChunks, C as OutExtensionFactory, D as RolldownContext, E as BuildContext, F as AttwOptions, M as CopyEntry, N as CopyOptions, O as TsdownHooks, P as CopyOptionsFn, S as OutExtensionContext, T as PackageType, _ as Logger, a as NormalizedFormat, b as ChunkAddonFunction, c as Sourcemap, d as UserConfig, f as UserConfigExport, h as ReportOptions, i as NoExternalFn, j as DebugOptions, k as ExportsOptions, l as TreeshakingOptions, m as Workspace, n as Format, o as PublintOptions, p as UserConfigFn, r as InlineConfig, s as ResolvedConfig, t as DtsOptions, u as UnusedOptions, v as globalLogger, w as OutExtensionObject, x as ChunkAddonObject, y as ChunkAddon } from "./index-BcO8yjl6.mjs";
2
- import { t as defineConfig } from "./config-BNLClkOs.mjs";
1
+ import { A as TsdownHooks, C as ChunkAddonObject, D as PackageType, E as OutExtensionObject, F as CopyOptions, I as CopyOptionsFn, L as AttwOptions, M as TsdownChunks, N as DebugOptions, O as BuildContext, P as CopyEntry, S as ChunkAddonFunction, T as OutExtensionFactory, _ as ReportOptions, a as NoExternalFn, b as globalLogger, c as ResolvedConfig, d as UnusedOptions, f as UserConfig, g as Workspace, h as WithEnabled, i as InlineConfig, j as ExportsOptions, k as RolldownContext, l as Sourcemap, m as UserConfigFn, n as DtsOptions, o as NormalizedFormat, p as UserConfigExport, r as Format, s as PublintOptions, t as CIOption, u as TreeshakingOptions, w as OutExtensionContext, x as ChunkAddon, y as Logger } from "./index-k1oOp_n4.mjs";
2
+ import { t as defineConfig } from "./config-qCTuQ4uL.mjs";
3
3
 
4
4
  //#region src/index.d.ts
5
5
 
@@ -19,4 +19,4 @@ declare const shimFile: string;
19
19
  */
20
20
  declare function buildSingle(config: ResolvedConfig, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
21
21
  //#endregion
22
- export { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DebugOptions, DtsOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedConfig, RolldownContext, Sourcemap, TreeshakingOptions, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, Workspace, build, buildSingle, defineConfig, globalLogger, shimFile };
22
+ export { AttwOptions, BuildContext, CIOption, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DebugOptions, DtsOptions, ExportsOptions, Format, InlineConfig, type Logger, NoExternalFn, NormalizedFormat, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedConfig, RolldownContext, Sourcemap, TreeshakingOptions, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigExport, UserConfigFn, WithEnabled, Workspace, build, buildSingle, defineConfig, globalLogger, shimFile };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as defineConfig } from "./config-DLSWqKoz.mjs";
2
- import { n as buildSingle, r as shimFile, t as build } from "./src-DWFMRAyU.mjs";
3
- import { a as globalLogger } from "./package-Cu3WIzIc.mjs";
2
+ import { n as buildSingle, r as shimFile, t as build } from "./src-EBZO44R8.mjs";
3
+ import { a as globalLogger } from "./package-BDAjF-Kz.mjs";
4
4
 
5
5
  export { build, buildSingle, defineConfig, globalLogger, shimFile };
@@ -1,4 +1,4 @@
1
- import { a as globalLogger, t as version } from "./package-Cu3WIzIc.mjs";
1
+ import { a as globalLogger, t as version } from "./package-BDAjF-Kz.mjs";
2
2
  import process from "node:process";
3
3
  import { bold, green, underline } from "ansis";
4
4
  import { readFile, unlink, writeFile } from "node:fs/promises";
@@ -160,7 +160,7 @@ function hue2rgb(p, q, t) {
160
160
 
161
161
  //#endregion
162
162
  //#region package.json
163
- var version = "0.16.6";
163
+ var version = "0.16.8";
164
164
 
165
165
  //#endregion
166
166
  export { globalLogger as a, debounce as c, noop as d, pkgExists as f, toArray as g, slash as h, generateColor as i, importWithError as l, resolveRegex as m, LogLevels as n, prettyFormat as o, resolveComma as p, createLogger as r, prettyName as s, version as t, matchPattern as u };
@@ -1,4 +1,4 @@
1
- import { _ as Logger, g as ReportPlugin, s as ResolvedConfig } from "./index-BcO8yjl6.mjs";
1
+ import { c as ResolvedConfig, v as ReportPlugin, y as Logger } from "./index-k1oOp_n4.mjs";
2
2
  import { Plugin } from "rolldown";
3
3
 
4
4
  //#region src/features/external.d.ts
package/dist/plugins.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./config-DLSWqKoz.mjs";
2
- import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, s as ExternalPlugin } from "./src-DWFMRAyU.mjs";
3
- import "./package-Cu3WIzIc.mjs";
2
+ import { a as ReportPlugin, i as ShebangPlugin, o as NodeProtocolPlugin, s as ExternalPlugin } from "./src-EBZO44R8.mjs";
3
+ import "./package-BDAjF-Kz.mjs";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as globalLogger, g as toArray, p as resolveComma, t as version } from "./package-Cu3WIzIc.mjs";
2
+ import { a as globalLogger, g as toArray, p as resolveComma, t as version } from "./package-BDAjF-Kz.mjs";
3
3
  import module from "node:module";
4
4
  import process from "node:process";
5
5
  import { dim } from "ansis";
@@ -36,7 +36,7 @@ cli.command("[...files]", "Bundle files", {
36
36
  await build$1(flags);
37
37
  });
38
38
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
39
- const { migrate } = await import("./migrate-CFJaLDyD.mjs");
39
+ const { migrate } = await import("./migrate-nFQ0dxbr.mjs");
40
40
  await migrate(args);
41
41
  });
42
42
  async function runCLI() {
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __cjs_createRequire } from "node:module";
2
2
  const __cjs_require = __cjs_createRequire(import.meta.url);
3
- import { a as globalLogger, c as debounce, d as noop, f as pkgExists, g as toArray, h as slash, i as generateColor, l as importWithError, m as resolveRegex, n as LogLevels, o as prettyFormat, p as resolveComma, r as createLogger, s as prettyName, t as version, u as matchPattern } from "./package-Cu3WIzIc.mjs";
3
+ import { a as globalLogger, c as debounce, d as noop, f as pkgExists, g as toArray, h as slash, i as generateColor, l as importWithError, m as resolveRegex, n as LogLevels, o as prettyFormat, p as resolveComma, r as createLogger, s as prettyName, t as version, u as matchPattern } from "./package-BDAjF-Kz.mjs";
4
4
  import { builtinModules, isBuiltin } from "node:module";
5
5
  import path, { dirname, join, normalize, sep } from "node:path";
6
- import process from "node:process";
6
+ import process, { env } from "node:process";
7
7
  import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import { blue, bold, dim, green, underline } from "ansis";
9
9
  import { VERSION, build } from "rolldown";
@@ -28,6 +28,12 @@ import { brotliCompress, gzip } from "node:zlib";
28
28
  import readline from "node:readline";
29
29
  import { globalContext, invalidateContextFile } from "rolldown-plugin-dts/tsc-context";
30
30
 
31
+ //#region node_modules/.pnpm/is-in-ci@2.0.0/node_modules/is-in-ci/index.js
32
+ const check = (key) => key in env && env[key] !== "0" && env[key] !== "false";
33
+ const isInCi = check("CI") || check("CONTINUOUS_INTEGRATION");
34
+ var is_in_ci_default = isInCi;
35
+
36
+ //#endregion
31
37
  //#region src/utils/fs.ts
32
38
  function fsExists(path$1) {
33
39
  return access(path$1).then(() => true, () => false);
@@ -155,10 +161,11 @@ async function loadConfigFile(inlineConfig, workspace) {
155
161
  ({config: exported, source: file} = result);
156
162
  globalLogger.info(`Using tsdown config: ${underline(file)}`);
157
163
  exported = await exported;
158
- if (typeof exported === "function") exported = await exported(inlineConfig);
164
+ if (typeof exported === "function") exported = await exported(inlineConfig, { ci: is_in_ci_default });
159
165
  }
160
166
  exported = toArray(exported);
161
167
  if (exported.length === 0) exported.push({});
168
+ if (exported.some((config) => typeof config === "function")) throw new Error("Function should not be nested within multiple tsdown configurations. It must be at the top level.\nExample: export default defineConfig(() => [...])");
162
169
  return {
163
170
  configs: exported,
164
171
  file
@@ -559,10 +566,10 @@ async function resolveWorkspace(config, inlineConfig) {
559
566
  };
560
567
  }
561
568
  async function resolveUserConfig(userConfig, inlineConfig) {
562
- let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, fixedExtension = platform === "node", debug: debug$9 = false } = userConfig;
569
+ let { entry, format = ["es"], plugins = [], clean = true, silent = false, logLevel = silent ? "silent" : "info", failOnWarn = false, customLogger, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, ignoreWatch, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, attw: attw$1 = false, fromVite, alias, tsconfig, report = true, target, env: env$1 = {}, copy: copy$1, publicDir, hash = true, cwd = process.cwd(), name, workspace, external, noExternal, exports = false, bundle, unbundle = typeof bundle === "boolean" ? !bundle : false, removeNodeProtocol, nodeProtocol, cjsDefault = true, globImport = true, inlineOnly, fixedExtension = platform === "node", debug: debug$9 = false } = userConfig;
563
570
  const logger = createLogger(logLevel, {
564
571
  customLogger,
565
- failOnWarn
572
+ failOnWarn: resolveFeatureOption(failOnWarn, true)
566
573
  });
567
574
  if (typeof bundle === "boolean") logger.warn("`bundle` option is deprecated. Use `unbundle` instead.");
568
575
  if (removeNodeProtocol && nodeProtocol) throw new TypeError("`removeNodeProtocol` is deprecated. Please only use `nodeProtocol` instead.");
@@ -577,9 +584,12 @@ async function resolveUserConfig(userConfig, inlineConfig) {
577
584
  tsconfig = await resolveTsconfig(logger, tsconfig, cwd, name);
578
585
  if (typeof external === "string") external = resolveRegex(external);
579
586
  if (typeof noExternal === "string") noExternal = resolveRegex(noExternal);
580
- if (publint$1 === true) publint$1 = {};
581
- if (attw$1 === true) attw$1 = {};
582
- if (exports === true) exports = {};
587
+ publint$1 = resolveFeatureOption(publint$1, {});
588
+ attw$1 = resolveFeatureOption(attw$1, {});
589
+ exports = resolveFeatureOption(exports, {});
590
+ unused = resolveFeatureOption(unused, {});
591
+ report = resolveFeatureOption(report, {});
592
+ dts = resolveFeatureOption(dts, {});
583
593
  if (publicDir) if (copy$1) throw new TypeError("`publicDir` is deprecated. Cannot be used with `copy`");
584
594
  else logger.warn(`${blue`publicDir`} is deprecated. Use ${blue`copy`} instead.`);
585
595
  if (fromVite) {
@@ -604,10 +614,8 @@ async function resolveUserConfig(userConfig, inlineConfig) {
604
614
  noExternal = (id) => matchPattern(id, noExternalPatterns);
605
615
  }
606
616
  if (inlineOnly != null) inlineOnly = toArray(inlineOnly);
607
- if (debug$9) {
608
- if (debug$9 === true) debug$9 = {};
609
- debug$9.devtools ??= !!pkgExists("@vitejs/devtools/cli");
610
- }
617
+ debug$9 = resolveFeatureOption(debug$9, {});
618
+ if (debug$9) debug$9.devtools ??= !!pkgExists("@vitejs/devtools/cli");
611
619
  return {
612
620
  ...userConfig,
613
621
  entry,
@@ -620,8 +628,8 @@ async function resolveUserConfig(userConfig, inlineConfig) {
620
628
  treeshake,
621
629
  platform,
622
630
  sourcemap,
623
- dts: dts === true ? {} : dts,
624
- report: report === true ? {} : report,
631
+ dts,
632
+ report,
625
633
  unused,
626
634
  watch,
627
635
  ignoreWatch,
@@ -632,10 +640,10 @@ async function resolveUserConfig(userConfig, inlineConfig) {
632
640
  alias,
633
641
  tsconfig,
634
642
  cwd,
635
- env,
643
+ env: env$1,
636
644
  pkg,
637
645
  copy: publicDir || copy$1,
638
- hash: hash ?? true,
646
+ hash,
639
647
  name,
640
648
  external,
641
649
  noExternal,
@@ -656,10 +664,20 @@ async function mergeUserOptions(defaults, user, args) {
656
664
  ...userOutputOptions
657
665
  };
658
666
  }
667
+ function resolveFeatureOption(value, defaults) {
668
+ if (typeof value === "object" && value !== null) return resolveCIOption(value.enabled ?? true) ? value : false;
669
+ return resolveCIOption(value) ? defaults : false;
670
+ }
671
+ function resolveCIOption(value) {
672
+ if (value === "ci-only") return is_in_ci_default ? true : false;
673
+ if (value === "local-only") return is_in_ci_default ? false : true;
674
+ return value;
675
+ }
659
676
 
660
677
  //#endregion
661
678
  //#region src/features/attw.ts
662
679
  const debug$4 = createDebug("tsdown:attw");
680
+ const label$1 = dim`[attw]`;
663
681
  /**
664
682
  * ATTW profiles.
665
683
  * Defines the resolution modes to ignore for each profile.
@@ -669,44 +687,24 @@ const debug$4 = createDebug("tsdown:attw");
669
687
  const profiles = {
670
688
  strict: [],
671
689
  node16: ["node10"],
672
- esmOnly: ["node10", "node16-cjs"]
690
+ "esm-only": ["node10", "node16-cjs"]
673
691
  };
674
- /**
675
- * Format an ATTW problem for display
676
- */
677
- function formatProblem(problem) {
678
- const resolutionKind = "resolutionKind" in problem ? ` (${problem.resolutionKind})` : "";
679
- const entrypoint = "entrypoint" in problem ? ` at ${problem.entrypoint}` : "";
680
- switch (problem.kind) {
681
- case "NoResolution": return ` ❌ No resolution${resolutionKind}${entrypoint}`;
682
- case "UntypedResolution": return ` ⚠️ Untyped resolution${resolutionKind}${entrypoint}`;
683
- case "FalseESM": return ` 🔄 False ESM: Types indicate ESM (${problem.typesModuleKind}) but implementation is CJS (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
684
- case "FalseCJS": return ` 🔄 False CJS: Types indicate CJS (${problem.typesModuleKind}) but implementation is ESM (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
685
- case "CJSResolvesToESM": return ` ⚡ CJS resolves to ESM${resolutionKind}${entrypoint}`;
686
- case "NamedExports": {
687
- const missingExports = problem.missing?.length > 0 ? ` Missing: ${problem.missing.join(", ")}` : "";
688
- return ` 📤 Named exports problem${problem.isMissingAllNamed ? " (all named exports missing)" : ""}${missingExports}\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
689
- }
690
- case "FallbackCondition": return ` 🎯 Fallback condition used${resolutionKind}${entrypoint}`;
691
- case "FalseExportDefault": return ` 🎭 False export default\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
692
- case "MissingExportEquals": return ` 📝 Missing export equals\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
693
- case "InternalResolutionError": return ` 💥 Internal resolution error in ${problem.fileName} (${problem.resolutionOption})\n Module: ${problem.moduleSpecifier} | Mode: ${problem.resolutionMode}`;
694
- case "UnexpectedModuleSyntax": return ` 📋 Unexpected module syntax in ${problem.fileName}\n Expected: ${problem.moduleKind} | Found: ${problem.syntax === 99 ? "ESM" : "CJS"}`;
695
- case "CJSOnlyExportsDefault": return ` 🏷️ CJS only exports default in ${problem.fileName}`;
696
- default: return ` ❓ Unknown problem: ${JSON.stringify(problem)}`;
697
- }
698
- }
699
692
  async function attw(options) {
700
693
  if (!options.attw) return;
701
694
  if (!options.pkg) {
702
695
  options.logger.warn("attw is enabled but package.json is not found");
703
696
  return;
704
697
  }
705
- const { profile = "strict", level = "warn", ...attwOptions } = options.attw === true ? {} : options.attw;
698
+ let { profile = "strict", level = "warn", ...attwOptions } = options.attw;
699
+ if (profile === "esmOnly") {
700
+ options.logger.warn("attw option \"esmOnly\" is deprecated, use \"esm-only\" instead");
701
+ profile = "esm-only";
702
+ }
706
703
  const t = performance.now();
707
704
  debug$4("Running attw check");
708
705
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
709
706
  const attwCore = await importWithError("@arethetypeswrong/core");
707
+ let checkResult;
710
708
  try {
711
709
  const { stdout: tarballInfo } = await exec("npm", [
712
710
  "pack",
@@ -718,25 +716,55 @@ async function attw(options) {
718
716
  if (!Array.isArray(parsed) || !parsed[0]?.filename) throw new Error("Invalid npm pack output format");
719
717
  const tarball = await readFile(path.join(tempDir, parsed[0].filename));
720
718
  const pkg = attwCore.createPackageFromTarballData(tarball);
721
- const checkResult = await attwCore.checkPackage(pkg, attwOptions);
722
- if (checkResult.types !== false && checkResult.problems.length) {
723
- const problems = checkResult.problems.filter((problem) => {
724
- if ("resolutionKind" in problem) return !profiles[profile]?.includes(problem.resolutionKind);
725
- return true;
726
- });
727
- if (problems.length) {
728
- const problemMessage = `Are the types wrong problems found:\n${problems.map(formatProblem).join("\n")}`;
729
- if (level === "error") throw new Error(problemMessage);
730
- options.logger.warn(prettyName(options.name), problemMessage);
731
- }
732
- } else options.logger.success(prettyName(options.name), `No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
719
+ checkResult = await attwCore.checkPackage(pkg, attwOptions);
733
720
  } catch (error) {
734
721
  options.logger.error("ATTW check failed:", error);
735
722
  debug$4("Found errors, setting exit code to 1");
736
723
  process.exitCode = 1;
724
+ return;
737
725
  } finally {
738
726
  await fsRemove(tempDir);
739
727
  }
728
+ let errorMessage;
729
+ if (checkResult.types) {
730
+ const problems = checkResult.problems.filter((problem) => {
731
+ if ("resolutionKind" in problem) return !profiles[profile]?.includes(problem.resolutionKind);
732
+ return true;
733
+ });
734
+ if (problems.length) errorMessage = `problems found:\n${problems.map(formatProblem).join("\n")}`;
735
+ } else errorMessage = `Package has no types`;
736
+ if (errorMessage) {
737
+ options.logger[level](prettyName(options.name), label$1, errorMessage);
738
+ if (level === "error") {
739
+ process.exitCode = 1;
740
+ debug$4("Found problems, setting exit code to 1");
741
+ }
742
+ } else options.logger.success(prettyName(options.name), label$1, "No problems found", dim`(${Math.round(performance.now() - t)}ms)`);
743
+ }
744
+ /**
745
+ * Format an ATTW problem for display
746
+ */
747
+ function formatProblem(problem) {
748
+ const resolutionKind = "resolutionKind" in problem ? ` (${problem.resolutionKind})` : "";
749
+ const entrypoint = "entrypoint" in problem ? ` at ${problem.entrypoint}` : "";
750
+ switch (problem.kind) {
751
+ case "NoResolution": return ` ❌ No resolution${resolutionKind}${entrypoint}`;
752
+ case "UntypedResolution": return ` ⚠️ Untyped resolution${resolutionKind}${entrypoint}`;
753
+ case "FalseESM": return ` 🔄 False ESM: Types indicate ESM (${problem.typesModuleKind}) but implementation is CJS (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
754
+ case "FalseCJS": return ` 🔄 False CJS: Types indicate CJS (${problem.typesModuleKind}) but implementation is ESM (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
755
+ case "CJSResolvesToESM": return ` ⚡ CJS resolves to ESM${resolutionKind}${entrypoint}`;
756
+ case "NamedExports": {
757
+ const missingExports = problem.missing?.length > 0 ? ` Missing: ${problem.missing.join(", ")}` : "";
758
+ return ` 📤 Named exports problem${problem.isMissingAllNamed ? " (all named exports missing)" : ""}${missingExports}\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
759
+ }
760
+ case "FallbackCondition": return ` 🎯 Fallback condition used${resolutionKind}${entrypoint}`;
761
+ case "FalseExportDefault": return ` 🎭 False export default\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
762
+ case "MissingExportEquals": return ` 📝 Missing export equals\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`;
763
+ case "InternalResolutionError": return ` 💥 Internal resolution error in ${problem.fileName} (${problem.resolutionOption})\n Module: ${problem.moduleSpecifier} | Mode: ${problem.resolutionMode}`;
764
+ case "UnexpectedModuleSyntax": return ` 📋 Unexpected module syntax in ${problem.fileName}\n Expected: ${problem.moduleKind} | Found: ${problem.syntax === 99 ? "ESM" : "CJS"}`;
765
+ case "CJSOnlyExportsDefault": return ` 🏷️ CJS only exports default in ${problem.fileName}`;
766
+ default: return ` ❓ Unknown problem: ${JSON.stringify(problem)}`;
767
+ }
740
768
  }
741
769
 
742
770
  //#endregion
@@ -787,6 +815,7 @@ async function createHooks$1(options) {
787
815
  //#endregion
788
816
  //#region src/features/publint.ts
789
817
  const debug$3 = createDebug("tsdown:publint");
818
+ const label = dim`[publint]`;
790
819
  async function publint(options) {
791
820
  if (!options.publint) return;
792
821
  if (!options.pkg) {
@@ -798,12 +827,12 @@ async function publint(options) {
798
827
  const { publint: publint$1 } = await importWithError("publint");
799
828
  const { formatMessage } = await import("publint/utils");
800
829
  const { messages } = await publint$1({
801
- ...options.publint === true ? {} : options.publint,
830
+ ...options.publint,
802
831
  pkgDir: path.dirname(options.pkg.packageJsonPath)
803
832
  });
804
833
  debug$3("Found %d issues", messages.length);
805
834
  if (!messages.length) {
806
- options.logger.success(prettyName(options.name), `No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
835
+ options.logger.success(prettyName(options.name), label, "No issues found", dim`(${Math.round(performance.now() - t)}ms)`);
807
836
  return;
808
837
  }
809
838
  let hasError = false;
@@ -815,7 +844,7 @@ async function publint(options) {
815
844
  warning: "warn",
816
845
  suggestion: "info"
817
846
  }[message.type];
818
- options.logger[logType](prettyName(options.name), formattedMessage);
847
+ options.logger[logType](prettyName(options.name), label, formattedMessage);
819
848
  }
820
849
  if (hasError) {
821
850
  debug$3("Found errors, setting exit code to 1");
@@ -1143,7 +1172,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
1143
1172
  return rolldownConfig;
1144
1173
  }
1145
1174
  async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
1146
- const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer, globImport, debug: debug$9 } = config;
1175
+ const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, shims, tsconfig, cwd, report, env: env$1, nodeProtocol, loader, name, logger, cjsDefault, banner, footer, globImport, debug: debug$9 } = config;
1147
1176
  const plugins = [];
1148
1177
  if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
1149
1178
  if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
@@ -1167,7 +1196,7 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
1167
1196
  const { Unused } = await importWithError("unplugin-unused");
1168
1197
  plugins.push(Unused.rolldown({
1169
1198
  root: cwd,
1170
- ...unused === true ? {} : unused
1199
+ ...unused
1171
1200
  }));
1172
1201
  }
1173
1202
  if (target) plugins.push(await LightningCSSPlugin({ target }));
@@ -1178,8 +1207,8 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
1178
1207
  if (!cjsDts) plugins.push(userPlugins);
1179
1208
  const define = {
1180
1209
  ...config.define,
1181
- ...Object.keys(env).reduce((acc, key) => {
1182
- const value = JSON.stringify(env[key]);
1210
+ ...Object.keys(env$1).reduce((acc, key) => {
1211
+ const value = JSON.stringify(env$1[key]);
1183
1212
  acc[`process.env.${key}`] = value;
1184
1213
  acc[`import.meta.env.${key}`] = value;
1185
1214
  return acc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.16.6",
3
+ "version": "0.16.8",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "typesVersions": {
34
34
  "*": {
35
35
  "*": [
36
- "./dist/*",
36
+ "./dist/*.d.mts",
37
37
  "./*"
38
38
  ]
39
39
  }
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@arethetypeswrong/core": "^0.18.1",
49
- "@vitejs/devtools": "^0.0.0-alpha.17",
49
+ "@vitejs/devtools": "^0.0.0-alpha.18",
50
50
  "publint": "^0.3.0",
51
51
  "typescript": "^5.0.0",
52
52
  "unplugin-lightningcss": "^0.4.0",
@@ -75,43 +75,44 @@
75
75
  "dependencies": {
76
76
  "ansis": "^4.2.0",
77
77
  "cac": "^6.7.14",
78
- "chokidar": "^4.0.3",
78
+ "chokidar": "^5.0.0",
79
79
  "diff": "^8.0.2",
80
80
  "empathic": "^2.0.0",
81
81
  "hookable": "^5.5.3",
82
- "obug": "^2.1.0",
83
- "rolldown": "1.0.0-beta.51",
84
- "rolldown-plugin-dts": "^0.18.0",
82
+ "obug": "^2.1.1",
83
+ "rolldown": "1.0.0-beta.52",
84
+ "rolldown-plugin-dts": "^0.18.1",
85
85
  "semver": "^7.7.3",
86
86
  "tinyexec": "^1.0.2",
87
87
  "tinyglobby": "^0.2.15",
88
88
  "tree-kill": "^1.2.2",
89
89
  "unconfig-core": "^7.4.1",
90
- "unrun": "^0.2.11"
90
+ "unrun": "^0.2.13"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@arethetypeswrong/core": "^0.18.2",
94
- "@sxzz/eslint-config": "^7.3.0",
95
- "@sxzz/prettier-config": "^2.2.5",
96
- "@sxzz/test-utils": "^0.5.12",
94
+ "@sxzz/eslint-config": "^7.3.2",
95
+ "@sxzz/prettier-config": "^2.2.6",
96
+ "@sxzz/test-utils": "^0.5.13",
97
97
  "@types/node": "^24.10.1",
98
98
  "@types/semver": "^7.7.1",
99
- "@unocss/eslint-plugin": "66.5.4",
100
- "@vitejs/devtools": "^0.0.0-alpha.17",
101
- "@vueuse/core": "^14.0.0",
102
- "bumpp": "^10.3.1",
99
+ "@unocss/eslint-plugin": "^66.5.9",
100
+ "@vitejs/devtools": "^0.0.0-alpha.18",
101
+ "@vueuse/core": "^14.1.0",
102
+ "bumpp": "^10.3.2",
103
103
  "eslint": "^9.39.1",
104
+ "is-in-ci": "^2.0.0",
104
105
  "lightningcss": "^1.30.2",
105
106
  "pkg-types": "^2.3.0",
106
- "prettier": "^3.6.2",
107
+ "prettier": "^3.7.1",
107
108
  "publint": "^0.3.15",
108
109
  "rolldown-plugin-require-cjs": "^0.3.1",
109
110
  "typescript": "~5.9.3",
110
- "unocss": "^66.5.7",
111
+ "unocss": "^66.5.9",
111
112
  "unplugin-lightningcss": "^0.4.3",
112
113
  "unplugin-unused": "^0.5.6",
113
- "vite": "npm:rolldown-vite@^7.2.6",
114
- "vitest": "^4.0.10"
114
+ "vite": "npm:rolldown-vite@^7.2.8",
115
+ "vitest": "^4.0.14"
115
116
  },
116
117
  "engines": {
117
118
  "node": ">=20.19.0"