tsdown 0.9.9 → 0.10.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/{config.d-Ca2e571o.d.ts → config.d-D3EdptPL.d.ts} +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +88 -59
- package/dist/{migrate-CygdeFLJ.js → migrate-CowIU0R_.js} +3 -2
- package/dist/{options.d-DF6uzkZt.d.ts → options.d--a1aWVL6.d.ts} +15 -10
- package/dist/package-DfgxaSyP.js +5 -0
- package/dist/{plugins-BcuTSrGE.js → plugins-DX6CtlR1.js} +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +1 -1
- package/dist/run.js +3 -3
- package/package.json +3 -3
- package/dist/package-Cr6J7APF.js +0 -5
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./options.d
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config.d-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./options.d--a1aWVL6.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-D3EdptPL.js";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig } from "./options.d
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config.d-
|
|
1
|
+
import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig } from "./options.d--a1aWVL6.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-D3EdptPL.js";
|
|
3
3
|
import { ConsolaInstance } from "consola";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/logger.d.ts
|
|
@@ -19,9 +19,12 @@ declare const pkgRoot: string;
|
|
|
19
19
|
/**
|
|
20
20
|
* Build a single configuration, without watch and shortcuts features.
|
|
21
21
|
*
|
|
22
|
+
* Internal API, not for public use
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
22
25
|
* @param config Resolved options
|
|
23
26
|
*/
|
|
24
|
-
declare function buildSingle(config: ResolvedOptions): Promise<(() => Promise<void>) | undefined>;
|
|
27
|
+
declare function buildSingle(config: ResolvedOptions, clean: () => Promise<void>): Promise<(() => Promise<void>) | undefined>;
|
|
25
28
|
|
|
26
29
|
//#endregion
|
|
27
30
|
export { BuildContext, Options, TsdownHooks, UserConfig, build, buildSingle, defineConfig, logger, pkgRoot };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CpIe1Ud_.js";
|
|
2
|
-
import { ExternalPlugin, ReportPlugin, ShebangPlugin, fsExists, fsRemove, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson } from "./plugins-
|
|
2
|
+
import { ExternalPlugin, ReportPlugin, ShebangPlugin, fsExists, fsRemove, getPackageType, lowestCommonAncestor, normalizeFormat, prettyFormat, readPackageJson } from "./plugins-DX6CtlR1.js";
|
|
3
3
|
import { debounce, logger, resolveComma, setSilent, toArray } from "./general-C06aMSSY.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
@@ -9,8 +9,8 @@ import Debug from "debug";
|
|
|
9
9
|
import { build as build$1 } from "rolldown";
|
|
10
10
|
import { transformPlugin } from "rolldown/experimental";
|
|
11
11
|
import { exec } from "tinyexec";
|
|
12
|
-
import { readdir, stat } from "node:fs/promises";
|
|
13
12
|
import { glob } from "tinyglobby";
|
|
13
|
+
import { stat } from "node:fs/promises";
|
|
14
14
|
import { createHooks } from "hookable";
|
|
15
15
|
import LightningCSS from "unplugin-lightningcss/rolldown";
|
|
16
16
|
import readline from "node:readline";
|
|
@@ -18,19 +18,29 @@ import { loadConfig } from "unconfig";
|
|
|
18
18
|
import { up } from "empathic/find";
|
|
19
19
|
|
|
20
20
|
//#region src/features/clean.ts
|
|
21
|
-
const debug$
|
|
22
|
-
async function cleanOutDir(
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
debug$2("Removing", file);
|
|
32
|
-
await fsRemove(file);
|
|
21
|
+
const debug$3 = Debug("tsdown:clean");
|
|
22
|
+
async function cleanOutDir(configs) {
|
|
23
|
+
const removes = new Set();
|
|
24
|
+
for (const config of configs) {
|
|
25
|
+
if (!config.clean.length) continue;
|
|
26
|
+
const files = await glob(config.clean, {
|
|
27
|
+
cwd: config.cwd,
|
|
28
|
+
absolute: true
|
|
29
|
+
});
|
|
30
|
+
for (const file of files) removes.add(file);
|
|
33
31
|
}
|
|
32
|
+
if (!removes.size) return;
|
|
33
|
+
logger.info("Cleaning %d files", removes.size);
|
|
34
|
+
await Promise.all([...removes].map(async (file) => {
|
|
35
|
+
debug$3("Removing", file);
|
|
36
|
+
await fsRemove(file);
|
|
37
|
+
}));
|
|
38
|
+
debug$3("Removed %d files", removes.size);
|
|
39
|
+
}
|
|
40
|
+
function resolveClean(clean, outDir) {
|
|
41
|
+
if (clean === true) clean = [outDir];
|
|
42
|
+
else if (!clean) clean = [];
|
|
43
|
+
return clean;
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
//#endregion
|
|
@@ -108,7 +118,7 @@ function resolveJsOutputExtension(packageType, format, fixedExtension) {
|
|
|
108
118
|
default: return "js";
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
|
-
function resolveChunkFilename(
|
|
121
|
+
function resolveChunkFilename({ outExtensions, fixedExtension, pkg }, inputOptions, format) {
|
|
112
122
|
const packageType = getPackageType(pkg);
|
|
113
123
|
let jsExtension;
|
|
114
124
|
let dtsExtension;
|
|
@@ -117,12 +127,13 @@ function resolveChunkFilename(pkg, inputOptions, format, { outExtensions, fixedE
|
|
|
117
127
|
options: inputOptions,
|
|
118
128
|
format,
|
|
119
129
|
pkgType: packageType
|
|
120
|
-
});
|
|
130
|
+
}) || {};
|
|
121
131
|
jsExtension = js;
|
|
122
132
|
dtsExtension = dts;
|
|
123
133
|
}
|
|
124
134
|
jsExtension ||= `.${resolveJsOutputExtension(packageType, format, fixedExtension)}`;
|
|
125
|
-
|
|
135
|
+
const suffix = format === "iife" || format === "umd" ? `.${format}` : "";
|
|
136
|
+
return [createChunkFilename(`[name]${suffix}`, jsExtension, dtsExtension), createChunkFilename(`[name]${suffix}-[hash]`, jsExtension, dtsExtension)];
|
|
126
137
|
}
|
|
127
138
|
function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
128
139
|
if (!dtsExtension) return `${basename}${jsExtension}`;
|
|
@@ -133,13 +144,13 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
|
133
144
|
|
|
134
145
|
//#endregion
|
|
135
146
|
//#region src/features/publint.ts
|
|
136
|
-
const debug$
|
|
137
|
-
async function publint(pkg) {
|
|
138
|
-
debug$
|
|
147
|
+
const debug$2 = Debug("tsdown:publint");
|
|
148
|
+
async function publint(pkg, options) {
|
|
149
|
+
debug$2("Running publint");
|
|
139
150
|
const { publint: publint$1 } = await import("publint");
|
|
140
151
|
const { formatMessage } = await import("publint/utils");
|
|
141
|
-
const { messages } = await publint$1();
|
|
142
|
-
debug$
|
|
152
|
+
const { messages } = await publint$1(options);
|
|
153
|
+
debug$2("Found %d issues", messages.length);
|
|
143
154
|
if (!messages.length) logger.success("No publint issues found");
|
|
144
155
|
let hasError = false;
|
|
145
156
|
for (const message of messages) {
|
|
@@ -153,7 +164,7 @@ async function publint(pkg) {
|
|
|
153
164
|
logger[logType](formattedMessage);
|
|
154
165
|
}
|
|
155
166
|
if (hasError) {
|
|
156
|
-
debug$
|
|
167
|
+
debug$2("Found errors, setting exit code to 1");
|
|
157
168
|
process.exitCode = 1;
|
|
158
169
|
}
|
|
159
170
|
}
|
|
@@ -275,43 +286,53 @@ async function toObjectEntry(entry, cwd) {
|
|
|
275
286
|
}
|
|
276
287
|
|
|
277
288
|
//#endregion
|
|
278
|
-
//#region src/
|
|
289
|
+
//#region src/features/tsconfig.ts
|
|
279
290
|
function findTsconfig(cwd, name = "tsconfig.json") {
|
|
280
291
|
return up(name, { cwd }) || false;
|
|
281
292
|
}
|
|
293
|
+
async function resolveTsconfig(tsconfig, cwd) {
|
|
294
|
+
if (tsconfig !== false) {
|
|
295
|
+
if (tsconfig === true || tsconfig == null) {
|
|
296
|
+
const isSet = tsconfig;
|
|
297
|
+
tsconfig = findTsconfig(cwd);
|
|
298
|
+
if (isSet && !tsconfig) logger.warn(`No tsconfig found in \`${cwd}\``);
|
|
299
|
+
} else {
|
|
300
|
+
const tsconfigPath = path.resolve(cwd, tsconfig);
|
|
301
|
+
if (await fsExists(tsconfigPath)) tsconfig = tsconfigPath;
|
|
302
|
+
else if (tsconfig.includes("\\") || tsconfig.includes("/")) {
|
|
303
|
+
logger.warn(`tsconfig \`${tsconfig}\` doesn't exist`);
|
|
304
|
+
tsconfig = false;
|
|
305
|
+
} else {
|
|
306
|
+
tsconfig = findTsconfig(cwd, tsconfig);
|
|
307
|
+
if (!tsconfig) logger.warn(`No \`${tsconfig}\` found in \`${cwd}\``);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (tsconfig) logger.info(`Using tsconfig: ${underline(path.relative(cwd, tsconfig))}`);
|
|
311
|
+
}
|
|
312
|
+
return tsconfig;
|
|
313
|
+
}
|
|
282
314
|
|
|
283
315
|
//#endregion
|
|
284
316
|
//#region src/options.ts
|
|
317
|
+
const debug$1 = Debug("tsdown:options");
|
|
285
318
|
async function resolveOptions(options) {
|
|
286
319
|
const { configs: userConfigs, file, cwd } = await loadConfigFile(options);
|
|
287
320
|
if (userConfigs.length === 0) userConfigs.push({});
|
|
321
|
+
debug$1("Loaded config file %s from %s", file, cwd);
|
|
322
|
+
debug$1("User configs %o", userConfigs);
|
|
288
323
|
const configs = await Promise.all(userConfigs.map(async (subConfig) => {
|
|
289
324
|
const subOptions = {
|
|
290
325
|
...subConfig,
|
|
291
326
|
...options
|
|
292
327
|
};
|
|
293
|
-
let { entry, format = ["es"], plugins = [], clean =
|
|
328
|
+
let { entry, format = ["es"], plugins = [], clean = true, silent = false, treeshake = true, platform = "node", outDir = "dist", sourcemap = false, dts, unused = false, watch = false, shims = false, skipNodeModulesBundle = false, publint: publint$1 = false, fromVite, alias, tsconfig, report = true, target, env = {} } = subOptions;
|
|
329
|
+
outDir = path.resolve(outDir);
|
|
294
330
|
entry = await resolveEntry(entry, cwd);
|
|
295
|
-
|
|
331
|
+
clean = resolveClean(clean, outDir);
|
|
332
|
+
const pkg = await readPackageJson(cwd);
|
|
333
|
+
if (dts == null) dts = !!(pkg?.types || pkg?.typings);
|
|
334
|
+
tsconfig = await resolveTsconfig(tsconfig, cwd);
|
|
296
335
|
if (publint$1 === true) publint$1 = {};
|
|
297
|
-
if (tsconfig !== false) {
|
|
298
|
-
if (tsconfig === true || tsconfig == null) {
|
|
299
|
-
const isSet = tsconfig;
|
|
300
|
-
tsconfig = findTsconfig(cwd);
|
|
301
|
-
if (isSet && !tsconfig) logger.warn(`No tsconfig found in \`${cwd}\``);
|
|
302
|
-
} else {
|
|
303
|
-
const tsconfigPath = path.resolve(cwd, tsconfig);
|
|
304
|
-
if (await fsExists(tsconfigPath)) tsconfig = tsconfigPath;
|
|
305
|
-
else if (tsconfig.includes("\\") || tsconfig.includes("/")) {
|
|
306
|
-
logger.warn(`tsconfig \`${tsconfig}\` doesn't exist`);
|
|
307
|
-
tsconfig = false;
|
|
308
|
-
} else {
|
|
309
|
-
tsconfig = findTsconfig(cwd, tsconfig);
|
|
310
|
-
if (!tsconfig) logger.warn(`No \`${tsconfig}\` found in \`${cwd}\``);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
if (tsconfig) logger.info(`Using tsconfig: ${underline(path.relative(cwd, tsconfig))}`);
|
|
314
|
-
}
|
|
315
336
|
if (fromVite) {
|
|
316
337
|
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd);
|
|
317
338
|
if (viteUserConfig) {
|
|
@@ -327,7 +348,7 @@ async function resolveOptions(options) {
|
|
|
327
348
|
plugins,
|
|
328
349
|
format: normalizeFormat(format),
|
|
329
350
|
target: target ? resolveComma(toArray(target)) : void 0,
|
|
330
|
-
outDir
|
|
351
|
+
outDir,
|
|
331
352
|
clean,
|
|
332
353
|
silent,
|
|
333
354
|
treeshake,
|
|
@@ -343,7 +364,8 @@ async function resolveOptions(options) {
|
|
|
343
364
|
alias,
|
|
344
365
|
tsconfig,
|
|
345
366
|
cwd,
|
|
346
|
-
env
|
|
367
|
+
env,
|
|
368
|
+
pkg
|
|
347
369
|
};
|
|
348
370
|
return config;
|
|
349
371
|
}));
|
|
@@ -448,7 +470,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
448
470
|
|
|
449
471
|
//#endregion
|
|
450
472
|
//#region src/index.ts
|
|
451
|
-
const debug = Debug("tsdown:
|
|
473
|
+
const debug = Debug("tsdown:main");
|
|
452
474
|
/**
|
|
453
475
|
* Build with tsdown.
|
|
454
476
|
*/
|
|
@@ -462,7 +484,12 @@ async function build(userOptions = {}) {
|
|
|
462
484
|
debug("using resolved config: %O", config);
|
|
463
485
|
});
|
|
464
486
|
} else debug("No config file found");
|
|
465
|
-
|
|
487
|
+
let cleanPromise;
|
|
488
|
+
const clean = () => {
|
|
489
|
+
if (cleanPromise) return cleanPromise;
|
|
490
|
+
return cleanPromise = cleanOutDir(configs);
|
|
491
|
+
};
|
|
492
|
+
const rebuilds = await Promise.all(configs.map((options) => buildSingle(options, clean)));
|
|
466
493
|
const cleanCbs = [];
|
|
467
494
|
for (const [i, config] of configs.entries()) {
|
|
468
495
|
const rebuild = rebuilds[i];
|
|
@@ -472,7 +499,7 @@ async function build(userOptions = {}) {
|
|
|
472
499
|
}
|
|
473
500
|
if (cleanCbs.length) shortcuts(restart);
|
|
474
501
|
async function restart() {
|
|
475
|
-
for (const clean of cleanCbs) await clean();
|
|
502
|
+
for (const clean$1 of cleanCbs) await clean$1();
|
|
476
503
|
build(userOptions);
|
|
477
504
|
}
|
|
478
505
|
}
|
|
@@ -481,12 +508,14 @@ const pkgRoot = path.resolve(dirname$1, "..");
|
|
|
481
508
|
/**
|
|
482
509
|
* Build a single configuration, without watch and shortcuts features.
|
|
483
510
|
*
|
|
511
|
+
* Internal API, not for public use
|
|
512
|
+
*
|
|
513
|
+
* @private
|
|
484
514
|
* @param config Resolved options
|
|
485
515
|
*/
|
|
486
|
-
async function buildSingle(config) {
|
|
487
|
-
const {
|
|
516
|
+
async function buildSingle(config, clean) {
|
|
517
|
+
const { format: formats, dts, watch, onSuccess } = config;
|
|
488
518
|
let onSuccessCleanup;
|
|
489
|
-
const pkg = await readPackageJson(process.cwd());
|
|
490
519
|
const { hooks, context } = await createHooks$1(config);
|
|
491
520
|
await rebuild(true);
|
|
492
521
|
if (watch) return () => rebuild();
|
|
@@ -494,19 +523,19 @@ async function buildSingle(config) {
|
|
|
494
523
|
const startTime = performance.now();
|
|
495
524
|
await hooks.callHook("build:prepare", context);
|
|
496
525
|
onSuccessCleanup?.();
|
|
497
|
-
|
|
526
|
+
await clean();
|
|
498
527
|
let hasErrors = false;
|
|
499
528
|
await Promise.all(formats.map(async (format) => {
|
|
500
529
|
try {
|
|
501
530
|
const formatLabel = prettyFormat(format);
|
|
502
531
|
logger.info(formatLabel, "Build start");
|
|
503
|
-
const buildOptions = await getBuildOptions(config,
|
|
532
|
+
const buildOptions = await getBuildOptions(config, format);
|
|
504
533
|
await hooks.callHook("build:before", {
|
|
505
534
|
...context,
|
|
506
535
|
buildOptions
|
|
507
536
|
});
|
|
508
537
|
await build$1(buildOptions);
|
|
509
|
-
if (format === "cjs" && dts) await build$1(await getBuildOptions(config,
|
|
538
|
+
if (format === "cjs" && dts) await build$1(await getBuildOptions(config, format, true));
|
|
510
539
|
} catch (error) {
|
|
511
540
|
if (watch) {
|
|
512
541
|
logger.error(error);
|
|
@@ -518,7 +547,7 @@ async function buildSingle(config) {
|
|
|
518
547
|
}));
|
|
519
548
|
if (hasErrors) return;
|
|
520
549
|
await hooks.callHook("build:done", context);
|
|
521
|
-
if (config.publint) if (pkg) await publint(pkg);
|
|
550
|
+
if (config.publint) if (config.pkg) await publint(config.pkg, config.publint === true ? {} : config.publint);
|
|
522
551
|
else logger.warn("publint is enabled but package.json is not found");
|
|
523
552
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${green(`${Math.round(performance.now() - startTime)}ms`)}`);
|
|
524
553
|
if (typeof onSuccess === "string") {
|
|
@@ -533,10 +562,10 @@ async function buildSingle(config) {
|
|
|
533
562
|
} else await onSuccess?.(config);
|
|
534
563
|
}
|
|
535
564
|
}
|
|
536
|
-
async function getBuildOptions(config,
|
|
565
|
+
async function getBuildOptions(config, format, cjsDts) {
|
|
537
566
|
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env } = config;
|
|
538
567
|
const plugins = [];
|
|
539
|
-
if (pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config
|
|
568
|
+
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
540
569
|
if (dts) {
|
|
541
570
|
const { dts: dtsPlugin } = await import("rolldown-plugin-dts");
|
|
542
571
|
const options = {
|
|
@@ -590,7 +619,7 @@ async function getBuildOptions(config, pkg, format, cjsDts) {
|
|
|
590
619
|
plugins,
|
|
591
620
|
inject: { ...shims && !cjsDts && getShimsInject(format, platform) }
|
|
592
621
|
}, config.inputOptions, [format]);
|
|
593
|
-
const [entryFileNames, chunkFileNames] = resolveChunkFilename(
|
|
622
|
+
const [entryFileNames, chunkFileNames] = resolveChunkFilename(config, inputOptions, format);
|
|
594
623
|
const outputOptions = await mergeUserOptions({
|
|
595
624
|
format: cjsDts ? "es" : format,
|
|
596
625
|
name: config.globalName,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { version } from "./package-
|
|
1
|
+
import { version } from "./package-DfgxaSyP.js";
|
|
2
2
|
import process from "node:process";
|
|
3
|
+
import { green, underline } from "ansis";
|
|
3
4
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
4
5
|
import consola$1 from "consola";
|
|
5
6
|
import { existsSync } from "node:fs";
|
|
@@ -8,7 +9,7 @@ import { existsSync } from "node:fs";
|
|
|
8
9
|
async function migrate({ cwd, dryRun }) {
|
|
9
10
|
if (dryRun) consola$1.info("Dry run enabled. No changes were made.");
|
|
10
11
|
else {
|
|
11
|
-
const confirm = await consola$1.prompt(
|
|
12
|
+
const confirm = await consola$1.prompt(`Before proceeding, review the migration guide at ${underline`https://tsdown.dev/guide/migrate-from-tsup`}, as this process will modify your files.\nUncommitted changes will be lost. Use the ${green`--dry-run`} flag to preview changes without applying them.\n\nContinue?`, { type: "confirm" });
|
|
12
13
|
if (!confirm) {
|
|
13
14
|
consola$1.error("Migration cancelled.");
|
|
14
15
|
process.exitCode = 1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, ModuleFormat, OutputOptions, Plugin } from "rolldown";
|
|
1
|
+
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, OutputOptions, Plugin } from "rolldown";
|
|
2
2
|
import { Hookable } from "hookable";
|
|
3
3
|
import { Options } from "publint";
|
|
4
4
|
import { Options as Options$1 } from "rolldown-plugin-dts";
|
|
@@ -51,7 +51,7 @@ interface OutExtensionObject {
|
|
|
51
51
|
js?: string;
|
|
52
52
|
dts?: string;
|
|
53
53
|
}
|
|
54
|
-
type OutExtensionFactory = (
|
|
54
|
+
type OutExtensionFactory = (context: OutExtensionContext) => OutExtensionObject | undefined;
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/features/report.d.ts
|
|
@@ -83,11 +83,6 @@ type Arrayable<T> = T | T[];
|
|
|
83
83
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
84
84
|
type Format = Exclude<ModuleFormat, "experimental-app">;
|
|
85
85
|
type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
|
|
86
|
-
interface MinifyOptions {
|
|
87
|
-
mangle?: boolean;
|
|
88
|
-
compress?: boolean;
|
|
89
|
-
removeWhitespace?: boolean;
|
|
90
|
-
}
|
|
91
86
|
|
|
92
87
|
/**
|
|
93
88
|
* Options for tsdown.
|
|
@@ -107,6 +102,11 @@ interface Options$3 {
|
|
|
107
102
|
/** @default 'dist' */
|
|
108
103
|
outDir?: string;
|
|
109
104
|
sourcemap?: Sourcemap;
|
|
105
|
+
/**
|
|
106
|
+
* Clean directories before build.
|
|
107
|
+
*
|
|
108
|
+
* Default to output directory.
|
|
109
|
+
*/
|
|
110
110
|
clean?: boolean | string[];
|
|
111
111
|
/** @default false */
|
|
112
112
|
minify?: boolean | "dce-only" | MinifyOptions;
|
|
@@ -150,7 +150,11 @@ interface Options$3 {
|
|
|
150
150
|
*/
|
|
151
151
|
fromVite?: boolean | "vitest";
|
|
152
152
|
/**
|
|
153
|
-
* Emit declaration files
|
|
153
|
+
* Emit TypeScript declaration files (.d.ts).
|
|
154
|
+
*
|
|
155
|
+
* By default, this feature is auto-detected based on the presence of the `types` field in the `package.json` file.
|
|
156
|
+
* - If the `types` field is present in `package.json`, declaration file emission is enabled.
|
|
157
|
+
* - If the `types` field is absent, declaration file emission is disabled by default.
|
|
154
158
|
*/
|
|
155
159
|
dts?: boolean | Options$1;
|
|
156
160
|
/**
|
|
@@ -171,7 +175,7 @@ interface Options$3 {
|
|
|
171
175
|
/**
|
|
172
176
|
* Compile-time env variables.
|
|
173
177
|
* @example
|
|
174
|
-
* ```
|
|
178
|
+
* ```json
|
|
175
179
|
* {
|
|
176
180
|
* "DEBUG": true,
|
|
177
181
|
* "NODE_ENV": "production"
|
|
@@ -190,11 +194,12 @@ type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
|
190
194
|
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks">, {
|
|
191
195
|
format: NormalizedFormat[];
|
|
192
196
|
target?: string[];
|
|
193
|
-
clean: string[]
|
|
197
|
+
clean: string[];
|
|
194
198
|
dts: false | Options$1;
|
|
195
199
|
report: false | ReportOptions;
|
|
196
200
|
tsconfig: string | false;
|
|
197
201
|
cwd: string;
|
|
202
|
+
pkg?: PackageJson;
|
|
198
203
|
}>, "config" | "fromVite">;
|
|
199
204
|
|
|
200
205
|
//#endregion
|
|
@@ -41,8 +41,8 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
41
41
|
//#region src/features/external.ts
|
|
42
42
|
const debug$2 = Debug("tsdown:external");
|
|
43
43
|
const RE_DTS$1 = /\.d\.[cm]?ts$/;
|
|
44
|
-
function ExternalPlugin(options
|
|
45
|
-
const deps = pkg && Array.from(getProductionDeps(pkg));
|
|
44
|
+
function ExternalPlugin(options) {
|
|
45
|
+
const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
|
|
46
46
|
return {
|
|
47
47
|
name: "tsdown:external",
|
|
48
48
|
async resolveId(id, importer, { isEntry }) {
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options.d
|
|
1
|
+
import { ReportPlugin$1 as ReportPlugin, ResolvedOptions } from "./options.d--a1aWVL6.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
|
-
declare function ExternalPlugin(options: ResolvedOptions
|
|
6
|
+
declare function ExternalPlugin(options: ResolvedOptions): Plugin;
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/features/shebang.d.ts
|
package/dist/plugins.js
CHANGED
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-
|
|
3
|
+
import { version } from "./package-DfgxaSyP.js";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { dim } from "ansis";
|
|
6
6
|
import Debug from "debug";
|
|
@@ -11,7 +11,7 @@ import { cac } from "cac";
|
|
|
11
11
|
//#region src/cli.ts
|
|
12
12
|
const cli = cac("tsdown");
|
|
13
13
|
cli.help().version(version);
|
|
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("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [scope]", "Show debug logs").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("--dts", "Generate dts files"
|
|
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("--external <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--debug [scope]", "Show debug logs").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("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").action(async (input, flags) => {
|
|
15
15
|
setSilent(!!flags.silent);
|
|
16
16
|
logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
17
17
|
const { build: build$1 } = await import("./index.js");
|
|
@@ -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-
|
|
22
|
+
const { migrate } = await import("./migrate-CowIU0R_.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.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"empathic": "^1.0.0",
|
|
64
64
|
"hookable": "^5.5.3",
|
|
65
65
|
"lightningcss": "^1.29.3",
|
|
66
|
-
"rolldown": "1.0.0-beta.8-commit.
|
|
67
|
-
"rolldown-plugin-dts": "^0.9.
|
|
66
|
+
"rolldown": "1.0.0-beta.8-commit.852c603",
|
|
67
|
+
"rolldown-plugin-dts": "^0.9.5",
|
|
68
68
|
"tinyexec": "^1.0.1",
|
|
69
69
|
"tinyglobby": "^0.2.13",
|
|
70
70
|
"unconfig": "^7.3.2",
|