tsdown 0.9.9 → 0.10.0
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-DpTGFaWV.d.ts} +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +83 -55
- package/dist/{migrate-CygdeFLJ.js → migrate-Cq1rvewL.js} +3 -2
- package/dist/{options.d-DF6uzkZt.d.ts → options.d-C1wrHXGf.d.ts} +12 -2
- package/dist/package-D9H_HrcE.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 +2 -2
- 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-C1wrHXGf.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-DpTGFaWV.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-C1wrHXGf.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-DpTGFaWV.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;
|
|
@@ -133,13 +143,13 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
|
133
143
|
|
|
134
144
|
//#endregion
|
|
135
145
|
//#region src/features/publint.ts
|
|
136
|
-
const debug$
|
|
146
|
+
const debug$2 = Debug("tsdown:publint");
|
|
137
147
|
async function publint(pkg) {
|
|
138
|
-
debug$
|
|
148
|
+
debug$2("Running publint");
|
|
139
149
|
const { publint: publint$1 } = await import("publint");
|
|
140
150
|
const { formatMessage } = await import("publint/utils");
|
|
141
151
|
const { messages } = await publint$1();
|
|
142
|
-
debug$
|
|
152
|
+
debug$2("Found %d issues", messages.length);
|
|
143
153
|
if (!messages.length) logger.success("No publint issues found");
|
|
144
154
|
let hasError = false;
|
|
145
155
|
for (const message of messages) {
|
|
@@ -153,7 +163,7 @@ async function publint(pkg) {
|
|
|
153
163
|
logger[logType](formattedMessage);
|
|
154
164
|
}
|
|
155
165
|
if (hasError) {
|
|
156
|
-
debug$
|
|
166
|
+
debug$2("Found errors, setting exit code to 1");
|
|
157
167
|
process.exitCode = 1;
|
|
158
168
|
}
|
|
159
169
|
}
|
|
@@ -275,43 +285,53 @@ async function toObjectEntry(entry, cwd) {
|
|
|
275
285
|
}
|
|
276
286
|
|
|
277
287
|
//#endregion
|
|
278
|
-
//#region src/
|
|
288
|
+
//#region src/features/tsconfig.ts
|
|
279
289
|
function findTsconfig(cwd, name = "tsconfig.json") {
|
|
280
290
|
return up(name, { cwd }) || false;
|
|
281
291
|
}
|
|
292
|
+
async function resolveTsconfig(tsconfig, cwd) {
|
|
293
|
+
if (tsconfig !== false) {
|
|
294
|
+
if (tsconfig === true || tsconfig == null) {
|
|
295
|
+
const isSet = tsconfig;
|
|
296
|
+
tsconfig = findTsconfig(cwd);
|
|
297
|
+
if (isSet && !tsconfig) logger.warn(`No tsconfig found in \`${cwd}\``);
|
|
298
|
+
} else {
|
|
299
|
+
const tsconfigPath = path.resolve(cwd, tsconfig);
|
|
300
|
+
if (await fsExists(tsconfigPath)) tsconfig = tsconfigPath;
|
|
301
|
+
else if (tsconfig.includes("\\") || tsconfig.includes("/")) {
|
|
302
|
+
logger.warn(`tsconfig \`${tsconfig}\` doesn't exist`);
|
|
303
|
+
tsconfig = false;
|
|
304
|
+
} else {
|
|
305
|
+
tsconfig = findTsconfig(cwd, tsconfig);
|
|
306
|
+
if (!tsconfig) logger.warn(`No \`${tsconfig}\` found in \`${cwd}\``);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (tsconfig) logger.info(`Using tsconfig: ${underline(path.relative(cwd, tsconfig))}`);
|
|
310
|
+
}
|
|
311
|
+
return tsconfig;
|
|
312
|
+
}
|
|
282
313
|
|
|
283
314
|
//#endregion
|
|
284
315
|
//#region src/options.ts
|
|
316
|
+
const debug$1 = Debug("tsdown:options");
|
|
285
317
|
async function resolveOptions(options) {
|
|
286
318
|
const { configs: userConfigs, file, cwd } = await loadConfigFile(options);
|
|
287
319
|
if (userConfigs.length === 0) userConfigs.push({});
|
|
320
|
+
debug$1("Loaded config file %s from %s", file, cwd);
|
|
321
|
+
debug$1("User configs %o", userConfigs);
|
|
288
322
|
const configs = await Promise.all(userConfigs.map(async (subConfig) => {
|
|
289
323
|
const subOptions = {
|
|
290
324
|
...subConfig,
|
|
291
325
|
...options
|
|
292
326
|
};
|
|
293
|
-
let { entry, format = ["es"], plugins = [], clean =
|
|
327
|
+
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;
|
|
328
|
+
outDir = path.resolve(outDir);
|
|
294
329
|
entry = await resolveEntry(entry, cwd);
|
|
295
|
-
|
|
330
|
+
clean = resolveClean(clean, outDir);
|
|
331
|
+
const pkg = await readPackageJson(cwd);
|
|
332
|
+
if (dts == null) dts = !!(pkg?.types || pkg?.typings);
|
|
333
|
+
tsconfig = await resolveTsconfig(tsconfig, cwd);
|
|
296
334
|
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
335
|
if (fromVite) {
|
|
316
336
|
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd);
|
|
317
337
|
if (viteUserConfig) {
|
|
@@ -327,7 +347,7 @@ async function resolveOptions(options) {
|
|
|
327
347
|
plugins,
|
|
328
348
|
format: normalizeFormat(format),
|
|
329
349
|
target: target ? resolveComma(toArray(target)) : void 0,
|
|
330
|
-
outDir
|
|
350
|
+
outDir,
|
|
331
351
|
clean,
|
|
332
352
|
silent,
|
|
333
353
|
treeshake,
|
|
@@ -343,7 +363,8 @@ async function resolveOptions(options) {
|
|
|
343
363
|
alias,
|
|
344
364
|
tsconfig,
|
|
345
365
|
cwd,
|
|
346
|
-
env
|
|
366
|
+
env,
|
|
367
|
+
pkg
|
|
347
368
|
};
|
|
348
369
|
return config;
|
|
349
370
|
}));
|
|
@@ -448,7 +469,7 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
448
469
|
|
|
449
470
|
//#endregion
|
|
450
471
|
//#region src/index.ts
|
|
451
|
-
const debug = Debug("tsdown:
|
|
472
|
+
const debug = Debug("tsdown:main");
|
|
452
473
|
/**
|
|
453
474
|
* Build with tsdown.
|
|
454
475
|
*/
|
|
@@ -462,7 +483,12 @@ async function build(userOptions = {}) {
|
|
|
462
483
|
debug("using resolved config: %O", config);
|
|
463
484
|
});
|
|
464
485
|
} else debug("No config file found");
|
|
465
|
-
|
|
486
|
+
let cleanPromise;
|
|
487
|
+
const clean = () => {
|
|
488
|
+
if (cleanPromise) return cleanPromise;
|
|
489
|
+
return cleanPromise = cleanOutDir(configs);
|
|
490
|
+
};
|
|
491
|
+
const rebuilds = await Promise.all(configs.map((options) => buildSingle(options, clean)));
|
|
466
492
|
const cleanCbs = [];
|
|
467
493
|
for (const [i, config] of configs.entries()) {
|
|
468
494
|
const rebuild = rebuilds[i];
|
|
@@ -472,7 +498,7 @@ async function build(userOptions = {}) {
|
|
|
472
498
|
}
|
|
473
499
|
if (cleanCbs.length) shortcuts(restart);
|
|
474
500
|
async function restart() {
|
|
475
|
-
for (const clean of cleanCbs) await clean();
|
|
501
|
+
for (const clean$1 of cleanCbs) await clean$1();
|
|
476
502
|
build(userOptions);
|
|
477
503
|
}
|
|
478
504
|
}
|
|
@@ -481,12 +507,14 @@ const pkgRoot = path.resolve(dirname$1, "..");
|
|
|
481
507
|
/**
|
|
482
508
|
* Build a single configuration, without watch and shortcuts features.
|
|
483
509
|
*
|
|
510
|
+
* Internal API, not for public use
|
|
511
|
+
*
|
|
512
|
+
* @private
|
|
484
513
|
* @param config Resolved options
|
|
485
514
|
*/
|
|
486
|
-
async function buildSingle(config) {
|
|
487
|
-
const {
|
|
515
|
+
async function buildSingle(config, clean) {
|
|
516
|
+
const { format: formats, dts, watch, onSuccess } = config;
|
|
488
517
|
let onSuccessCleanup;
|
|
489
|
-
const pkg = await readPackageJson(process.cwd());
|
|
490
518
|
const { hooks, context } = await createHooks$1(config);
|
|
491
519
|
await rebuild(true);
|
|
492
520
|
if (watch) return () => rebuild();
|
|
@@ -494,19 +522,19 @@ async function buildSingle(config) {
|
|
|
494
522
|
const startTime = performance.now();
|
|
495
523
|
await hooks.callHook("build:prepare", context);
|
|
496
524
|
onSuccessCleanup?.();
|
|
497
|
-
|
|
525
|
+
await clean();
|
|
498
526
|
let hasErrors = false;
|
|
499
527
|
await Promise.all(formats.map(async (format) => {
|
|
500
528
|
try {
|
|
501
529
|
const formatLabel = prettyFormat(format);
|
|
502
530
|
logger.info(formatLabel, "Build start");
|
|
503
|
-
const buildOptions = await getBuildOptions(config,
|
|
531
|
+
const buildOptions = await getBuildOptions(config, format);
|
|
504
532
|
await hooks.callHook("build:before", {
|
|
505
533
|
...context,
|
|
506
534
|
buildOptions
|
|
507
535
|
});
|
|
508
536
|
await build$1(buildOptions);
|
|
509
|
-
if (format === "cjs" && dts) await build$1(await getBuildOptions(config,
|
|
537
|
+
if (format === "cjs" && dts) await build$1(await getBuildOptions(config, format, true));
|
|
510
538
|
} catch (error) {
|
|
511
539
|
if (watch) {
|
|
512
540
|
logger.error(error);
|
|
@@ -518,7 +546,7 @@ async function buildSingle(config) {
|
|
|
518
546
|
}));
|
|
519
547
|
if (hasErrors) return;
|
|
520
548
|
await hooks.callHook("build:done", context);
|
|
521
|
-
if (config.publint) if (pkg) await publint(pkg);
|
|
549
|
+
if (config.publint) if (config.pkg) await publint(config.pkg);
|
|
522
550
|
else logger.warn("publint is enabled but package.json is not found");
|
|
523
551
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${green(`${Math.round(performance.now() - startTime)}ms`)}`);
|
|
524
552
|
if (typeof onSuccess === "string") {
|
|
@@ -533,10 +561,10 @@ async function buildSingle(config) {
|
|
|
533
561
|
} else await onSuccess?.(config);
|
|
534
562
|
}
|
|
535
563
|
}
|
|
536
|
-
async function getBuildOptions(config,
|
|
564
|
+
async function getBuildOptions(config, format, cjsDts) {
|
|
537
565
|
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env } = config;
|
|
538
566
|
const plugins = [];
|
|
539
|
-
if (pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config
|
|
567
|
+
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
540
568
|
if (dts) {
|
|
541
569
|
const { dts: dtsPlugin } = await import("rolldown-plugin-dts");
|
|
542
570
|
const options = {
|
|
@@ -590,7 +618,7 @@ async function getBuildOptions(config, pkg, format, cjsDts) {
|
|
|
590
618
|
plugins,
|
|
591
619
|
inject: { ...shims && !cjsDts && getShimsInject(format, platform) }
|
|
592
620
|
}, config.inputOptions, [format]);
|
|
593
|
-
const [entryFileNames, chunkFileNames] = resolveChunkFilename(
|
|
621
|
+
const [entryFileNames, chunkFileNames] = resolveChunkFilename(config, inputOptions, format);
|
|
594
622
|
const outputOptions = await mergeUserOptions({
|
|
595
623
|
format: cjsDts ? "es" : format,
|
|
596
624
|
name: config.globalName,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { version } from "./package-
|
|
1
|
+
import { version } from "./package-D9H_HrcE.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;
|
|
@@ -107,6 +107,11 @@ interface Options$3 {
|
|
|
107
107
|
/** @default 'dist' */
|
|
108
108
|
outDir?: string;
|
|
109
109
|
sourcemap?: Sourcemap;
|
|
110
|
+
/**
|
|
111
|
+
* Clean directories before build.
|
|
112
|
+
*
|
|
113
|
+
* Default to output directory.
|
|
114
|
+
*/
|
|
110
115
|
clean?: boolean | string[];
|
|
111
116
|
/** @default false */
|
|
112
117
|
minify?: boolean | "dce-only" | MinifyOptions;
|
|
@@ -150,7 +155,11 @@ interface Options$3 {
|
|
|
150
155
|
*/
|
|
151
156
|
fromVite?: boolean | "vitest";
|
|
152
157
|
/**
|
|
153
|
-
* Emit declaration files
|
|
158
|
+
* Emit TypeScript declaration files (.d.ts).
|
|
159
|
+
*
|
|
160
|
+
* By default, this feature is auto-detected based on the presence of the `types` field in the `package.json` file.
|
|
161
|
+
* - If the `types` field is present in `package.json`, declaration file emission is enabled.
|
|
162
|
+
* - If the `types` field is absent, declaration file emission is disabled by default.
|
|
154
163
|
*/
|
|
155
164
|
dts?: boolean | Options$1;
|
|
156
165
|
/**
|
|
@@ -190,11 +199,12 @@ type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
|
190
199
|
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks">, {
|
|
191
200
|
format: NormalizedFormat[];
|
|
192
201
|
target?: string[];
|
|
193
|
-
clean: string[]
|
|
202
|
+
clean: string[];
|
|
194
203
|
dts: false | Options$1;
|
|
195
204
|
report: false | ReportOptions;
|
|
196
205
|
tsconfig: string | false;
|
|
197
206
|
cwd: string;
|
|
207
|
+
pkg?: PackageJson;
|
|
198
208
|
}>, "config" | "fromVite">;
|
|
199
209
|
|
|
200
210
|
//#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-C1wrHXGf.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-D9H_HrcE.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-Cq1rvewL.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.0",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"hookable": "^5.5.3",
|
|
65
65
|
"lightningcss": "^1.29.3",
|
|
66
66
|
"rolldown": "1.0.0-beta.8-commit.151352b",
|
|
67
|
-
"rolldown-plugin-dts": "^0.9.
|
|
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",
|