tsdown 0.4.4 → 0.5.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.
- package/dist/index.d.ts +84 -8
- package/dist/index.js +91 -53
- package/dist/plugins.d-CKHmQhmh.d.ts +7 -0
- package/dist/plugins.d.ts +3 -1
- package/dist/run.d.ts +2 -1
- package/dist/run.js +5 -5
- package/package.json +8 -6
- package/dist/cli.d.ts +0 -1
- package/dist/features/clean.d.ts +0 -1
- package/dist/features/entry.d.ts +0 -2
- package/dist/features/external.d.ts +0 -5
- package/dist/features/output.d.ts +0 -2
- package/dist/features/shims.d.ts +0 -2
- package/dist/features/shortcuts.d.ts +0 -6
- package/dist/features/watch.d.ts +0 -3
- package/dist/options.d.ts +0 -59
- package/dist/utils/fs.d.ts +0 -2
- package/dist/utils/general.d.ts +0 -2
- package/dist/utils/logger.d.ts +0 -7
- package/dist/utils/package.d.ts +0 -3
- package/dist/utils/types.d.ts +0 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { E as External } from './plugins.d-CKHmQhmh.js';
|
|
2
|
+
import { InputOptions, ModuleFormat, OutputOptions, InternalModuleFormat } from 'rolldown';
|
|
3
|
+
import { Options as Options$1 } from 'unplugin-isolated-decl';
|
|
4
|
+
import { Options as Options$2 } from 'unplugin-unused';
|
|
5
|
+
import { ConsolaInstance } from 'consola';
|
|
6
|
+
import 'pkg-types';
|
|
7
|
+
|
|
8
|
+
type Overwrite<
|
|
9
|
+
T,
|
|
10
|
+
U
|
|
11
|
+
> = Omit<T, keyof U> & U;
|
|
12
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
13
|
+
type MarkPartial<
|
|
14
|
+
T,
|
|
15
|
+
K extends keyof T
|
|
16
|
+
> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
17
|
+
type Arrayable<T> = T | T[];
|
|
18
|
+
|
|
19
|
+
type Sourcemap = boolean | "inline" | "hidden";
|
|
20
|
+
/**
|
|
21
|
+
* Options for tsdown.
|
|
22
|
+
*/
|
|
23
|
+
interface Options {
|
|
24
|
+
entry?: InputOptions["input"];
|
|
25
|
+
format?: ModuleFormat | ModuleFormat[];
|
|
26
|
+
globalName?: string;
|
|
27
|
+
plugins?: InputOptions["plugins"];
|
|
28
|
+
external?: External;
|
|
29
|
+
outDir?: string;
|
|
30
|
+
clean?: boolean | string[];
|
|
31
|
+
silent?: boolean;
|
|
32
|
+
config?: boolean | string;
|
|
33
|
+
sourcemap?: Sourcemap;
|
|
34
|
+
alias?: Record<string, string>;
|
|
35
|
+
/** @default true */
|
|
36
|
+
treeshake?: boolean;
|
|
37
|
+
/** @default false */
|
|
38
|
+
minify?: boolean;
|
|
39
|
+
target?: string | string[];
|
|
40
|
+
define?: Record<string, string>;
|
|
41
|
+
/** @default 'node' */
|
|
42
|
+
platform?: "node" | "neutral" | "browser";
|
|
43
|
+
shims?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
46
|
+
*/
|
|
47
|
+
dts?: boolean | Options$1;
|
|
48
|
+
/** @default true */
|
|
49
|
+
bundleDts?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Enable unused dependencies check with `unplugin-unused` (experimental)
|
|
52
|
+
*/
|
|
53
|
+
unused?: boolean | Options$2;
|
|
54
|
+
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
|
+
onSuccess?: () => void | Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Skip bundling node_modules.
|
|
60
|
+
*/
|
|
61
|
+
skipNodeModulesBundle?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Options without specifying config file path.
|
|
65
|
+
*/
|
|
66
|
+
type Config = Arrayable<Omit<Options, "config">>;
|
|
67
|
+
type NormalizedFormat = Exclude<InternalModuleFormat, "app"> | "experimental-app";
|
|
68
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "globalName" | "inputOptions" | "outputOptions" | "minify" | "target" | "define" | "alias" | "external" | "onSuccess" | "dts">, {
|
|
69
|
+
format: NormalizedFormat[];
|
|
70
|
+
clean: string[] | false;
|
|
71
|
+
dts: false | Options$1;
|
|
72
|
+
}>, "config">;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Logger instance
|
|
76
|
+
*/
|
|
77
|
+
declare const logger: ConsolaInstance;
|
|
78
|
+
|
|
3
79
|
/**
|
|
4
80
|
* Build with tsdown.
|
|
5
81
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
82
|
+
declare function build(userOptions?: Omit<Options, "silent">): Promise<void>;
|
|
83
|
+
declare const pkgRoot: string;
|
|
8
84
|
/**
|
|
9
85
|
* Build a single configuration, without watch and shortcuts features.
|
|
10
86
|
*
|
|
11
87
|
* @param resolved Resolved options
|
|
12
88
|
*/
|
|
13
|
-
|
|
89
|
+
declare function buildSingle(resolved: ResolvedOptions): Promise<(() => Promise<void>) | undefined>;
|
|
14
90
|
/**
|
|
15
91
|
* Defines the configuration for tsdown.
|
|
16
92
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export type
|
|
93
|
+
declare function defineConfig(options: Config): Config;
|
|
94
|
+
|
|
95
|
+
export { type Config, type Options, build, buildSingle, defineConfig, logger, pkgRoot };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { debug, logger } from "./logger-Pk57TMWT.js";
|
|
2
2
|
import { ExternalPlugin } from "./external-9r3oq3tH.js";
|
|
3
|
-
import path, { dirname
|
|
3
|
+
import path, { dirname, normalize, sep, default as path$1, default as path$2, default as path$3, default as path$4, default as path$5, default as path$6 } from "node:path";
|
|
4
4
|
import process, { default as process$1, default as process$2, default as process$3 } from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { build as
|
|
6
|
+
import { build as build$1 } from "rolldown";
|
|
7
7
|
import { transformPlugin } from "rolldown/experimental";
|
|
8
8
|
import { IsolatedDecl } from "unplugin-isolated-decl";
|
|
9
9
|
import { Unused } from "unplugin-unused";
|
|
10
10
|
import { access, readdir, rm, stat } from "node:fs/promises";
|
|
11
|
-
import { glob
|
|
11
|
+
import { glob } from "tinyglobby";
|
|
12
|
+
import { rollup } from "rollup";
|
|
13
|
+
import DtsPlugin from "rollup-plugin-dts";
|
|
12
14
|
import { readPackageJSON } from "pkg-types";
|
|
13
15
|
import readline from "node:readline";
|
|
14
16
|
import pc, { default as pc$1, default as pc$2 } from "picocolors";
|
|
15
17
|
import { loadConfig } from "unconfig";
|
|
16
18
|
|
|
17
19
|
//#region src/utils/fs.ts
|
|
18
|
-
function fsExists(path$
|
|
19
|
-
return access(path$
|
|
20
|
+
function fsExists(path$7) {
|
|
21
|
+
return access(path$7).then(() => true, () => false);
|
|
20
22
|
}
|
|
21
23
|
function lowestCommonAncestor(...filepaths) {
|
|
22
24
|
if (filepaths.length === 0) return "";
|
|
23
|
-
if (filepaths.length === 1) return dirname
|
|
25
|
+
if (filepaths.length === 1) return dirname(filepaths[0]);
|
|
24
26
|
filepaths = filepaths.map(normalize);
|
|
25
27
|
const [first, ...rest] = filepaths;
|
|
26
28
|
let ancestor = first.split(sep);
|
|
@@ -41,8 +43,8 @@ else {
|
|
|
41
43
|
//#region src/features/clean.ts
|
|
42
44
|
async function cleanOutDir(cwd, patterns) {
|
|
43
45
|
const files = [];
|
|
44
|
-
if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$
|
|
45
|
-
if (patterns.length) files.push(...await glob
|
|
46
|
+
if (await fsExists(cwd)) files.push(...(await readdir(cwd)).map((file) => path$6.resolve(cwd, file)));
|
|
47
|
+
if (patterns.length) files.push(...await glob(patterns, {
|
|
46
48
|
cwd,
|
|
47
49
|
absolute: true
|
|
48
50
|
}));
|
|
@@ -56,6 +58,34 @@ async function cleanOutDir(cwd, patterns) {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/features/dts.ts
|
|
63
|
+
const TEMP_DTS_DIR = ".tsdown-types";
|
|
64
|
+
async function bundleDts(options, jsExtension) {
|
|
65
|
+
const ext = jsExtension.replace("j", "t");
|
|
66
|
+
const dtsOutDir = path$5.resolve(options.outDir, TEMP_DTS_DIR);
|
|
67
|
+
const dtsEntry = Object.fromEntries(Object.keys(options.entry).map((key) => [key, path$5.resolve(dtsOutDir, `${key}.d.${ext}`)]));
|
|
68
|
+
const build$2 = await rollup({
|
|
69
|
+
input: dtsEntry,
|
|
70
|
+
onLog(level, log, defaultHandler) {
|
|
71
|
+
if (log.code !== "EMPTY_BUNDLE") defaultHandler(level, log);
|
|
72
|
+
},
|
|
73
|
+
plugins: [DtsPlugin()]
|
|
74
|
+
});
|
|
75
|
+
let outDir = options.outDir;
|
|
76
|
+
const extraOutdir = options.dts.extraOutdir;
|
|
77
|
+
if (extraOutdir) outDir = path$5.resolve(outDir, extraOutdir);
|
|
78
|
+
await build$2.write({
|
|
79
|
+
dir: outDir,
|
|
80
|
+
format: "es",
|
|
81
|
+
entryFileNames: `[name].d.${ext}`
|
|
82
|
+
});
|
|
83
|
+
await rm(dtsOutDir, {
|
|
84
|
+
recursive: true,
|
|
85
|
+
force: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
59
89
|
//#endregion
|
|
60
90
|
//#region src/utils/package.ts
|
|
61
91
|
async function readPackageJson(dir) {
|
|
@@ -169,11 +199,13 @@ function debounce(fn, wait) {
|
|
|
169
199
|
|
|
170
200
|
//#endregion
|
|
171
201
|
//#region src/features/watch.ts
|
|
172
|
-
|
|
202
|
+
const endsWithPackageJson = /[\\/]package\.json$/;
|
|
203
|
+
async function watchBuild(options, configFile, rebuild, restart) {
|
|
173
204
|
const { watch } = await import("chokidar");
|
|
174
205
|
const debouncedRebuild = debounce(rebuild, 100);
|
|
175
|
-
const files = typeof options.watch === "boolean" ? process$2.cwd() : options.watch;
|
|
176
|
-
logger.info(`Watching for changes in ${
|
|
206
|
+
const files = toArray(typeof options.watch === "boolean" ? process$2.cwd() : options.watch);
|
|
207
|
+
logger.info(`Watching for changes in ${files.join(", ")}`);
|
|
208
|
+
if (configFile) files.push(configFile);
|
|
177
209
|
const watcher = watch(files, {
|
|
178
210
|
ignoreInitial: true,
|
|
179
211
|
ignorePermissionErrors: true,
|
|
@@ -183,6 +215,11 @@ async function watchBuild(options, rebuild) {
|
|
|
183
215
|
}
|
|
184
216
|
});
|
|
185
217
|
watcher.on("all", (type, file) => {
|
|
218
|
+
if (endsWithPackageJson.test(file) || configFile === file) {
|
|
219
|
+
logger.info(`Reload config: ${file}`);
|
|
220
|
+
restart();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
186
223
|
logger.info(`Change detected: ${type} ${file}`);
|
|
187
224
|
debouncedRebuild();
|
|
188
225
|
});
|
|
@@ -193,25 +230,21 @@ async function watchBuild(options, rebuild) {
|
|
|
193
230
|
//#region src/features/entry.ts
|
|
194
231
|
async function resolveEntry(entry) {
|
|
195
232
|
if (!entry || Object.keys(entry).length === 0) throw new Error(`No input files, try "tsdown <your-file>" instead`);
|
|
233
|
+
const objectEntry = await toObjectEntry(entry);
|
|
234
|
+
const entries = Object.values(objectEntry);
|
|
235
|
+
if (entries.length === 0) throw new Error(`Cannot find entry: ${JSON.stringify(entry)}`);
|
|
236
|
+
logger.info(`entry: ${pc$1.blue(entries.join(", "))}`);
|
|
237
|
+
return objectEntry;
|
|
238
|
+
}
|
|
239
|
+
async function toObjectEntry(entry) {
|
|
196
240
|
if (typeof entry === "string") entry = [entry];
|
|
197
|
-
if (Array.isArray(entry))
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return [relative.slice(0, relative.length - path$2.extname(relative).length), file];
|
|
205
|
-
}));
|
|
206
|
-
} else throw new Error(`Cannot find entry: ${entry}`);
|
|
207
|
-
} else {
|
|
208
|
-
const files = Object.values(entry);
|
|
209
|
-
files.forEach((filename) => {
|
|
210
|
-
if (!fsExists(filename)) throw new Error(`Cannot find entry: ${filename}`);
|
|
211
|
-
});
|
|
212
|
-
logger.info(`entry: ${pc$1.blue(files.join(", "))}`);
|
|
213
|
-
}
|
|
214
|
-
return entry;
|
|
241
|
+
if (!Array.isArray(entry)) return entry;
|
|
242
|
+
const resolvedEntry = await glob(entry);
|
|
243
|
+
const base = lowestCommonAncestor(...resolvedEntry);
|
|
244
|
+
return Object.fromEntries(resolvedEntry.map((file) => {
|
|
245
|
+
const relative = path$2.relative(base, file);
|
|
246
|
+
return [relative.slice(0, relative.length - path$2.extname(relative).length), file];
|
|
247
|
+
}));
|
|
215
248
|
}
|
|
216
249
|
|
|
217
250
|
//#endregion
|
|
@@ -224,7 +257,7 @@ async function resolveOptions(options) {
|
|
|
224
257
|
...subConfig,
|
|
225
258
|
...options
|
|
226
259
|
};
|
|
227
|
-
let { entry, format = ["es"], plugins = [], clean = false, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts = false, unused = false, watch = false, shims = false, skipNodeModulesBundle = false } = subOptions;
|
|
260
|
+
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 } = subOptions;
|
|
228
261
|
entry = await resolveEntry(entry);
|
|
229
262
|
if (clean === true) clean = [];
|
|
230
263
|
return {
|
|
@@ -238,7 +271,8 @@ async function resolveOptions(options) {
|
|
|
238
271
|
treeshake,
|
|
239
272
|
platform,
|
|
240
273
|
sourcemap,
|
|
241
|
-
dts,
|
|
274
|
+
dts: dts === true ? {} : dts,
|
|
275
|
+
bundleDts: bundleDts$1,
|
|
242
276
|
unused,
|
|
243
277
|
watch,
|
|
244
278
|
shims,
|
|
@@ -294,12 +328,20 @@ async function loadConfigFile(options) {
|
|
|
294
328
|
rewrite: (config$1) => config$1?.tsdown
|
|
295
329
|
}],
|
|
296
330
|
cwd,
|
|
297
|
-
defaults: {}
|
|
331
|
+
defaults: {},
|
|
332
|
+
importx: { loader: "bundle-require" }
|
|
298
333
|
});
|
|
299
334
|
if (sources.length > 0) logger.info(`Using tsdown config: ${pc.underline(sources.join(", "))}`);
|
|
300
335
|
const file = sources[0];
|
|
301
336
|
return [toArray(config), file];
|
|
302
337
|
}
|
|
338
|
+
async function mergeUserOptions(defaults, user, args) {
|
|
339
|
+
const userOutputOptions = typeof user === "function" ? await user(defaults, ...args) : user;
|
|
340
|
+
return {
|
|
341
|
+
...defaults,
|
|
342
|
+
...userOutputOptions
|
|
343
|
+
};
|
|
344
|
+
}
|
|
303
345
|
|
|
304
346
|
//#endregion
|
|
305
347
|
//#region src/index.ts
|
|
@@ -313,16 +355,17 @@ else debug("No config file found");
|
|
|
313
355
|
for (const [i, resolved] of resolveds.entries()) {
|
|
314
356
|
const rebuild = rebuilds[i];
|
|
315
357
|
if (!rebuild) continue;
|
|
316
|
-
const watcher = await watchBuild(resolved, rebuild);
|
|
358
|
+
const watcher = await watchBuild(resolved, configFile, rebuild, restart);
|
|
317
359
|
cleanCbs.push(() => watcher.close());
|
|
318
360
|
}
|
|
319
|
-
if (cleanCbs.length) shortcuts(
|
|
361
|
+
if (cleanCbs.length) shortcuts(restart);
|
|
362
|
+
async function restart() {
|
|
320
363
|
for (const clean of cleanCbs) await clean();
|
|
321
364
|
build(userOptions);
|
|
322
|
-
}
|
|
365
|
+
}
|
|
323
366
|
}
|
|
324
|
-
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
325
|
-
const pkgRoot = path.resolve(dirname, "..");
|
|
367
|
+
const dirname$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
368
|
+
const pkgRoot = path.resolve(dirname$1, "..");
|
|
326
369
|
async function buildSingle(resolved) {
|
|
327
370
|
const { entry, external, plugins: userPlugins, outDir, format, clean, platform, alias, treeshake, sourcemap, dts, minify, watch, unused, target, define, shims, onSuccess } = resolved;
|
|
328
371
|
if (clean) await cleanOutDir(outDir, clean);
|
|
@@ -334,12 +377,15 @@ async function buildSingle(resolved) {
|
|
|
334
377
|
const plugins = [
|
|
335
378
|
pkg && ExternalPlugin(pkg, resolved.skipNodeModulesBundle),
|
|
336
379
|
unused && Unused.rolldown(unused === true ? {} : unused),
|
|
337
|
-
dts && IsolatedDecl.rolldown(
|
|
380
|
+
dts && IsolatedDecl.rolldown({
|
|
381
|
+
...dts,
|
|
382
|
+
extraOutdir: resolved.bundleDts ? TEMP_DTS_DIR : dts.extraOutdir
|
|
383
|
+
}),
|
|
338
384
|
target && transformPlugin({ target: target && (typeof target === "string" ? target : target.join(",")) }),
|
|
339
385
|
userPlugins
|
|
340
386
|
].filter((plugin) => !!plugin);
|
|
341
387
|
await Promise.all(format.map(async (format$1) => {
|
|
342
|
-
const inputOptions = {
|
|
388
|
+
const inputOptions = await mergeUserOptions({
|
|
343
389
|
input: entry,
|
|
344
390
|
external,
|
|
345
391
|
resolve: { alias },
|
|
@@ -347,14 +393,10 @@ async function buildSingle(resolved) {
|
|
|
347
393
|
platform,
|
|
348
394
|
define,
|
|
349
395
|
plugins,
|
|
350
|
-
...
|
|
351
|
-
|
|
352
|
-
...shims && getShimsInject(format$1, platform),
|
|
353
|
-
...resolved.inputOptions?.inject
|
|
354
|
-
}
|
|
355
|
-
};
|
|
396
|
+
inject: { ...shims && getShimsInject(format$1, platform) }
|
|
397
|
+
}, resolved.inputOptions, [format$1]);
|
|
356
398
|
const extension = resolveOutputExtension(pkg, format$1);
|
|
357
|
-
|
|
399
|
+
const outputOptions = await mergeUserOptions({
|
|
358
400
|
format: format$1,
|
|
359
401
|
name: resolved.globalName,
|
|
360
402
|
sourcemap,
|
|
@@ -362,16 +404,12 @@ async function buildSingle(resolved) {
|
|
|
362
404
|
minify,
|
|
363
405
|
entryFileNames: `[name].${extension}`,
|
|
364
406
|
chunkFileNames: `[name]-[hash].${extension}`
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
outputOptions = {
|
|
368
|
-
...outputOptions,
|
|
369
|
-
...userOutputOptions
|
|
370
|
-
};
|
|
371
|
-
await rolldownBuild({
|
|
407
|
+
}, resolved.outputOptions, [format$1]);
|
|
408
|
+
await build$1({
|
|
372
409
|
...inputOptions,
|
|
373
410
|
output: outputOptions
|
|
374
411
|
});
|
|
412
|
+
if (resolved.dts && resolved.bundleDts) await bundleDts(resolved, extension);
|
|
375
413
|
}));
|
|
376
414
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${Math.round(performance.now() - startTime)}ms`);
|
|
377
415
|
await onSuccess?.();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PackageJson } from 'pkg-types';
|
|
2
|
+
import { Plugin, InputOptions } from 'rolldown';
|
|
3
|
+
|
|
4
|
+
type External = InputOptions["external"];
|
|
5
|
+
declare function ExternalPlugin(pkg: PackageJson, skipNodeModulesBundle?: boolean): Plugin;
|
|
6
|
+
|
|
7
|
+
export { type External as E, ExternalPlugin as a };
|
package/dist/plugins.d.ts
CHANGED
package/dist/run.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|
package/dist/run.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { logger } from "./logger-Pk57TMWT.js";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import { VERSION
|
|
3
|
+
import { VERSION } from "rolldown";
|
|
4
4
|
import pc from "picocolors";
|
|
5
5
|
import { cac } from "cac";
|
|
6
6
|
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.5.1";
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/cli.ts
|
|
@@ -13,10 +13,10 @@ async function runCLI() {
|
|
|
13
13
|
const cli = cac("tsdown");
|
|
14
14
|
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) => {
|
|
15
15
|
if (!("CONSOLA_LEVEL" in process.env)) logger.level = flags.silent ? 0 : 3;
|
|
16
|
-
logger.info(`tsdown ${pc.dim(`v${version}`)} powered by rolldown ${pc.dim(`v${
|
|
17
|
-
const { build } = await import("./index.js");
|
|
16
|
+
logger.info(`tsdown ${pc.dim(`v${version}`)} powered by rolldown ${pc.dim(`v${VERSION}`)}`);
|
|
17
|
+
const { build: build$1 } = await import("./index.js");
|
|
18
18
|
if (input.length > 0) flags.entry = input;
|
|
19
|
-
await build(flags);
|
|
19
|
+
await build$1(flags);
|
|
20
20
|
});
|
|
21
21
|
cli.help();
|
|
22
22
|
cli.version(version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "An even faster bundler powered by Rolldown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,23 +43,25 @@
|
|
|
43
43
|
"cac": "^6.7.14",
|
|
44
44
|
"chokidar": "^4.0.1",
|
|
45
45
|
"consola": "^3.2.3",
|
|
46
|
-
"debug": "^4.
|
|
46
|
+
"debug": "^4.4.0",
|
|
47
47
|
"picocolors": "^1.1.1",
|
|
48
48
|
"pkg-types": "^1.2.1",
|
|
49
|
-
"rolldown": "
|
|
49
|
+
"rolldown": "nightly",
|
|
50
|
+
"rollup": "^4.28.1",
|
|
51
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
50
52
|
"tinyglobby": "^0.2.10",
|
|
51
53
|
"unconfig": "^0.6.0",
|
|
52
|
-
"unplugin-isolated-decl": "^0.
|
|
54
|
+
"unplugin-isolated-decl": "^0.10.0",
|
|
53
55
|
"unplugin-unused": "^0.2.3"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@sxzz/eslint-config": "^4.5.1",
|
|
57
59
|
"@sxzz/prettier-config": "^2.0.2",
|
|
60
|
+
"@sxzz/test-utils": "^0.3.11",
|
|
58
61
|
"@types/debug": "^4.1.12",
|
|
59
62
|
"@types/node": "^22.10.1",
|
|
60
|
-
"bumpp": "^9.
|
|
63
|
+
"bumpp": "^9.9.0",
|
|
61
64
|
"eslint": "^9.16.0",
|
|
62
|
-
"fdir": "^6.4.2",
|
|
63
65
|
"oxc-transform": "^0.39.0",
|
|
64
66
|
"prettier": "^3.4.2",
|
|
65
67
|
"tinyexec": "^0.3.1",
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runCLI(): Promise<void>;
|
package/dist/features/clean.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function cleanOutDir(cwd: string, patterns: string[]): Promise<void>;
|
package/dist/features/entry.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { PackageJson } from "pkg-types";
|
|
2
|
-
import type { InputOptions, Plugin } from "rolldown";
|
|
3
|
-
export type External = InputOptions["external"];
|
|
4
|
-
export declare function ExternalPlugin(pkg: PackageJson, skipNodeModulesBundle?: boolean): Plugin;
|
|
5
|
-
export declare function getProductionDeps(pkg: PackageJson): Set<string>;
|
package/dist/features/shims.d.ts
DELETED
package/dist/features/watch.d.ts
DELETED
package/dist/options.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { External } from "./features/external.js";
|
|
2
|
-
import type { Arrayable, MarkPartial, MaybePromise, Overwrite } from "./utils/types.js";
|
|
3
|
-
import type { InputOptions, InternalModuleFormat, ModuleFormat, 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 Sourcemap = boolean | "inline" | "hidden";
|
|
7
|
-
/**
|
|
8
|
-
* Options for tsdown.
|
|
9
|
-
*/
|
|
10
|
-
export interface Options {
|
|
11
|
-
entry?: InputOptions["input"];
|
|
12
|
-
format?: ModuleFormat | ModuleFormat[];
|
|
13
|
-
globalName?: string;
|
|
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
|
-
target?: string | string[];
|
|
27
|
-
define?: Record<string, string>;
|
|
28
|
-
/** @default 'node' */
|
|
29
|
-
platform?: "node" | "neutral" | "browser";
|
|
30
|
-
shims?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Enable dts generation with `isolatedDeclarations` (experimental)
|
|
33
|
-
*/
|
|
34
|
-
dts?: boolean | IsolatedDeclOptions;
|
|
35
|
-
/**
|
|
36
|
-
* Enable unused dependencies check with `unplugin-unused` (experimental)
|
|
37
|
-
*/
|
|
38
|
-
unused?: boolean | UnusedOptions;
|
|
39
|
-
watch?: boolean | string | string[];
|
|
40
|
-
inputOptions?: InputOptions;
|
|
41
|
-
outputOptions?: OutputOptions | ((options: OutputOptions, format: ModuleFormat) => MaybePromise<OutputOptions | void | null>);
|
|
42
|
-
onSuccess?: () => void | Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Skip bundling node_modules.
|
|
45
|
-
*/
|
|
46
|
-
skipNodeModulesBundle?: boolean;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Options without specifying config file path.
|
|
50
|
-
*/
|
|
51
|
-
export type Config = Arrayable<Omit<Options, "config">>;
|
|
52
|
-
export type ResolvedConfig = Extract<Config, any[]>;
|
|
53
|
-
export type NormalizedFormat = Exclude<InternalModuleFormat, "app"> | "experimental-app";
|
|
54
|
-
export type ResolvedOptions = Omit<Overwrite<MarkPartial<Options, "globalName" | "inputOptions" | "outputOptions" | "minify" | "target" | "define" | "alias" | "external" | "onSuccess">, {
|
|
55
|
-
format: NormalizedFormat[];
|
|
56
|
-
clean: string[] | false;
|
|
57
|
-
}>, "config">;
|
|
58
|
-
export declare function resolveOptions(options: Options): Promise<[configs: ResolvedOptions[], configFile?: string]>;
|
|
59
|
-
export declare function normalizeFormat(format: ModuleFormat | ModuleFormat[]): NormalizedFormat[];
|
package/dist/utils/fs.d.ts
DELETED
package/dist/utils/general.d.ts
DELETED
package/dist/utils/logger.d.ts
DELETED
package/dist/utils/package.d.ts
DELETED
package/dist/utils/types.d.ts
DELETED