tsdown 0.12.2 → 0.12.4

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.
@@ -11,7 +11,6 @@ type Overwrite<T, U> = Omit<T, keyof U> & U;
11
11
  type Awaitable<T> = T | Promise<T>;
12
12
  type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
13
13
  type Arrayable<T> = T | T[];
14
-
15
14
  //#endregion
16
15
  //#region src/utils/logger.d.ts
17
16
  declare class Logger {
@@ -24,7 +23,6 @@ declare class Logger {
24
23
  success(...args: any[]): void;
25
24
  }
26
25
  declare const logger: Logger;
27
-
28
26
  //#endregion
29
27
  //#region src/features/hooks.d.ts
30
28
  interface BuildContext {
@@ -56,7 +54,6 @@ interface TsdownHooks {
56
54
  */
57
55
  "build:done": (ctx: BuildContext) => void | Promise<void>;
58
56
  }
59
-
60
57
  //#endregion
61
58
  //#region src/index.d.ts
62
59
  /**
@@ -74,7 +71,6 @@ type TsdownChunks = Partial<Record<NormalizedFormat, Array<OutputChunk | OutputA
74
71
  * @param config Resolved options
75
72
  */
76
73
  declare function buildSingle(config: ResolvedOptions, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
77
-
78
74
  //#endregion
79
75
  //#region src/features/copy.d.ts
80
76
  interface CopyEntry {
@@ -83,11 +79,9 @@ interface CopyEntry {
83
79
  }
84
80
  type CopyOptions = Arrayable<string | CopyEntry>;
85
81
  type CopyOptionsFn = (options: ResolvedOptions) => Awaitable<CopyOptions>;
86
-
87
82
  //#endregion
88
83
  //#region src/utils/package.d.ts
89
84
  type PackageType = "module" | "commonjs" | undefined;
90
-
91
85
  //#endregion
92
86
  //#region src/features/output.d.ts
93
87
  interface OutExtensionContext {
@@ -101,7 +95,6 @@ interface OutExtensionObject {
101
95
  dts?: string;
102
96
  }
103
97
  type OutExtensionFactory = (context: OutExtensionContext) => OutExtensionObject | undefined;
104
-
105
98
  //#endregion
106
99
  //#region src/features/report.d.ts
107
100
  interface ReportOptions {
@@ -119,7 +112,6 @@ interface ReportOptions {
119
112
  maxCompressSize?: number;
120
113
  }
121
114
  declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: boolean, name?: string, isMultiFormat?: boolean): Plugin;
122
-
123
115
  //#endregion
124
116
  //#region src/options/types.d.ts
125
117
  type Sourcemap = boolean | "inline" | "hidden";
@@ -166,12 +158,25 @@ interface ExportsOptions {
166
158
  */
167
159
  interface Options$3 {
168
160
  /// build options
161
+ /**
162
+ * Defaults to `'src/index.ts'` if it exists.
163
+ */
169
164
  entry?: InputOption;
170
165
  external?: ExternalOption;
171
166
  noExternal?: Arrayable<string | RegExp> | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
172
167
  alias?: Record<string, string>;
173
168
  tsconfig?: string | boolean;
174
- /** @default 'node' */
169
+ /**
170
+ * Specifies the target runtime platform for the build.
171
+ *
172
+ * - `node`: Node.js and compatible runtimes (e.g., Deno, Bun).
173
+ * For CJS format, this is always set to `node` and cannot be changed.
174
+ * - `neutral`: A platform-agnostic target with no specific runtime assumptions.
175
+ * - `browser`: Web browsers.
176
+ *
177
+ * @default 'node'
178
+ * @see https://tsdown.dev/options/platform
179
+ */
175
180
  platform?: "node" | "neutral" | "browser";
176
181
  inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat) => Awaitable<InputOptions | void | null>);
177
182
  /// output options
@@ -382,12 +387,12 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
382
387
  tsconfig: string | false;
383
388
  pkg?: PackageJson;
384
389
  exports: false | ExportsOptions;
385
- }>, "config" | "fromVite">; //#endregion
390
+ }>, "config" | "fromVite">;
391
+ //#endregion
386
392
  //#region src/config.d.ts
387
393
  /**
388
394
  * Defines the configuration for tsdown.
389
395
  */
390
396
  declare function defineConfig(options: UserConfig | UserConfigFn): UserConfig | UserConfigFn;
391
-
392
397
  //#endregion
393
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 };
package/dist/config.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { UserConfig, UserConfigFn, defineConfig$1 as defineConfig } from "./config-DQmC8Ss1.js";
1
+ import { UserConfig, UserConfigFn, defineConfig$1 as defineConfig } from "./config-DcChLYA_.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-DQmC8Ss1.js";
1
+ import { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig$1 as defineConfig, logger, pkgRoot } from "./config-DcChLYA_.js";
2
2
  export { BuildContext, Options, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, pkgRoot };
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-D-fqvWYC.js";
2
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-BK9K-20W.js";
3
3
  import { debounce, generateColor, logger$1 as logger, prettyName, resolveComma, resolveRegex, slash, toArray } from "./logger-CS4H_tpu.js";
4
4
  import path from "node:path";
5
5
  import process from "node:process";
@@ -484,7 +484,11 @@ async function watchBuild(options, configFiles, rebuild, restart) {
484
484
  //#region src/features/entry.ts
485
485
  async function resolveEntry(entry, cwd, name) {
486
486
  const nameLabel = name ? `[${name}] ` : "";
487
- if (!entry || Object.keys(entry).length === 0) throw new Error(`${nameLabel}No input files, try "tsdown <your-file>" instead`);
487
+ if (!entry || Object.keys(entry).length === 0) {
488
+ const defaultEntry = path.resolve(cwd, "src/index.ts");
489
+ if (await fsExists(defaultEntry)) entry = { index: defaultEntry };
490
+ else throw new Error(`${nameLabel}No input files, try "tsdown <your-file>" or create src/index.ts`);
491
+ }
488
492
  const entryMap = await toObjectEntry(entry, cwd);
489
493
  const entries = Object.values(entryMap);
490
494
  if (entries.length === 0) throw new Error(`${nameLabel}Cannot find entry: ${JSON.stringify(entry)}`);
@@ -900,7 +904,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
900
904
  tsconfigFilename: tsconfig || void 0
901
905
  },
902
906
  treeshake,
903
- platform,
907
+ platform: cjsDts || format === "cjs" ? "node" : platform,
904
908
  define: {
905
909
  ...define,
906
910
  ...Object.keys(env).reduce((acc, key) => {
@@ -910,6 +914,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
910
914
  return acc;
911
915
  }, Object.create(null))
912
916
  },
917
+ transform: { target },
913
918
  plugins,
914
919
  inject: { ...shims && !cjsDts && getShimsInject(format, platform) },
915
920
  moduleTypes: loader
@@ -920,7 +925,6 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
920
925
  name: config.globalName,
921
926
  sourcemap,
922
927
  dir: outDir,
923
- target,
924
928
  minify: !cjsDts && minify,
925
929
  entryFileNames,
926
930
  chunkFileNames,
@@ -1,5 +1,5 @@
1
1
  import { logger$1 as logger } from "./logger-CS4H_tpu.js";
2
- import { version } from "./package-BnhpFGoQ.js";
2
+ import { version } from "./package-DHv574be.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.4";
3
+
4
+ //#endregion
5
+ export { version };
@@ -210,4 +210,4 @@ function ShebangPlugin(cwd, name, isMultiFormat) {
210
210
  }
211
211
 
212
212
  //#endregion
213
- export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor };
213
+ export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsExists, fsRemove, fsStat, lowestCommonAncestor };
package/dist/plugins.d.ts CHANGED
@@ -1,17 +1,15 @@
1
- import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./config-DQmC8Ss1.js";
1
+ import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./config-DcChLYA_.js";
2
2
  import { Plugin } from "rolldown";
3
3
  import { PackageJson } from "pkg-types";
4
4
 
5
5
  //#region src/features/external.d.ts
6
6
  declare function ExternalPlugin(options: ResolvedOptions): Plugin;
7
-
8
- //#endregion
9
- //#region src/features/shebang.d.ts
10
7
  /*
11
8
  * Production deps should be excluded from the bundle
12
9
  */
10
+ //#endregion
11
+ //#region src/features/shebang.d.ts
13
12
  declare function ShebangPlugin(cwd: string, name?: string, isMultiFormat?: boolean): Plugin;
14
-
15
13
  //#endregion
16
14
  //#region src/features/node-protocol.d.ts
17
15
  /**
@@ -19,6 +17,5 @@ declare function ShebangPlugin(cwd: string, name?: string, isMultiFormat?: boole
19
17
  * @see https://nodejs.org/api/esm.html#node-imports
20
18
  */
21
19
  declare function NodeProtocolPlugin(): Plugin;
22
-
23
20
  //#endregion
24
21
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/plugins.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-D-fqvWYC.js";
1
+ import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-BK9K-20W.js";
2
2
  import "./logger-CS4H_tpu.js";
3
3
 
4
4
  export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
package/dist/run.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { logger$1 as logger, resolveComma, toArray } from "./logger-CS4H_tpu.js";
3
- import { version } from "./package-BnhpFGoQ.js";
3
+ import { version } from "./package-DHv574be.js";
4
4
  import module from "node:module";
5
5
  import process from "node:process";
6
6
  import { dim } from "ansis";
@@ -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-DRENvqVO.js");
25
+ const { migrate } = await import("./migrate-BD_TCCI8.js");
26
26
  await migrate(args);
27
27
  });
