tsdown 0.2.15 → 0.2.17

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.
@@ -18,7 +18,7 @@ function ExternalPlugin(pkg, platform) {
18
18
  };
19
19
  }
20
20
  function getProductionDeps(pkg) {
21
- return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {}),]);
21
+ return new Set([...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]);
22
22
  }
23
23
 
24
24
  //#endregion
@@ -1,2 +1,2 @@
1
- import type { Options } from "../options";
2
- export declare function resolveEntry(entry: Options["entry"]): Promise<string[] | Record<string, string>>;
1
+ import type { Options } from '../options';
2
+ export declare function resolveEntry(entry: Options['entry']): Promise<string[] | Record<string, string>>;
@@ -1,6 +1,6 @@
1
- import type { ResolvedOptions } from "../options";
2
- import type { PackageJson } from "pkg-types";
3
- import type { InputOptions, Plugin } from "rolldown";
4
- export type External = InputOptions["external"];
5
- export declare function ExternalPlugin(pkg: PackageJson | undefined, platform: ResolvedOptions["platform"]): Plugin;
1
+ import type { ResolvedOptions } from '../options';
2
+ import type { PackageJson } from 'pkg-types';
3
+ import type { InputOptions, Plugin } from 'rolldown';
4
+ export type External = InputOptions['external'];
5
+ export declare function ExternalPlugin(pkg: PackageJson | undefined, platform: ResolvedOptions['platform']): Plugin;
6
6
  export declare function getProductionDeps(pkg: PackageJson): Set<string>;
@@ -1,2 +1,2 @@
1
- import type { Format } from "../options";
2
- export declare function resolveOutputExtension(pkg: any, format: Format): "mjs" | "cjs" | "js";
1
+ import type { Format } from '../options';
2
+ export declare function resolveOutputExtension(pkg: any, format: Format): 'mjs' | 'cjs' | 'js';
@@ -1,2 +1,2 @@
1
- import type { ResolvedOptions } from "../options";
1
+ import type { ResolvedOptions } from '../options';
2
2
  export declare function watchBuild(options: ResolvedOptions, rebuild: () => void): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,12 @@
1
- import { type Options, type OptionsWithoutConfig } from "./options";
2
- import { logger } from "./utils/logger";
3
- export declare function build(userOptions?: Omit<Options, "silent">): Promise<void>;
1
+ import { type Options, type OptionsWithoutConfig } from './options';
2
+ import { logger } from './utils/logger';
3
+ /**
4
+ * Build with tsdown.
5
+ */
6
+ export declare function build(userOptions?: Omit<Options, 'silent'>): Promise<void>;
7
+ /**
8
+ * Defines the configuration for tsdown.
9
+ */
4
10
  export declare function defineConfig(options: OptionsWithoutConfig): OptionsWithoutConfig;
5
11
  export { logger };
6
12
  export type { Options, OptionsWithoutConfig };
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  import { logger } from "./logger-e0Fr5WMR.js";
2
- import { ExternalPlugin } from "./external-NHKSS1J8.js";
2
+ import { ExternalPlugin } from "./external-m3ERo7i1.js";
3
3
  import { default as process, default as process$1, default as process$2 } from "node:process";
4
4
  import { rolldown } from "rolldown";
5
5
  import { IsolatedDecl } from "unplugin-isolated-decl";
6
6
  import { Unused } from "unplugin-unused";
7
7
  import { access, readdir, rm, stat } from "node:fs/promises";
8
- import { default as path, default as path$1, default as path$2, default as path$3 } from "node:path";
8
+ import { default as path, default as path$1, default as path$2 } from "node:path";
9
9
  import { glob, glob as glob$1 } from "tinyglobby";
10
10
  import { readPackageJSON } from "pkg-types";
11
11
  import { default as pc, default as pc$1 } from "picocolors";
12
12
  import { loadConfig } from "unconfig";
13
13
 
14
14
  //#region src/utils/fs.ts
