tsdown 0.6.1 → 0.6.3
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.
- package/README.md +19 -5
- package/dist/config.d.ts +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +100 -48
- package/dist/{migrate-DoLTWYYz.js → migrate-DjS7871z.js} +1 -1
- package/dist/{options.d-CXI-XGhn.d.ts → options.d-B6hAHDaA.d.ts} +32 -27
- package/dist/package-COmVwFsw.js +6 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/run.js +3 -3
- package/package.json +10 -9
- package/dist/package-DE4z_cPY.js +0 -6
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# tsdown [](https://npmjs.com/package/tsdown) [](https://github.com/sxzz/tsdown/actions/workflows/unit-test.yml) [](https://jsr.io/@sxzz/tsdown)
|
|
2
2
|
|
|
3
|
-
An even faster bundler powered by [Rolldown](https://github.com/rolldown/rolldown).
|
|
3
|
+
⚡️ An even faster bundler powered by [Rolldown](https://github.com/rolldown/rolldown).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Blazing fast**: Build and generate `.d.ts` powered by Oxc and Rolldown, incredibly fast!
|
|
8
|
+
- ♻️ **Powerful ecosystem**: Support Rollup / Rolldown / Vite / unplugin plugins.
|
|
9
|
+
- 📦 **Out-of-box**: Support reusing configurations from Vite or Vitest.
|
|
10
|
+
- 🔄 **Seamless migration**: Compatible with tsup's main options and features, ensuring a smooth transition.
|
|
9
11
|
|
|
10
12
|
## Install
|
|
11
13
|
|
|
@@ -13,6 +15,18 @@ An even faster bundler powered by [Rolldown](https://github.com/rolldown/rolldow
|
|
|
13
15
|
npm i tsdown
|
|
14
16
|
```
|
|
15
17
|
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// tsdown.config.ts
|
|
22
|
+
import { defineConfig } from 'tsdown'
|
|
23
|
+
|
|
24
|
+
export default defineConfig({
|
|
25
|
+
entry: ['./src'],
|
|
26
|
+
// ...
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
16
30
|
## Credits
|
|
17
31
|
|
|
18
32
|
This project also partially contains code derived or copied from [tsup](https://github.com/egoist/tsup).
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as UserConfig } from './options.d-B6hAHDaA.js';
|
|
2
2
|
import 'publint';
|
|
3
3
|
import 'rolldown';
|
|
4
4
|
import 'unplugin-isolated-decl';
|
|
@@ -7,6 +7,6 @@ import 'unplugin-unused';
|
|
|
7
7
|
/**
|
|
8
8
|
* Defines the configuration for tsdown.
|
|
9
9
|
*/
|
|
10
|
-
declare function defineConfig(options:
|
|
10
|
+
declare function defineConfig(options: UserConfig): UserConfig;
|
|
11
11
|
|
|
12
12
|
export { defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Options, R as ResolvedOptions } from './options.d-
|
|
2
|
-
export {
|
|
1
|
+
import { O as Options, R as ResolvedOptions } from './options.d-B6hAHDaA.js';
|
|
2
|
+
export { U as UserConfig } from './options.d-B6hAHDaA.js';
|
|
3
3
|
import { ConsolaInstance } from 'consola';
|
|
4
4
|
export { defineConfig } from './config.js';
|
|
5
5
|
import 'publint';
|
|
@@ -20,8 +20,8 @@ declare const pkgRoot: string;
|
|
|
20
20
|
/**
|
|
21
21
|
* Build a single configuration, without watch and shortcuts features.
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
23
|
+
* @param config Resolved options
|
|
24
24
|
*/
|
|
25
|
-
declare function buildSingle(
|
|
25
|
+
declare function buildSingle(config: ResolvedOptions): Promise<(() => Promise<void>) | undefined>;
|
|
26
26
|
|
|
27
27
|
export { Options, build, buildSingle, logger, pkgRoot };
|
package/dist/index.js
CHANGED
|
@@ -106,6 +106,18 @@ function getPackageType(pkg) {
|
|
|
106
106
|
}
|
|
107
107
|
return "commonjs";
|
|
108
108
|
}
|
|
109
|
+
function normalizeFormat(format) {
|
|
110
|
+
return toArray(format, "es").map((format$1) => {
|
|
111
|
+
switch (format$1) {
|
|
112
|
+
case "es":
|
|
113
|
+
case "esm":
|
|
114
|
+
case "module": return "es";
|
|
115
|
+
case "cjs":
|
|
116
|
+
case "commonjs": return "cjs";
|
|
117
|
+
default: return format$1;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
109
121
|
|
|
110
122
|
//#endregion
|
|
111
123
|
//#region src/features/output.ts
|
|
@@ -220,10 +232,11 @@ async function watchBuild(options, configFile, rebuild, restart) {
|
|
|
220
232
|
const watcher = watch(files, {
|
|
221
233
|
ignoreInitial: true,
|
|
222
234
|
ignorePermissionErrors: true,
|
|
223
|
-
ignored:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
235
|
+
ignored: [
|
|
236
|
+
/[\\/]\.git[\\/]/,
|
|
237
|
+
/[\\/]node_modules[\\/]/,
|
|
238
|
+
options.outDir
|
|
239
|
+
]
|
|
227
240
|
});
|
|
228
241
|
watcher.on("all", (type, file) => {
|
|
229
242
|
if (endsWithPackageJson.test(file) || configFile === file) {
|
|
@@ -261,18 +274,27 @@ async function toObjectEntry(entry) {
|
|
|
261
274
|
//#endregion
|
|
262
275
|
//#region src/options.ts
|
|
263
276
|
async function resolveOptions(options) {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
|
|
277
|
+
const { configs: userConfigs, file, cwd } = await loadConfigFile(options);
|
|
278
|
+
if (userConfigs.length === 0) userConfigs.push({});
|
|
279
|
+
const configs = await Promise.all(userConfigs.map(async (subConfig) => {
|
|
267
280
|
const subOptions = {
|
|
268
281
|
...subConfig,
|
|
269
282
|
...options
|
|
270
283
|
};
|
|
271
|
-
let { entry, format = ["es"], plugins = [], clean = false, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts = false, bundleDts: bundleDts$1 = true, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false } = subOptions;
|
|
284
|
+
let { entry, format = ["es"], plugins = [], clean = false, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts = false, bundleDts: bundleDts$1 = true, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias } = subOptions;
|
|
272
285
|
entry = await resolveEntry(entry);
|
|
273
286
|
if (clean === true) clean = [];
|
|
274
287
|
if (publint$1 === true) publint$1 = {};
|
|
275
|
-
|
|
288
|
+
if (fromVite) {
|
|
289
|
+
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd);
|
|
290
|
+
if (viteUserConfig) {
|
|
291
|
+
if (Array.isArray(alias)) throw new TypeError("Unsupported resolve.alias in Vite config. Use object instead of array");
|
|
292
|
+
if (viteUserConfig.plugins) plugins = [viteUserConfig.plugins, plugins];
|
|
293
|
+
const viteAlias = viteUserConfig.resolve?.alias;
|
|
294
|
+
if (viteAlias && !Array.isArray(viteAlias)) alias = viteAlias;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const config = {
|
|
276
298
|
...subOptions,
|
|
277
299
|
entry,
|
|
278
300
|
plugins,
|
|
@@ -289,35 +311,34 @@ async function resolveOptions(options) {
|
|
|
289
311
|
watch,
|
|
290
312
|
shims,
|
|
291
313
|
skipNodeModulesBundle,
|
|
292
|
-
publint: publint$1
|
|
314
|
+
publint: publint$1,
|
|
315
|
+
alias
|
|
293
316
|
};
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
case "esm":
|
|
301
|
-
case "module": return "es";
|
|
302
|
-
case "cjs":
|
|
303
|
-
case "commonjs": return "cjs";
|
|
304
|
-
default: return format$1;
|
|
305
|
-
}
|
|
306
|
-
});
|
|
317
|
+
return config;
|
|
318
|
+
}));
|
|
319
|
+
return {
|
|
320
|
+
configs,
|
|
321
|
+
file
|
|
322
|
+
};
|
|
307
323
|
}
|
|
308
324
|
async function loadConfigFile(options) {
|
|
309
|
-
let { config: filePath } = options;
|
|
310
|
-
if (filePath === false) return [[]];
|
|
311
325
|
let cwd = process.cwd();
|
|
312
326
|
let overrideConfig = false;
|
|
313
|
-
let
|
|
314
|
-
if (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
327
|
+
let { config: filePath } = options;
|
|
328
|
+
if (filePath === false) return {
|
|
329
|
+
configs: [],
|
|
330
|
+
cwd
|
|
331
|
+
};
|
|
332
|
+
if (typeof filePath === "string") {
|
|
333
|
+
const stats = await stat(filePath).catch(() => null);
|
|
334
|
+
if (stats) {
|
|
335
|
+
const resolved = path.resolve(filePath);
|
|
336
|
+
if (stats.isFile()) {
|
|
337
|
+
overrideConfig = true;
|
|
338
|
+
filePath = resolved;
|
|
339
|
+
cwd = path.dirname(filePath);
|
|
340
|
+
} else if (stats.isDirectory()) cwd = resolved;
|
|
341
|
+
}
|
|
321
342
|
}
|
|
322
343
|
const { config, sources } = await loadConfig({
|
|
323
344
|
sources: overrideConfig ? [{
|
|
@@ -345,7 +366,38 @@ async function loadConfigFile(options) {
|
|
|
345
366
|
});
|
|
346
367
|
if (sources.length > 0) logger.info(`Using tsdown config: ${underline(sources.join(", "))}`);
|
|
347
368
|
const file = sources[0];
|
|
348
|
-
return
|
|
369
|
+
return {
|
|
370
|
+
configs: toArray(config),
|
|
371
|
+
file,
|
|
372
|
+
cwd
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
async function loadViteConfig(prefix, cwd) {
|
|
376
|
+
const { config, sources: [source] } = await loadConfig({
|
|
377
|
+
sources: [{
|
|
378
|
+
files: `${prefix}.config`,
|
|
379
|
+
extensions: [
|
|
380
|
+
"ts",
|
|
381
|
+
"mts",
|
|
382
|
+
"cts",
|
|
383
|
+
"js",
|
|
384
|
+
"mjs",
|
|
385
|
+
"cjs",
|
|
386
|
+
"json",
|
|
387
|
+
""
|
|
388
|
+
]
|
|
389
|
+
}],
|
|
390
|
+
cwd,
|
|
391
|
+
defaults: {}
|
|
392
|
+
});
|
|
393
|
+
if (!source) return;
|
|
394
|
+
logger.info(`Using Vite config: ${underline(source)}`);
|
|
395
|
+
const resolved = await config;
|
|
396
|
+
if (typeof resolved === "function") return resolved({
|
|
397
|
+
command: "build",
|
|
398
|
+
mode: "production"
|
|
399
|
+
});
|
|
400
|
+
return resolved;
|
|
349
401
|
}
|
|
350
402
|
async function mergeUserOptions(defaults, user, args) {
|
|
351
403
|
const userOutputOptions = typeof user === "function" ? await user(defaults, ...args) : user;
|
|
@@ -358,17 +410,17 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
358
410
|
//#endregion
|
|
359
411
|
//#region src/index.ts
|
|
360
412
|
async function build(userOptions = {}) {
|
|
361
|
-
typeof userOptions.silent === "boolean"
|
|
413
|
+
if (typeof userOptions.silent === "boolean") setSilent(userOptions.silent);
|
|
362
414
|
debug("Loading config");
|
|
363
|
-
const
|
|
415
|
+
const { configs, file: configFile } = await resolveOptions(userOptions);
|
|
364
416
|
if (configFile) debug("Loaded config:", configFile);
|
|
365
417
|
else debug("No config file found");
|
|
366
|
-
const rebuilds = await Promise.all(
|
|
418
|
+
const rebuilds = await Promise.all(configs.map(buildSingle));
|
|
367
419
|
const cleanCbs = [];
|
|
368
|
-
for (const [i,
|
|
420
|
+
for (const [i, config] of configs.entries()) {
|
|
369
421
|
const rebuild = rebuilds[i];
|
|
370
422
|
if (!rebuild) continue;
|
|
371
|
-
const watcher = await watchBuild(
|
|
423
|
+
const watcher = await watchBuild(config, configFile, rebuild, restart);
|
|
372
424
|
cleanCbs.push(() => watcher.close());
|
|
373
425
|
}
|
|
374
426
|
if (cleanCbs.length) shortcuts(restart);
|
|
@@ -379,8 +431,8 @@ async function build(userOptions = {}) {
|
|
|
379
431
|
}
|
|
380
432
|
const dirname$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
381
433
|
const pkgRoot = path.resolve(dirname$1, "..");
|
|
382
|
-
async function buildSingle(
|
|
383
|
-
const { entry, external, plugins: userPlugins, outDir, format, clean, platform, alias, treeshake, sourcemap, dts, minify, watch, unused, target, define, shims, fixedExtension, onSuccess } =
|
|
434
|
+
async function buildSingle(config) {
|
|
435
|
+
const { entry, external, plugins: userPlugins, outDir, format, clean, platform, alias, treeshake, sourcemap, dts, minify, watch, unused, target, define, shims, fixedExtension, onSuccess } = config;
|
|
384
436
|
if (clean) await cleanOutDir(outDir, clean);
|
|
385
437
|
const pkg = await readPackageJson(process.cwd());
|
|
386
438
|
await rebuild(true);
|
|
@@ -396,34 +448,34 @@ async function buildSingle(resolved) {
|
|
|
396
448
|
platform,
|
|
397
449
|
define,
|
|
398
450
|
plugins: [
|
|
399
|
-
(pkg ||
|
|
451
|
+
(pkg || config.skipNodeModulesBundle) && ExternalPlugin(config, pkg),
|
|
400
452
|
unused && (await import("unplugin-unused")).Unused.rolldown(unused === true ? {} : unused),
|
|
401
453
|
dts && (await import("unplugin-isolated-decl")).IsolatedDecl.rolldown({
|
|
402
454
|
...dts,
|
|
403
|
-
extraOutdir:
|
|
455
|
+
extraOutdir: config.bundleDts ? getTempDtsDir(format$1) : dts.extraOutdir
|
|
404
456
|
}),
|
|
405
457
|
target && transformPlugin({ target: target && (typeof target === "string" ? target : target.join(",")) }),
|
|
406
458
|
userPlugins
|
|
407
459
|
].filter((plugin) => !!plugin),
|
|
408
460
|
inject: { ...shims && getShimsInject(format$1, platform) }
|
|
409
|
-
},
|
|
461
|
+
}, config.inputOptions, [format$1]);
|
|
410
462
|
const extension = resolveOutputExtension(pkg, format$1, fixedExtension);
|
|
411
463
|
const outputOptions = await mergeUserOptions({
|
|
412
464
|
format: format$1,
|
|
413
|
-
name:
|
|
465
|
+
name: config.globalName,
|
|
414
466
|
sourcemap,
|
|
415
467
|
dir: outDir,
|
|
416
468
|
minify,
|
|
417
469
|
entryFileNames: `[name].${extension}`,
|
|
418
470
|
chunkFileNames: `[name]-[hash].${extension}`
|
|
419
|
-
},
|
|
471
|
+
}, config.outputOptions, [format$1]);
|
|
420
472
|
await build$1({
|
|
421
473
|
...inputOptions,
|
|
422
474
|
output: outputOptions
|
|
423
475
|
});
|
|
424
|
-
if (
|
|
476
|
+
if (config.dts && config.bundleDts) await bundleDts(config, extension, format$1);
|
|
425
477
|
}));
|
|
426
|
-
if (
|
|
478
|
+
if (config.publint) if (pkg) await publint(pkg);
|
|
427
479
|
else logger.warn("publint is enabled but package.json is not found");
|
|
428
480
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${Math.round(performance.now() - startTime)}ms`);
|
|
429
481
|
await onSuccess?.();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Options as Options$3 } from 'publint';
|
|
2
|
-
import { InputOptions,
|
|
2
|
+
import { InputOptions, ExternalOption, ModuleFormat, OutputOptions, InternalModuleFormat } from 'rolldown';
|
|
3
3
|
import { Options as Options$1 } from 'unplugin-isolated-decl';
|
|
4
4
|
import { Options as Options$2 } from 'unplugin-unused';
|
|
5
5
|
|
|
@@ -20,40 +20,29 @@ type Sourcemap = boolean | "inline" | "hidden";
|
|
|
20
20
|
*/
|
|
21
21
|
interface Options {
|
|
22
22
|
entry?: InputOptions["input"];
|
|
23
|
-
format?: ModuleFormat | ModuleFormat[];
|
|
24
|
-
globalName?: string;
|
|
25
|
-
plugins?: InputOptions["plugins"];
|
|
26
23
|
external?: ExternalOption;
|
|
27
24
|
noExternal?: Arrayable<string | RegExp> | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
|
|
25
|
+
alias?: Record<string, string>;
|
|
26
|
+
/** @default 'node' */
|
|
27
|
+
platform?: "node" | "neutral" | "browser";
|
|
28
|
+
inputOptions?: InputOptions | ((options: InputOptions, format: ModuleFormat) => MaybePromise<InputOptions | void | null>);
|
|
29
|
+
format?: ModuleFormat | ModuleFormat[];
|
|
30
|
+
globalName?: string;
|
|
28
31
|
outDir?: string;
|
|
29
|
-
clean?: boolean | string[];
|
|
30
|
-
silent?: boolean;
|
|
31
|
-
config?: boolean | string;
|
|
32
32
|
sourcemap?: Sourcemap;
|
|
33
|
-
|
|
34
|
-
/** @default true */
|
|
35
|
-
treeshake?: boolean;
|
|
33
|
+
clean?: boolean | string[];
|
|
36
34
|
/** @default false */
|
|
37
35
|
minify?: boolean;
|
|
38
36
|
target?: string | string[];
|
|
39
37
|
define?: Record<string, string>;
|
|
40
|
-
/** @default 'node' */
|
|
41
|
-
platform?: "node" | "neutral" | "browser";
|
|
42
38
|
shims?: boolean;
|
|
43
|
-
|
|
44
|
-
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
45
|
-
*/
|
|
46
|
-
dts?: boolean | Options$1;
|
|
39
|
+
outputOptions?: OutputOptions | ((options: OutputOptions, format: ModuleFormat) => MaybePromise<OutputOptions | void | null>);
|
|
47
40
|
/** @default true */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
unused?: boolean | Options$2;
|
|
41
|
+
treeshake?: boolean;
|
|
42
|
+
plugins?: InputOptions["plugins"];
|
|
43
|
+
silent?: boolean;
|
|
44
|
+
config?: boolean | string;
|
|
54
45
|
watch?: boolean | string | string[];
|
|
55
|
-
inputOptions?: InputOptions | ((options: InputOptions, format: ModuleFormat) => MaybePromise<InputOptions | void | null>);
|
|
56
|
-
outputOptions?: OutputOptions | ((options: OutputOptions, format: ModuleFormat) => MaybePromise<OutputOptions | void | null>);
|
|
57
46
|
onSuccess?: () => void | Promise<void>;
|
|
58
47
|
/**
|
|
59
48
|
* Skip bundling node_modules.
|
|
@@ -67,6 +56,22 @@ interface Options {
|
|
|
67
56
|
*/
|
|
68
57
|
fixedExtension?: boolean;
|
|
69
58
|
/**
|
|
59
|
+
* Reuse config from Vite or Vitest (experimental)
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
fromVite?: boolean | "vitest";
|
|
63
|
+
/**
|
|
64
|
+
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
65
|
+
*/
|
|
66
|
+
dts?: boolean | Options$1;
|
|
67
|
+
/** @default true */
|
|
68
|
+
bundleDts?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Enable unused dependencies check with `unplugin-unused`
|
|
71
|
+
* Requires `unplugin-unused` to be installed.
|
|
72
|
+
*/
|
|
73
|
+
unused?: boolean | Options$2;
|
|
74
|
+
/**
|
|
70
75
|
* Run publint after bundling.
|
|
71
76
|
* Requires `publint` to be installed.
|
|
72
77
|
*/
|
|
@@ -75,12 +80,12 @@ interface Options {
|
|
|
75
80
|
/**
|
|
76
81
|
* Options without specifying config file path.
|
|
77
82
|
*/
|
|
78
|
-
type
|
|
83
|
+
type UserConfig = Arrayable<Omit<Options, "config">>;
|
|
79
84
|
type NormalizedFormat = Exclude<InternalModuleFormat, "app"> | "experimental-app";
|
|
80
85
|
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "globalName" | "inputOptions" | "outputOptions" | "minify" | "target" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "dts" | "fixedExtension">, {
|
|
81
86
|
format: NormalizedFormat[]
|
|
82
87
|
clean: string[] | false
|
|
83
88
|
dts: false | Options$1
|
|
84
|
-
}>, "config">;
|
|
89
|
+
}>, "config" | "fromVite">;
|
|
85
90
|
|
|
86
|
-
export type {
|
|
91
|
+
export type { Options as O, ResolvedOptions as R, UserConfig as U };
|
package/dist/plugins.d.ts
CHANGED
package/dist/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger, setSilent } from "./logger-4bmpqibt.js";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-COmVwFsw.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { VERSION } from "rolldown";
|
|
5
5
|
import { dim } from "ansis";
|
|
@@ -8,7 +8,7 @@ import { cac } from "cac";
|
|
|
8
8
|
//#region src/cli.ts
|
|
9
9
|
const cli = cac("tsdown");
|
|
10
10
|
cli.help().version(version);
|
|
11
|
-
cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory").option("--minify", "Minify output").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--silent", "Suppress non-error logs").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("-w, --watch [path]", "Watch mode").action(async (input, flags) => {
|
|
11
|
+
cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).option("-c, --config <filename>", "Use a custom config file").option("--no-config", "Disable config file").option("--format <format>", "Bundle format: esm, cjs, iife", { default: "esm" }).option("--clean", "Clean output directory").option("--minify", "Minify output").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("--silent", "Suppress non-error logs").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("-w, --watch [path]", "Watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").action(async (input, flags) => {
|
|
12
12
|
setSilent(!!flags.silent);
|
|
13
13
|
logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
14
14
|
const { build: build$1 } = await import("./index.js");
|
|
@@ -16,7 +16,7 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
|
|
|
16
16
|
await build$1(flags);
|
|
17
17
|
});
|
|
18
18
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
19
|
-
const { migrate } = await import("./migrate-
|
|
19
|
+
const { migrate } = await import("./migrate-DjS7871z.js");
|
|
20
20
|
await migrate(args);
|
|
21
21
|
});
|
|
22
22
|
async function runCLI() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "An even faster bundler powered by Rolldown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"consola": "^3.4.0",
|
|
60
60
|
"debug": "^4.4.0",
|
|
61
61
|
"diff": "^7.0.0",
|
|
62
|
-
"pkg-types": "^2.0
|
|
62
|
+
"pkg-types": "^2.1.0",
|
|
63
63
|
"rolldown": "^1.0.0-beta.3",
|
|
64
64
|
"rollup": "^4.34.9",
|
|
65
65
|
"rollup-plugin-dts": "^6.1.1",
|
|
66
66
|
"tinyglobby": "^0.2.12",
|
|
67
|
-
"unconfig": "^7.
|
|
68
|
-
"unplugin-isolated-decl": "^0.
|
|
67
|
+
"unconfig": "^7.3.0",
|
|
68
|
+
"unplugin-isolated-decl": "^0.13.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@sxzz/eslint-config": "^5.2.0",
|
|
@@ -73,18 +73,19 @@
|
|
|
73
73
|
"@sxzz/test-utils": "^0.5.1",
|
|
74
74
|
"@types/debug": "^4.1.12",
|
|
75
75
|
"@types/diff": "^7.0.1",
|
|
76
|
-
"@types/node": "^22.13.
|
|
76
|
+
"@types/node": "^22.13.9",
|
|
77
77
|
"bumpp": "^10.0.3",
|
|
78
78
|
"eslint": "^9.21.0",
|
|
79
|
-
"oxc-transform": "^0.
|
|
79
|
+
"oxc-transform": "^0.55.0",
|
|
80
80
|
"prettier": "^3.5.3",
|
|
81
|
-
"publint": "^0.3.
|
|
81
|
+
"publint": "^0.3.8",
|
|
82
82
|
"tinyexec": "^0.3.2",
|
|
83
83
|
"tsup": "^8.4.0",
|
|
84
84
|
"tsx": "^4.19.3",
|
|
85
85
|
"typescript": "~5.8.2",
|
|
86
|
-
"unplugin-ast": "^0.14.
|
|
87
|
-
"unplugin-unused": "^0.4.
|
|
86
|
+
"unplugin-ast": "^0.14.1",
|
|
87
|
+
"unplugin-unused": "^0.4.3",
|
|
88
|
+
"vite": "^6.2.0",
|
|
88
89
|
"vitest": "^3.0.7"
|
|
89
90
|
},
|
|
90
91
|
"engines": {
|