tsdown 0.15.0 → 0.15.1

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 "./types-CrxW0Y6g.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-CttfsBjJ.mjs";
2
2
 
3
3
  //#region src/config.d.ts
4
4
 
package/dist/config.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { UserConfig, UserConfigFn } from "./types-CrxW0Y6g.mjs";
2
- import { defineConfig } from "./config-Dk5Fszoy.mjs";
1
+ import { UserConfig, UserConfigFn } from "./types-CttfsBjJ.mjs";
2
+ import { defineConfig } from "./config-Cb8AaSYW.mjs";
3
3
  export { UserConfig, UserConfigFn, defineConfig };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-CrxW0Y6g.mjs";
2
- import { defineConfig } from "./config-Dk5Fszoy.mjs";
1
+ import { AttwOptions, BuildContext, ChunkAddon, ChunkAddonFunction, ChunkAddonObject, CopyEntry, CopyOptions, CopyOptionsFn, DtsOptions, ExportsOptions, Format, Logger, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, OutExtensionContext, OutExtensionFactory, OutExtensionObject, PackageType, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, globalLogger } from "./types-CttfsBjJ.mjs";
2
+ import { defineConfig } from "./config-Cb8AaSYW.mjs";
3
3
 
4
4
  //#region src/index.d.ts
5
5
 
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from "./config-CCGWF4al.mjs";
2
- import { build, buildSingle, shimFile } from "./src-DecVfDJY.mjs";
2
+ import { build, buildSingle, shimFile } from "./src-Cv09-2ZP.mjs";
3
3
  import { globalLogger } from "./logger-C09npKHT.mjs";
4
4
 
5
5
  export { build, buildSingle, defineConfig, globalLogger, shimFile };
@@ -1,5 +1,5 @@
1
1
  import { globalLogger } from "./logger-C09npKHT.mjs";
2
- import { version } from "./package-BCet0jau.mjs";
2
+ import { version } from "./package-CGTDSgsc.mjs";
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.15.1";
3
+
4
+ //#endregion
5
+ export { version };
@@ -1,4 +1,4 @@
1
- import { Logger, ReportPlugin, ResolvedOptions } from "./types-CrxW0Y6g.mjs";
1
+ import { Logger, ReportPlugin, ResolvedOptions } from "./types-CttfsBjJ.mjs";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/plugins.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./config-CCGWF4al.mjs";
2
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-DecVfDJY.mjs";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-Cv09-2ZP.mjs";
3
3
  import "./logger-C09npKHT.mjs";
4
4
 
