tsdown 0.9.7 → 0.9.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,7 +1,4 @@
1
1
  //#region src/config.ts
2
- /**
3
- * Defines the configuration for tsdown.
4
- */
5
2
  function defineConfig(options) {
6
3
  return options;
7
4
  }
@@ -0,0 +1,11 @@
1
+ import { UserConfig, UserConfigFn } from "./options.d-BXikSiux.js";
2
+
3
+ //#region src/config.d.ts
4
+ /**
5
+ * Defines the configuration for tsdown.
6
+ */
7
+ declare function defineConfig(options: UserConfig): UserConfig;
8
+ declare function defineConfig(options: UserConfigFn): UserConfigFn;
9
+
10
+ //#endregion
11
+ export { defineConfig as defineConfig$1 };
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "./options.d-DVjImwcI.js";
2
- import { defineConfig$1 as defineConfig } from "./config.d-jKttq4Nu.js";
1
+ import { UserConfig, UserConfigFn } from "./options.d-BXikSiux.js";
2
+ import { defineConfig$1 as defineConfig } from "./config.d-DI49UQhk.js";
3
3
 
4
- export { defineConfig };
4
+ export { UserConfig, UserConfigFn, defineConfig };
package/dist/config.js CHANGED
@@ -1,3 +1,3 @@
1
- import { defineConfig } from "./config-yiJy1jd0.js";
1
+ import { defineConfig } from "./config-CpIe1Ud_.js";
2
2
 
3
3
  export { defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig } from "./options.d-DVjImwcI.js";
2
- import { defineConfig$1 as defineConfig } from "./config.d-jKttq4Nu.js";
1
+ import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig } from "./options.d-BXikSiux.js";
2
+ import { defineConfig$1 as defineConfig } from "./config.d-DI49UQhk.js";
3
3
  import { ConsolaInstance } from "consola";
4
4
 
5
5
  //#region src/utils/logger.d.ts
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineConfig } from "./config-yiJy1jd0.js";
1
+ import { defineConfig } from "./config-CpIe1Ud_.js";
2
2
  import { ExternalPlugin, ReportPlugin, ShebangPlugin, fsExists, fsRemove, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson } from "./plugins-BcuTSrGE.js";
3
3
  import { debounce, logger, resolveComma, setSilent, toArray } from "./general-C06aMSSY.js";
4
4
  import path from "node:path";
@@ -323,7 +323,7 @@ async function loadConfigFile(options) {
323
323
  }
324
324
  }
325
325
  const nativeTS = process.features.typescript || process.versions.bun || process.versions.deno;
326
- const { config, sources } = await loadConfig.async({
326
+ let { config, sources } = await loadConfig.async({
327
327
  sources: overrideConfig ? [{
328
328
  files: filePath,
329
329
  extensions: []
@@ -352,8 +352,9 @@ async function loadConfigFile(options) {
352
352
  cwd,
353
353
  defaults: {}
354
354
  }).finally(() => loaded = true);
355
- if (sources.length > 0) logger.info(`Using tsdown config: ${underline(sources.join(", "))}`);
356
355
  const file = sources[0];
356
+ if (file) logger.info(`Using tsdown config: ${underline(file)}`);
357
+ if (typeof config === "function") config = await config(options);
357
358
  return {
358
359
  configs: toArray(config),
359
360
  file,
@@ -1,4 +1,4 @@
1
- import { version } from "./package-B5RDOoPA.js";
1
+ import { version } from "./package-BBoT5Sps.js";
2
2
  import process from "node:process";
3
3
  import { readFile, unlink, writeFile } from "node:fs/promises";
4
4
  import consola$1 from "consola";
@@ -90,6 +90,11 @@ type Arrayable<T> = T | T[];
90
90
  type Sourcemap = boolean | "inline" | "hidden";
91
91
  type Format = Exclude<ModuleFormat, "experimental-app">;
92
92
  type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
93
+ interface MinifyOptions {
94
+ mangle?: boolean;
95
+ compress?: boolean;
96
+ removeWhitespace?: boolean;
97
+ }
93
98
  /**
94
99
  * Options for tsdown.
95
100
  */
@@ -110,7 +115,7 @@ interface Options$3 {
110
115
  sourcemap?: Sourcemap;
111
116
  clean?: boolean | string[];
112
117
  /** @default false */
113
- minify?: boolean;
118
+ minify?: boolean | "dce-only" | MinifyOptions;
114
119
  target?: string | string[];
115
120
  define?: Record<string, string>;
116
121
  /** @default false */
@@ -186,6 +191,7 @@ interface Options$3 {
186
191
  * Options without specifying config file path.
187
192
  */
188
193
  type UserConfig = Arrayable<Omit<Options$3, "config">>;
194
+ type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
189
195
  type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks">, {
190
196
  format: NormalizedFormat[]
191
197
  target?: string[]
@@ -197,4 +203,4 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inp
197
203
  }>, "config" | "fromVite">;
198
204
 
199
205
  //#endregion
200
- export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig };
206
+ export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn };
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.9.8";
3
+
4
+ //#endregion
5
+ export { version };
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options.d-DVjImwcI.js";
1
+ import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options.d-BXikSiux.js";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
package/dist/run.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { logger, resolveComma, setSilent, toArray } from "./general-C06aMSSY.js";
3
- import { version } from "./package-B5RDOoPA.js";
3
+ import { version } from "./package-BBoT5Sps.js";
4
4
  import process from "node:process";
5
5
  import { dim } from "ansis";
6
6
  import Debug from "debug";
@@ -19,7 +19,7 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
19
19
  await build$1(flags);
20
20
  });
21
21
  cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
22
- const { migrate } = await import("./migrate-Cr0H4OLK.js");
22
+ const { migrate } = await import("./migrate-fONPr2zj.js");
23
23
  await migrate(args);
24
24
  });
25
25
  async function runCLI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -62,7 +62,7 @@
62
62
  "diff": "^7.0.0",
63
63
  "empathic": "^1.0.0",
64
64
  "hookable": "^5.5.3",
65
- "rolldown": "1.0.0-beta.8-commit.2686eb1",
65
+ "rolldown": "1.0.0-beta.8-commit.151352b",
66
66
  "rolldown-plugin-dts": "^0.8.3",
67
67
  "tinyexec": "^1.0.1",
68
68
  "tinyglobby": "^0.2.13",
@@ -1,10 +0,0 @@
1
- import { UserConfig } from "./options.d-DVjImwcI.js";
2
-
3
- //#region src/config.d.ts
4
- /**
5
- * Defines the configuration for tsdown.
6
- */
7
- declare function defineConfig(options: UserConfig): UserConfig;
8
-
9
- //#endregion
10
- export { defineConfig as defineConfig$1 };
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.9.7";
3
-
4
- //#endregion
5
- export { version };