15
- function fsExists(path$4) {
16
- return access(path$4).then(() => true, () => false);
15
+ function fsExists(path$3) {
16
+ return access(path$3).then(() => true, () => false);
17
17
  }
18
18
 
19
19
  //#endregion
20
20
  //#region src/features/clean.ts
21
21
  async function cleanOutDir(cwd, patterns) {
22
22
  const files = [];
23
- if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$3.resolve(cwd, file)));
23
+ if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$2.resolve(cwd, file)));
24
24
  if (patterns.length) {
25
25
  files.push(...await glob$1(patterns, {
26
26
  cwd,
@@ -39,7 +39,7 @@ async function cleanOutDir(cwd, patterns) {
39
39
  //#endregion
40
40
  //#region src/utils/package.ts
41
41
  async function readPackageJson(dir) {
42
- const packageJsonPath = path$2.join(dir, "package.json");
42
+ const packageJsonPath = path$1.join(dir, "package.json");
43
43
  const exists = await fsExists(packageJsonPath);
44
44
  if (!exists) return;
45
45
  return readPackageJSON(packageJsonPath);
@@ -101,12 +101,14 @@ async function watchBuild(options, rebuild) {
101
101
  const { watch } = await import("chokidar");
102
102
  const debouncedRebuild = debounce(rebuild, 100);
103
103
  const files = typeof options.watch === "boolean" ? process$2.cwd() : options.watch;
104
- const ignored = ["**/{.git,node_modules}/**", path$1.resolve(options.outDir)];
105
104
  logger.info(`Watching for changes in ${toArray(files).join(", ")}`);
106
105
  const watcher = watch(files, {
107
106
  ignoreInitial: true,
108
107
  ignorePermissionErrors: true,
109
- ignored
108
+ ignored: (id) => {
109
+ if (id.includes("/.git/") || id.includes("/node_modules/")) return true;
110
+ return id.startsWith(options.outDir);
111
+ }
110
112
  });
111
113
  watcher.on("all", (type, file) => {
112
114
  logger.info(`Change detected: ${type} ${file}`);
@@ -159,7 +161,7 @@ async function normalizeOptions(options) {
159
161
  plugins,
160
162
  external,
161
163
  format,
162
- outDir,
164
+ outDir: path.resolve(outDir),
163
165
  clean,
164
166
  silent,
165
167
  alias,
@@ -196,12 +198,21 @@ async function loadConfigFile(options) {
196
198
  extensions: []
197
199
  }] : [{
198
200
  files: "tsdown.config",
199
- extensions: ["ts", "mts", "cts", "js", "mjs", "cjs", "json", ""]
201
+ extensions: [
202
+ "ts",
203
+ "mts",
204
+ "cts",
205
+ "js",
206
+ "mjs",
207
+ "cjs",
208
+ "json",
209
+ ""
210
+ ]
200
211
  }, {
201
212
  files: "package.json",
202
213
  extensions: [],
203
214
  rewrite: (config$1) => config$1?.tsdown
204
- },],
215
+ }],
205
216
  cwd,
206
217
  defaults: {}
207
218
  });
@@ -218,25 +229,28 @@ async function build(userOptions = {}) {
218
229
  const { entry, external, plugins, outDir, format, clean, platform, alias, treeshake, sourcemap, dts, minify, watch, unused } = resolved;
219
230
  if (clean) await cleanOutDir(outDir, clean);
220
231
  const pkg = await readPackageJson(process.cwd());
221
- let startTime = performance.now();
222
- const inputOptions = {
223
- input: entry,
224
- external,
225
- resolve: { alias },
226
- treeshake,
227
- platform,
228
- plugins: [ExternalPlugin(pkg, platform), dts && IsolatedDecl.rolldown(dts === true ? {} : dts), unused && Unused.rolldown(unused === true ? {} : unused), ...plugins,].filter((plugin) => !!plugin),
229
- ...resolved.inputOptions
230
- };
231
- const build$1 = await rolldown(inputOptions);
232
- await writeBundle(true);
232
+ let startTime;
233
+ await rebuild(true);
233
234
  if (watch) {
234
- await watchBuild(resolved, writeBundle);
235
- } else {
236
- await build$1.close();
235
+ await watchBuild(resolved, rebuild);
237
236
  }
238
- async function writeBundle(first) {
239
- if (!first) startTime = performance.now();
237
+ async function rebuild(first) {
238
+ startTime = performance.now();
239
+ const inputOptions = {
240
+ input: entry,
241
+ external,
242
+ resolve: { alias },
243
+ treeshake,
244
+ platform,
245
+ plugins: [
246
+ ExternalPlugin(pkg, platform),
247
+ dts && IsolatedDecl.rolldown(dts === true ? {} : dts),
248
+ unused && Unused.rolldown(unused === true ? {} : unused),
249
+ ...plugins
250
+ ].filter((plugin) => !!plugin),
251
+ ...resolved.inputOptions
252
+ };
253
+ const build$1 = await rolldown(inputOptions);
240
254
  await Promise.all(format.map(async (format$1) => {
241
255
  const extension = resolveOutputExtension(pkg, format$1);
242
256
  const outputOptions = {
@@ -253,6 +267,7 @@ async function build(userOptions = {}) {
253
267
  ...userOutputOptions
254
268
  });
255
269
  }));
270
+ await build$1.close();
256
271
  logger.success(`${first ? "Build" : "Rebuild"} complete in ${Math.round(performance.now() - startTime)}ms`);
257
272
  }
258
273
  }
package/dist/options.d.ts CHANGED
@@ -1,33 +1,48 @@
1
- import type { External } from "./features/external";
2
- import type { MarkPartial, MaybePromise, Overwrite } from "./utils/types";
3
- import type { InputOptions, OutputOptions } from "rolldown";
4
- import type { Options as IsolatedDeclOptions } from "unplugin-isolated-decl";
5
- import type { Options as UnusedOptions } from "unplugin-unused";
6
- export type Format = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife";
7
- export type Sourcemap = boolean | "inline" | "hidden";
1
+ import type { External } from './features/external';
2
+ import type { MarkPartial, MaybePromise, Overwrite } from './utils/types';
3
+ import type { InputOptions, OutputOptions } from 'rolldown';
4
+ import type { Options as IsolatedDeclOptions } from 'unplugin-isolated-decl';
5
+ import type { Options as UnusedOptions } from 'unplugin-unused';
6
+ export type Format = 'es' | 'cjs' | 'esm' | 'module' | 'commonjs' | 'iife';
7
+ export type Sourcemap = boolean | 'inline' | 'hidden';
8
+ /**
9
+ * Options for tsdown.
10
+ */
8
11
  export interface Options {
9
- entry?: InputOptions["input"];
10
- format?: Format | Format[];
11
- plugins?: InputOptions["plugins"];
12
- external?: External;
13
- outDir?: string;
14
- clean?: boolean | string[];
15
- silent?: boolean;
16
- config?: boolean | string;
17
- sourcemap?: Sourcemap;
18
- alias?: Record<string, string>;
19
- treeshake?: boolean;
20
- minify?: boolean;
21
- platform?: "node" | "neutral" | "browser";
22
- dts?: boolean | IsolatedDeclOptions;
23
- unused?: boolean | UnusedOptions;
24
- watch?: boolean | string | string[];
25
- inputOptions?: InputOptions;
26
- outputOptions?: OutputOptions | ((options: OutputOptions, format: Format) => MaybePromise<OutputOptions | void | null>);
12
+ entry?: InputOptions['input'];
13
+ format?: Format | Format[];
14
+ plugins?: InputOptions['plugins'];
15
+ external?: External;
16
+ outDir?: string;
17
+ clean?: boolean | string[];
18
+ silent?: boolean;
19
+ config?: boolean | string;
20
+ sourcemap?: Sourcemap;
21
+ alias?: Record<string, string>;
22
+ /** @default true */
23
+ treeshake?: boolean;
24
+ /** @default false */
25
+ minify?: boolean;
26
+ /** @default 'node' */
27
+ platform?: 'node' | 'neutral' | 'browser';
28
+ /**
29
+ * Enable dts generation with `isolatedDeclarations` (experimental)
30
+ */
31
+ dts?: boolean | IsolatedDeclOptions;
32
+ /**
33
+ * Enable unused dependencies check with `unplugin-unused` (experimental)
34
+ */
35
+ unused?: boolean | UnusedOptions;
36
+ watch?: boolean | string | string[];
37
+ inputOptions?: InputOptions;
38
+ outputOptions?: OutputOptions | ((options: OutputOptions, format: Format) => MaybePromise<OutputOptions | void | null>);
27
39
  }
28
- export type OptionsWithoutConfig = Omit<Options, "config">;
29
- export type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "inputOptions" | "outputOptions" | "minify" | "alias" | "external">, {
30
- format: Format[];
31
- clean: string[] | false;
32
- }>, "config">;
40
+ /**
41
+ * Options without specifying config file path.
42
+ */
43
+ export type OptionsWithoutConfig = Omit<Options, 'config'>;
44
+ export type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, 'inputOptions' | 'outputOptions' | 'minify' | 'alias' | 'external'>, {
45
+ format: Format[];
46
+ clean: string[] | false;
47
+ }>, 'config'>;
33
48
  export declare function normalizeOptions(options: Options): Promise<ResolvedOptions>;
package/dist/plugins.d.ts CHANGED
@@ -1 +1 @@
1
- export { ExternalPlugin } from "./features/external";
1
+ export { ExternalPlugin } from './features/external';
package/dist/plugins.js CHANGED
@@ -1,3 +1,3 @@
1
- import { ExternalPlugin } from "./external-NHKSS1J8.js";
1
+ import { ExternalPlugin } from "./external-m3ERo7i1.js";
2
2
 
3
3
  export { ExternalPlugin };
package/dist/run.js CHANGED
@@ -5,7 +5,7 @@ import { default as pc } from "picocolors";
5
5
  import { cac } from "cac";
6
6
 
7
7
  //#region package.json
8
- const version = "0.2.15";
8
+ const version = "0.2.17";
9
9
 
10
10
  //#endregion
11
11
  //#region src/cli.ts
@@ -1,2 +1,5 @@
1
- import { type ConsolaInstance } from "consola";
1
+ import { type ConsolaInstance } from 'consola';
2
+ /**
3
+ * Logger instance
4
+ */
2
5
  export declare const logger: ConsolaInstance;
@@ -1,3 +1,3 @@
1
- import { type PackageJson } from "pkg-types";
1
+ import { type PackageJson } from 'pkg-types';
2
2
  export declare function readPackageJson(dir: string): Promise<PackageJson | undefined>;
3
- export declare function getPackageType(pkg: PackageJson | undefined): "module" | "commonjs";
3
+ export declare function getPackageType(pkg: PackageJson | undefined): 'module' | 'commonjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdown",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "description": "An even faster bundler powered by Rolldown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,29 +40,29 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "cac": "^6.7.14",
43
- "chokidar": "^3.6.0",
43
+ "chokidar": "^4.0.1",
44
44
  "consola": "^3.2.3",
45
45
  "picocolors": "^1.1.0",
46
46
  "pkg-types": "^1.2.0",
47
47
  "rolldown": "nightly",
48
48
  "tinyglobby": "^0.2.6",
49
- "unconfig": "^0.5.5",
50
- "unplugin-isolated-decl": "^0.4.7",
49
+ "unconfig": "^0.6.0",
50
+ "unplugin-isolated-decl": "^0.6.5",
51
51
  "unplugin-unused": "^0.2.3"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@sxzz/eslint-config": "^4.2.0",
55
55
  "@sxzz/prettier-config": "^2.0.2",
56
- "@types/node": "^22.5.4",
57
- "bumpp": "^9.5.2",
58
- "eslint": "^9.10.0",
59
- "execa": "^9.3.1",
56
+ "@types/node": "^22.7.4",
57
+ "bumpp": "^9.6.1",
58
+ "eslint": "^9.11.1",
59
+ "execa": "^9.4.0",
60
60
  "fdir": "^6.3.0",
61
61
  "prettier": "^3.3.3",
62
- "tsup": "^8.2.4",
63
- "tsx": "^4.19.0",
64
- "typescript": "~5.5.4",
65
- "vitest": "^2.0.5"
62
+ "tsup": "^8.3.0",
63
+ "tsx": "^4.19.1",
64
+ "typescript": "~5.6.2",
65
+ "vitest": "^2.1.1"
66
66
  },
67
67
  "engines": {
68
68
  "node": ">=18.0.0"