5
5
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.d.mts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export { };
package/dist/run.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { globalLogger, resolveComma, toArray } from "./logger-C09npKHT.mjs";
3
- import { version } from "./package-BCet0jau.mjs";
3
+ import { version } from "./package-CGTDSgsc.mjs";
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("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").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("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).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("--attw", "Enable Are the types wrong integration", { 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("--unbundle", "Unbundle mode").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
17
+ }).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unconfig", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").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("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).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("--attw", "Enable Are the types wrong integration", { 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("--unbundle", "Unbundle mode").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
18
18
  globalLogger.level = flags.logLevel || (flags.silent ? "silent" : "info");
19
19
  globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
20
20
  const { build: build$1 } = await import("./index.mjs");
@@ -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-Di69B4rp.mjs");
25
+ const { migrate } = await import("./migrate-CliKn3g9.mjs");
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();
@@ -11,7 +11,7 @@ import child_process from "node:child_process";
11
11
  import { access, chmod, cp, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
12
12
  import { tmpdir } from "node:os";
13
13
  import { promisify } from "node:util";
14
- import debug from "debug";
14
+ import Debug from "debug";
15
15
  import coerce from "semver/functions/coerce.js";
16
16
  import satisfies from "semver/functions/satisfies.js";
17
17
  import { glob } from "tinyglobby";
@@ -67,7 +67,7 @@ function lowestCommonAncestor(...filepaths) {
67
67
 
68
68
  //#endregion
69
69
  //#region src/features/attw.ts
70
- const debug$8 = debug("tsdown:attw");
70
+ const debug$7 = Debug("tsdown:attw");
71
71
  const exec$1 = promisify(child_process.exec);
72
72
  /**
73
73
  * ATTW profiles.
@@ -113,7 +113,7 @@ async function attw(options) {
113
113
  }
114
114
  const { profile = "strict", level = "warn",...attwOptions } = options.attw === true ? {} : options.attw;
115
115
  const t = performance.now();
116
- debug$8("Running attw check");
116
+ debug$7("Running attw check");
117
117
  const tempDir = await mkdtemp(path.join(tmpdir(), "tsdown-attw-"));
118
118
  let attwCore;
119
119
  try {
@@ -146,7 +146,7 @@ async function attw(options) {
146
146
  } else options.logger.success(`No Are the types wrong problems found`, dim`(${Math.round(performance.now() - t)}ms)`);
147
147
  } catch (error) {
148
148
  options.logger.error("ATTW check failed:", error);
149
- debug$8("Found errors, setting exit code to 1");
149
+ debug$7("Found errors, setting exit code to 1");
150
150
  process.exitCode = 1;
151
151
  } finally {
152
152
  await fsRemove(tempDir);
@@ -170,7 +170,7 @@ function warnLegacyCJS(config) {
170
170
 
171
171
  //#endregion
172
172
  //#region src/features/clean.ts
173
- const debug$7 = debug("tsdown:clean");
173
+ const debug$6 = Debug("tsdown:clean");
174
174
  const RE_LAST_SLASH = /[/\\]$/;
175
175
  async function cleanOutDir(configs) {
176
176
  const removes = /* @__PURE__ */ new Set();
@@ -187,10 +187,10 @@ async function cleanOutDir(configs) {
187
187
  if (!removes.size) return;
188
188
  globalLogger.info(`Cleaning ${removes.size} files`);
189
189
  await Promise.all([...removes].map(async (file) => {
190
- debug$7("Removing", file);
190
+ debug$6("Removing", file);
191
191
  await fsRemove(file);
192
192
  }));
193
- debug$7("Removed %d files", removes.size);
193
+ debug$6("Removed %d files", removes.size);
194
194
  }
195
195
  function resolveClean(clean, outDir, cwd) {
196
196
  if (clean === true) clean = [slash(outDir)];
@@ -348,7 +348,7 @@ async function createHooks$1(options) {
348
348
 
349
349
  //#endregion
350
350
  //#region src/features/publint.ts
351
- const debug$6 = debug("tsdown:publint");
351
+ const debug$5 = Debug("tsdown:publint");
352
352
  async function publint(options) {
353
353
  if (!options.publint) return;
354
354
  if (!options.pkg) {
@@ -356,11 +356,11 @@ async function publint(options) {
356
356
  return;
357
357
  }
358
358
  const t = performance.now();
359
- debug$6("Running publint");
359
+ debug$5("Running publint");
360
360
  const { publint: publint$1 } = await import("publint");
361
361
  const { formatMessage } = await import("publint/utils");
362
362
  const { messages } = await publint$1(options.publint === true ? {} : options.publint);
363
- debug$6("Found %d issues", messages.length);
363
+ debug$5("Found %d issues", messages.length);
364
364
  if (!messages.length) options.logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
365
365
  let hasError = false;
366
366
  for (const message of messages) {
@@ -374,7 +374,7 @@ async function publint(options) {
374
374
  options.logger[logType](formattedMessage);
375
375
  }
376
376
  if (hasError) {
377
- debug$6("Found errors, setting exit code to 1");
377
+ debug$5("Found errors, setting exit code to 1");
378
378
  process.exitCode = 1;
379
379
  }
380
380
  }
@@ -485,11 +485,11 @@ async function resolveTsconfig(logger, tsconfig, cwd, name) {
485
485
 
486
486
  //#endregion
487
487
  //#region src/utils/package.ts
488
- const debug$5 = debug("tsdown:package");
488
+ const debug$4 = Debug("tsdown:package");
489
489
  async function readPackageJson(dir) {
490
490
  const packageJsonPath = up$1({ cwd: dir });
491
491
  if (!packageJsonPath) return;
492
- debug$5("Reading package.json:", packageJsonPath);
492
+ debug$4("Reading package.json:", packageJsonPath);
493
493
  const contents = await readFile(packageJsonPath, "utf8");
494
494
  return {
495
495
  ...JSON.parse(contents),
@@ -561,7 +561,11 @@ async function loadConfigFile(options, workspace) {
561
561
  } else if (stats.isDirectory()) cwd = resolved;
562
562
  }
563
563
  }
564
- const nativeTS = process.features.typescript || process.versions.bun || process.versions.deno;
564
+ let isNative = false;
565
+ if (!loaded) {
566
+ if (!options.configLoader || options.configLoader === "auto") isNative = !!(process.features.typescript || process.versions.bun || process.versions.deno);
567
+ else if (options.configLoader === "native") isNative = true;
568
+ }
565
569
  let { config, sources } = await loadConfig.async({
566
570
  sources: overrideConfig ? [{
567
571
  files: filePath,
@@ -578,10 +582,7 @@ async function loadConfigFile(options, workspace) {
578
582
  "json",
579
583
  ""
580
584
  ],
581
- parser: loaded || !nativeTS ? "auto" : async (filepath) => {
582
- const mod = await import(pathToFileURL(filepath).href);
583
- return mod.default || mod;
584
- }
585
+ parser: isNative ? nativeImport : "auto"
585
586
  }, {
586
587
  files: "package.json",
587
588
  extensions: [],
@@ -601,10 +602,20 @@ async function loadConfigFile(options, workspace) {
601
602
  file
602
603
  };
603
604
  }
605
+ async function nativeImport(id) {
606
+ const mod = await import(pathToFileURL(id).href).catch((error) => {
607
+ if (error?.message?.includes?.("Cannot find module")) {
608
+ const configError = /* @__PURE__ */ new Error(`Failed to load the config file. Try setting the --config-loader CLI flag to \`unconfig\`.\n\n${error.message}`);
609
+ configError.cause = error;
610
+ throw configError;
611
+ } else throw error;
612
+ });
613
+ return mod.default || mod;
614
+ }
604
615
 
605
616
  //#endregion
606
617
  //#region src/options/index.ts
607
- const debug$4 = debug("tsdown:options");
618
+ const debug$3 = Debug("tsdown:options");
608
619
  const DEFAULT_EXCLUDE_WORKSPACE = [
609
620
  "**/node_modules/**",
610
621
  "**/dist/**",
@@ -612,20 +623,20 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
612
623
  "**/t?(e)mp/**"
613
624
  ];
614
625
  async function resolveOptions(options) {
615
- debug$4("options %O", options);
626
+ debug$3("options %O", options);
616
627
  const { configs: rootConfigs, file } = await loadConfigFile(options);
617
628
  const files = [];
618
629
  if (file) {
619
630
  files.push(file);
620
- debug$4("loaded root config file %s", file);
621
- debug$4("root configs %O", rootConfigs);
622
- } else debug$4("no root config file found");
631
+ debug$3("loaded root config file %s", file);
632
+ debug$3("root configs %O", rootConfigs);
633
+ } else debug$3("no root config file found");
623
634
  const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
624
635
  const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
625
636
  if (workspaceFiles) files.push(...workspaceFiles);
626
637
  return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry).map((config) => resolveConfig(config)));
627
638
  }))).flat();
628
- debug$4("resolved configs %O", configs);
639
+ debug$3("resolved configs %O", configs);
629
640
  return {
630
641
  configs,
631
642
  files
@@ -668,16 +679,16 @@ async function resolveWorkspace(config, options) {
668
679
  const files = [];
669
680
  return {
670
681
  configs: (await Promise.all(packages.map(async (cwd) => {
671
- debug$4("loading workspace config %s", cwd);
682
+ debug$3("loading workspace config %s", cwd);
672
683
  const { configs, file } = await loadConfigFile({
673
684
  ...options,
674
685
  config: workspaceConfig,
675
686
  cwd
676
687
  }, cwd);
677
688
  if (file) {
678
- debug$4("loaded workspace config file %s", file);
689
+ debug$3("loaded workspace config file %s", file);
679
690
  files.push(file);
680
- } else debug$4("no workspace config file found in %s", cwd);
691
+ } else debug$3("no workspace config file found in %s", cwd);
681
692
  return configs.map((config$1) => ({
682
693
  ...normalized,
683
694
  cwd,
@@ -772,7 +783,7 @@ async function mergeUserOptions(defaults, user, args) {
772
783
 
773
784
  //#endregion
774
785
  //#region src/features/external.ts
775
- const debug$3 = debug("tsdown:external");
786
+ const debug$2 = Debug("tsdown:external");
776
787
  function ExternalPlugin(options) {
777
788
  const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
778
789
  return {
@@ -799,7 +810,7 @@ function ExternalPlugin(options) {
799
810
  }
800
811
  if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
801
812
  if (shouldExternal) {
802
- debug$3("External dependency:", id);
813
+ debug$2("External dependency:", id);
803
814
  return {
804
815
  id,
805
816
  external: shouldExternal,
@@ -933,10 +944,15 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
933
944
  return `${basename}${chunk.name.endsWith(".d") ? dtsExtension : jsExtension}`;
934
945
  };
935
946
  }
936
- function resolveChunkAddon(chunkAddon, format) {
947
+ function resolveChunkAddon(chunkAddon, format, dts) {
937
948
  if (!chunkAddon) return;
938
949
  return (chunk) => {
939
- if (typeof chunkAddon === "function") chunkAddon = chunkAddon({ format });
950
+ if (!dts && RE_DTS.test(chunk.fileName)) return "";
951
+ if (typeof chunkAddon === "function") chunkAddon = chunkAddon({
952
+ format,
953
+ fileName: chunk.fileName
954
+ });
955
+ if (typeof chunkAddon === "string") return chunkAddon;
940
956
  switch (true) {
941
957
  case RE_JS.test(chunk.fileName): return chunkAddon?.js || "";
942
958
  case RE_CSS.test(chunk.fileName): return chunkAddon?.css || "";
@@ -955,7 +971,7 @@ function formatBytes(bytes) {
955
971
 
956
972
  //#endregion
957
973
  //#region src/features/report.ts
958
- const debug$2 = debug("tsdown:report");
974
+ const debug$1 = Debug("tsdown:report");
959
975
  const brotliCompressAsync = promisify(brotliCompress);
960
976
  const gzipAsync = promisify(gzip);
961
977
  function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
@@ -996,19 +1012,19 @@ function ReportPlugin(options, logger, cwd, cjsDts, name, isMultiFormat) {
996
1012
  };
997
1013
  }
998
1014
  async function calcSize(options, chunk) {
999
- debug$2(`Calculating size for`, chunk.fileName);
1015
+ debug$1(`Calculating size for`, chunk.fileName);
1000
1016
  const content = chunk.type === "chunk" ? chunk.code : chunk.source;
1001
1017
  const raw = Buffer.byteLength(content, "utf8");
1002
- debug$2("[size]", chunk.fileName, raw);
1018
+ debug$1("[size]", chunk.fileName, raw);
1003
1019
  let gzip$1 = Infinity;
1004
1020
  let brotli = Infinity;
1005
- if (raw > (options.maxCompressSize ?? 1e6)) debug$2(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
1021
+ if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
1006
1022
  else {
1007
1023
  gzip$1 = (await gzipAsync(content)).length;
1008
- debug$2("[gzip]", chunk.fileName, gzip$1);
1024
+ debug$1("[gzip]", chunk.fileName, gzip$1);
1009
1025
  if (options.brotli) {
1010
1026
  brotli = (await brotliCompressAsync(content)).length;
1011
- debug$2("[brotli]", chunk.fileName, brotli);
1027
+ debug$1("[brotli]", chunk.fileName, brotli);
1012
1028
  }
1013
1029
  }
1014
1030
  return {
@@ -1055,7 +1071,7 @@ function getShimsInject(format, platform) {
1055
1071
 
1056
1072
  //#endregion
1057
1073
  //#region src/features/rolldown.ts
1058
- const debug$1 = debug("tsdown:rolldown");
1074
+ const debug = Debug("tsdown:rolldown");
1059
1075
  async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
1060
1076
  const inputOptions = await resolveInputOptions(config, format, cjsDts, isMultiFormat);
1061
1077
  const outputOptions = await resolveOutputOptions(inputOptions, config, format, cjsDts);
@@ -1063,11 +1079,11 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts = false) {
1063
1079
  ...inputOptions,
1064
1080
  output: outputOptions
1065
1081
  };
1066
- debug$1("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
1082
+ debug("rolldown config with format \"%s\" %O", cjsDts ? "cjs dts" : format, rolldownConfig);
1067
1083
  return rolldownConfig;
1068
1084
  }
1069
1085
  async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
1070
- const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault } = config;
1086
+ const { entry, external, plugins: userPlugins, platform, alias, treeshake, dts, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, logger, cjsDefault, banner, footer } = config;
1071
1087
  const plugins = [];
1072
1088
  if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
1073
1089
  if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
@@ -1075,6 +1091,8 @@ async function resolveInputOptions(config, format, cjsDts, isMultiFormat) {
1075
1091
  const { dts: dtsPlugin } = await import("rolldown-plugin-dts");
1076
1092
  const options = {
1077
1093
  tsconfig,
1094
+ banner: resolveChunkAddon(banner, format, true),
1095
+ footer: resolveChunkAddon(footer, format, true),
1078
1096
  ...dts
1079
1097
  };
1080
1098
  if (format === "es") plugins.push(dtsPlugin(options));
@@ -120,8 +120,9 @@ interface ChunkAddonObject {
120
120
  }
121
121
  type ChunkAddonFunction = (ctx: {
122
122
  format: Format;
123
- }) => ChunkAddonObject | undefined;
124
- type ChunkAddon = ChunkAddonObject | ChunkAddonFunction;
123
+ fileName: string;
124
+ }) => ChunkAddonObject | string | undefined;
125
+ type ChunkAddon = ChunkAddonObject | ChunkAddonFunction | string;
125
126
  //#endregion
126
127
  //#region src/utils/logger.d.ts
127
128
  type LogType = "error" | "warn" | "info";
@@ -385,6 +386,11 @@ interface Options {
385
386
  */
386
387
  config?: boolean | string;
387
388
  /**
389
+ * Config loader to use. It can only be set via CLI or API.
390
+ * @default 'auto'
391
+ */
392
+ configLoader?: "auto" | "native" | "unconfig";
393
+ /**
388
394
  * Reuse config from Vite or Vitest (experimental)
389
395
  * @default false
390
396
  */
@@ -467,10 +473,10 @@ interface Options {
467
473
  /**
468
474
  * Options without specifying config file path.
469
475
  */
470
- type UserConfig = Arrayable<Omit<Options, "config" | "filter">>;
476
+ type UserConfig = Arrayable<Omit<Options, "config" | "filter" | "configLoader">>;
471
477
  type UserConfigFn = (cliOptions: Options) => Awaitable<UserConfig>;
472
478
  type NormalizedUserConfig = Exclude<UserConfig, any[]>;
473
- type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "workspace" | "filter" | "silent" | "logLevel" | "failOnWarn" | "customLogger">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "bundle" | "banner" | "footer">, {
479
+ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "workspace" | "filter" | "silent" | "logLevel" | "failOnWarn" | "customLogger" | "configLoader">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "bundle" | "banner" | "footer">, {
474
480
  format: NormalizedFormat[];
475
481
  target?: string[];
476
482
  clean: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -77,7 +77,7 @@
77
77
  "empathic": "^2.0.0",
78
78
  "hookable": "^5.5.3",
79
79
  "rolldown": "latest",
80
- "rolldown-plugin-dts": "^0.16.1",
80
+ "rolldown-plugin-dts": "^0.16.5",
81
81
  "semver": "^7.7.2",
82
82
  "tinyexec": "^1.0.1",
83
83
  "tinyglobby": "^0.2.15",
@@ -104,7 +104,7 @@
104
104
  "typescript": "~5.9.2",
105
105
  "unocss": "^66.5.1",
106
106
  "unplugin-lightningcss": "^0.4.2",
107
- "unplugin-unused": "^0.5.2",
107
+ "unplugin-unused": "^0.5.3",
108
108
  "vite": "npm:rolldown-vite@latest",
109
109
  "vitest": "^3.2.4"
110
110
  },
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.15.0";
3
-
4
- //#endregion
5
- export { version };