28
28
  async function runCLI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "The Elegant Bundler for Libraries",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -67,14 +67,14 @@
67
67
  "cac": "^6.7.14",
68
68
  "chokidar": "^4.0.3",
69
69
  "debug": "^4.4.1",
70
- "diff": "^8.0.1",
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.51df2b7",
74
- "rolldown-plugin-dts": "^0.13.4",
73
+ "rolldown": "1.0.0-beta.9-commit.273d50e",
74
+ "rolldown-plugin-dts": "^0.13.5",
75
75
  "semver": "^7.7.2",
76
76
  "tinyexec": "^1.0.1",
77
- "tinyglobby": "^0.2.13",
77
+ "tinyglobby": "^0.2.14",
78
78
  "unconfig": "^7.3.2"
79
79
  },
80
80
  "devDependencies": {
@@ -92,7 +92,7 @@
92
92
  "pkg-types": "^2.1.0",
93
93
  "prettier": "^3.5.3",
94
94
  "publint": "^0.3.12",
95
- "typedoc": "^0.28.4",
95
+ "typedoc": "^0.28.5",
96
96
  "typedoc-plugin-markdown": "^4.6.3",
97
97
  "typescript": "~5.8.3",
98
98
  "unocss": "^66.1.2",
@@ -101,9 +101,9 @@
101
101
  "vite": "^6.3.5",
102
102
  "vitepress": "^1.6.3",
103
103
  "vitepress-plugin-group-icons": "^1.5.5",
104
- "vitepress-plugin-llms": "^1.3.2",
104
+ "vitepress-plugin-llms": "^1.3.4",
105
105
  "vitest": "^3.1.4",
106
- "vue": "^3.5.14"
106
+ "vue": "^3.5.15"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=18.0.0"
@@ -1,5 +0,0 @@
1
- //#region package.json
2
- var version = "0.12.2";
3
-
4
- //#endregion
5
- export { version };