tsdown 0.11.8 → 0.11.10
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-DILVUP_s.d.ts → config-Cyqx6Xup.d.ts} +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/{index-BoDsEHb5.d.ts → index-B5B9KM9d.d.ts} +6 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +99 -59
- package/dist/{migrate-DJbJNdWb.js → migrate-Bt-9GxhE.js} +1 -1
- package/dist/package-DNOe3jsX.js +5 -0
- package/dist/{plugins-G7Z0rtO5.js → plugins-AcF8M16F.js} +9 -9
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -1
- package/dist/run.js +7 -7
- package/package.json +13 -13
- package/dist/package-BjzIq4Wm.js +0 -5
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./index-
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./index-B5B9KM9d.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config-Cyqx6Xup.js";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
|
@@ -296,13 +296,17 @@ interface Options$3 {
|
|
|
296
296
|
* This allows you to build multiple packages in a monorepo.
|
|
297
297
|
*/
|
|
298
298
|
workspace?: Workspace | Arrayable<string> | true;
|
|
299
|
+
/**
|
|
300
|
+
* Filter workspace packages. This option is only available in workspace mode.
|
|
301
|
+
*/
|
|
302
|
+
filter?: RegExp | string | string[];
|
|
299
303
|
}
|
|
300
304
|
/**
|
|
301
305
|
* Options without specifying config file path.
|
|
302
306
|
*/
|
|
303
|
-
type UserConfig = Arrayable<Omit<Options$3, "config">>;
|
|
307
|
+
type UserConfig = Arrayable<Omit<Options$3, "config" | "filter">>;
|
|
304
308
|
type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
305
|
-
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" | "workspace">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name">, {
|
|
309
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name">, {
|
|
306
310
|
format: NormalizedFormat[];
|
|
307
311
|
target?: string[];
|
|
308
312
|
clean: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./index-
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config-
|
|
1
|
+
import { BuildContext, Options, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn } from "./index-B5B9KM9d.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config-Cyqx6Xup.js";
|
|
3
3
|
import "ansis";
|
|
4
4
|
import { InternalModuleFormat } from "rolldown";
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { defineConfig } from "./config-yiJy1jd0.js";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin, fsCopy, fsRemove, fsStat, lowestCommonAncestor } from "./plugins-AcF8M16F.js";
|
|
3
3
|
import { debounce, generateColor, logger, prettyName, resolveComma, slash, toArray } from "./logger-BdIBA2vO.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import { blue, bold, dim, green, underline } from "ansis";
|
|
8
|
-
import Debug from "debug";
|
|
9
8
|
import { build as build$1 } from "rolldown";
|
|
10
9
|
import { transformPlugin } from "rolldown/experimental";
|
|
11
10
|
import { exec } from "tinyexec";
|
|
11
|
+
import debug from "debug";
|
|
12
12
|
import { glob } from "tinyglobby";
|
|
13
13
|
import { readFile } from "node:fs/promises";
|
|
14
14
|
import { createHooks } from "hookable";
|
|
@@ -19,7 +19,7 @@ import { up as up$1 } from "empathic/find";
|
|
|
19
19
|
import { loadConfig } from "unconfig";
|
|
20
20
|
|
|
21
21
|
//#region src/features/clean.ts
|
|
22
|
-
const debug$4 =
|
|
22
|
+
const debug$4 = debug("tsdown:clean");
|
|
23
23
|
const RE_LAST_SLASH = /[/\\]$/;
|
|
24
24
|
async function cleanOutDir(configs) {
|
|
25
25
|
const removes = new Set();
|
|
@@ -136,7 +136,7 @@ async function LightningCSSPlugin(options) {
|
|
|
136
136
|
|
|
137
137
|
//#endregion
|
|
138
138
|
//#region src/utils/package.ts
|
|
139
|
-
const debug$3 =
|
|
139
|
+
const debug$3 = debug("tsdown:package");
|
|
140
140
|
async function readPackageJson(dir) {
|
|
141
141
|
const packageJsonPath = up({ cwd: dir });
|
|
142
142
|
if (!packageJsonPath) return;
|
|
@@ -198,19 +198,20 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
|
198
198
|
|
|
199
199
|
//#endregion
|
|
200
200
|
//#region src/features/publint.ts
|
|
201
|
-
const debug$2 =
|
|
201
|
+
const debug$2 = debug("tsdown:publint");
|
|
202
202
|
async function publint(options) {
|
|
203
203
|
if (!options.publint) return;
|
|
204
204
|
if (!options.pkg) {
|
|
205
205
|
logger.warn("publint is enabled but package.json is not found");
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
+
const t = performance.now();
|
|
208
209
|
debug$2("Running publint");
|
|
209
210
|
const { publint: publint$1 } = await import("publint");
|
|
210
211
|
const { formatMessage } = await import("publint/utils");
|
|
211
212
|
const { messages } = await publint$1(options.publint === true ? {} : options.publint);
|
|
212
213
|
debug$2("Found %d issues", messages.length);
|
|
213
|
-
if (!messages.length) logger.success(
|
|
214
|
+
if (!messages.length) logger.success(`No publint issues found`, dim`(${Math.round(performance.now() - t)}ms)`);
|
|
214
215
|
let hasError = false;
|
|
215
216
|
for (const message of messages) {
|
|
216
217
|
hasError ||= message.type === "error";
|
|
@@ -291,14 +292,61 @@ function shortcuts(restart) {
|
|
|
291
292
|
rl.on("line", onInput);
|
|
292
293
|
}
|
|
293
294
|
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/features/target.ts
|
|
297
|
+
function resolveTarget(target, pkg, name) {
|
|
298
|
+
if (target === false) return;
|
|
299
|
+
if (target == null) {
|
|
300
|
+
const pkgTarget = resolvePackageTarget(pkg);
|
|
301
|
+
if (pkgTarget) target = pkgTarget;
|
|
302
|
+
else return;
|
|
303
|
+
}
|
|
304
|
+
const targets = resolveComma(toArray(target));
|
|
305
|
+
if (targets.length) logger.info(prettyName(name), `target${targets.length > 1 ? "s" : ""}: ${generateColor(name)(targets.join(", "))}`);
|
|
306
|
+
return targets;
|
|
307
|
+
}
|
|
308
|
+
function resolvePackageTarget(pkg) {
|
|
309
|
+
const nodeVersion = pkg?.engines?.node;
|
|
310
|
+
if (!nodeVersion) return;
|
|
311
|
+
const nodeMinVersion = minVersion(nodeVersion);
|
|
312
|
+
if (!nodeMinVersion) return;
|
|
313
|
+
if (nodeMinVersion.version === "0.0.0") return;
|
|
314
|
+
return `node${nodeMinVersion.version}`;
|
|
315
|
+
}
|
|
316
|
+
let warned = false;
|
|
317
|
+
function RuntimeHelperCheckPlugin(targets) {
|
|
318
|
+
return {
|
|
319
|
+
name: "tsdown:runtime-helper-check",
|
|
320
|
+
resolveId: {
|
|
321
|
+
filter: { id: /^@oxc-project\/runtime/ },
|
|
322
|
+
async handler(id, ...args) {
|
|
323
|
+
const EXTERNAL = {
|
|
324
|
+
id,
|
|
325
|
+
external: true
|
|
326
|
+
};
|
|
327
|
+
if (warned) return EXTERNAL;
|
|
328
|
+
const resolved = await this.resolve(id, ...args);
|
|
329
|
+
if (!resolved) {
|
|
330
|
+
if (!warned) {
|
|
331
|
+
warned = true;
|
|
332
|
+
logger.warn(`The target environment (${targets.join(", ")}) requires runtime helpers from ${blue`@oxc-project/runtime`}. Please install it to ensure all necessary polyfills are included.\nFor more information, visit: https://tsdown.dev/options/target#runtime-helpers`);
|
|
333
|
+
}
|
|
334
|
+
return EXTERNAL;
|
|
335
|
+
}
|
|
336
|
+
return resolved;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
294
342
|
//#endregion
|
|
295
343
|
//#region src/features/watch.ts
|
|
296
|
-
const
|
|
297
|
-
async function watchBuild(options,
|
|
344
|
+
const endsWithConfig = /[\\/](?:package\.json|tsdown\.config.*)$/;
|
|
345
|
+
async function watchBuild(options, configFiles, rebuild, restart) {
|
|
298
346
|
if (typeof options.watch === "boolean" && options.outDir === options.cwd) throw new Error(`Watch is enabled, but output directory is the same as the current working directory.Please specify a different watch directory using ${blue`watch`} option,or set ${blue`outDir`} to a different directory.`);
|
|
299
347
|
const files = toArray(typeof options.watch === "boolean" ? options.cwd : options.watch);
|
|
300
348
|
logger.info(`Watching for changes in ${files.join(", ")}`);
|
|
301
|
-
|
|
349
|
+
files.push(...configFiles);
|
|
302
350
|
const { watch } = await import("chokidar");
|
|
303
351
|
const debouncedRebuild = debounce(rebuild, 100);
|
|
304
352
|
const watcher = watch(files, {
|
|
@@ -311,7 +359,7 @@ async function watchBuild(options, configFile, rebuild, restart) {
|
|
|
311
359
|
]
|
|
312
360
|
});
|
|
313
361
|
watcher.on("all", (type, file) => {
|
|
314
|
-
if (
|
|
362
|
+
if (configFiles.includes(file) || endsWithConfig.test(file)) {
|
|
315
363
|
logger.info(`Reload config: ${file}`);
|
|
316
364
|
restart();
|
|
317
365
|
return;
|
|
@@ -325,13 +373,11 @@ async function watchBuild(options, configFile, rebuild, restart) {
|
|
|
325
373
|
//#endregion
|
|
326
374
|
//#region src/features/entry.ts
|
|
327
375
|
async function resolveEntry(entry, cwd, name) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
throw new Error(`${nameLabel}No input files, try "tsdown <your-file>" instead`);
|
|
331
|
-
}
|
|
376
|
+
const nameLabel = name ? `[${name}] ` : "";
|
|
377
|
+
if (!entry || Object.keys(entry).length === 0) throw new Error(`${nameLabel}No input files, try "tsdown <your-file>" instead`);
|
|
332
378
|
const entryMap = await toObjectEntry(entry, cwd);
|
|
333
379
|
const entries = Object.values(entryMap);
|
|
334
|
-
if (entries.length === 0) throw new Error(
|
|
380
|
+
if (entries.length === 0) throw new Error(`${nameLabel}Cannot find entry: ${JSON.stringify(entry)}`);
|
|
335
381
|
logger.info(prettyName(name), `entry: ${generateColor(name)(entries.map((entry$1) => path.relative(cwd, entry$1)).join(", "))}`);
|
|
336
382
|
return entryMap;
|
|
337
383
|
}
|
|
@@ -349,28 +395,6 @@ async function toObjectEntry(entry, cwd) {
|
|
|
349
395
|
}));
|
|
350
396
|
}
|
|
351
397
|
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region src/features/target.ts
|
|
354
|
-
function resolveTarget(target, pkg, name) {
|
|
355
|
-
if (target === false) return;
|
|
356
|
-
if (target == null) {
|
|
357
|
-
const pkgTarget = resolvePackageTarget(pkg);
|
|
358
|
-
if (pkgTarget) target = pkgTarget;
|
|
359
|
-
else return;
|
|
360
|
-
}
|
|
361
|
-
const targets = resolveComma(toArray(target));
|
|
362
|
-
if (targets.length) logger.info(prettyName(name), `target${targets.length > 1 ? "s" : ""}: ${generateColor(name)(targets.join(", "))}`);
|
|
363
|
-
return targets;
|
|
364
|
-
}
|
|
365
|
-
function resolvePackageTarget(pkg) {
|
|
366
|
-
const nodeVersion = pkg?.engines?.node;
|
|
367
|
-
if (!nodeVersion) return;
|
|
368
|
-
const nodeMinVersion = minVersion(nodeVersion);
|
|
369
|
-
if (!nodeMinVersion) return;
|
|
370
|
-
if (nodeMinVersion.version === "0.0.0") return;
|
|
371
|
-
return `node${nodeMinVersion.version}`;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
398
|
//#endregion
|
|
375
399
|
//#region src/features/tsconfig.ts
|
|
376
400
|
function findTsconfig(cwd, name = "tsconfig.json") {
|
|
@@ -489,7 +513,7 @@ async function loadConfigFile(options, workspace) {
|
|
|
489
513
|
|
|
490
514
|
//#endregion
|
|
491
515
|
//#region src/options/index.ts
|
|
492
|
-
const debug$1 =
|
|
516
|
+
const debug$1 = debug("tsdown:options");
|
|
493
517
|
const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
494
518
|
"**/node_modules/**",
|
|
495
519
|
"**/dist/**",
|
|
@@ -497,19 +521,24 @@ const DEFAULT_EXCLUDE_WORKSPACE = [
|
|
|
497
521
|
"**/t?(e)mp/**"
|
|
498
522
|
];
|
|
499
523
|
async function resolveOptions(options) {
|
|
524
|
+
const files = [];
|
|
525
|
+
debug$1("options %O", options);
|
|
526
|
+
debug$1("loading config file: %s", options.config);
|
|
500
527
|
const { configs: rootConfigs, file } = await loadConfigFile(options);
|
|
501
528
|
if (file) {
|
|
502
|
-
|
|
503
|
-
debug$1("
|
|
504
|
-
|
|
529
|
+
files.push(file);
|
|
530
|
+
debug$1("loaded root config file %s", file);
|
|
531
|
+
debug$1("root configs %o", rootConfigs);
|
|
532
|
+
} else debug$1("no root config file found");
|
|
505
533
|
const configs = (await Promise.all(rootConfigs.map(async (rootConfig) => {
|
|
506
|
-
const workspaceConfigs = await resolveWorkspace(rootConfig, options);
|
|
507
|
-
|
|
534
|
+
const { configs: workspaceConfigs, files: workspaceFiles } = await resolveWorkspace(rootConfig, options);
|
|
535
|
+
if (workspaceFiles) files.push(...workspaceFiles);
|
|
536
|
+
return Promise.all(workspaceConfigs.filter((config) => !config.workspace || config.entry?.length).map((config) => resolveConfig(config)));
|
|
508
537
|
}))).flat();
|
|
509
|
-
debug$1("
|
|
538
|
+
debug$1("resolved configs %O", configs);
|
|
510
539
|
return {
|
|
511
540
|
configs,
|
|
512
|
-
|
|
541
|
+
files
|
|
513
542
|
};
|
|
514
543
|
}
|
|
515
544
|
async function resolveWorkspace(config, options) {
|
|
@@ -519,7 +548,10 @@ async function resolveWorkspace(config, options) {
|
|
|
519
548
|
};
|
|
520
549
|
const rootCwd = normalized.cwd || process.cwd();
|
|
521
550
|
let { workspace } = normalized;
|
|
522
|
-
if (!workspace) return
|
|
551
|
+
if (!workspace) return {
|
|
552
|
+
configs: [normalized],
|
|
553
|
+
files: []
|
|
554
|
+
};
|
|
523
555
|
if (workspace === true) workspace = {};
|
|
524
556
|
else if (typeof workspace === "string" || Array.isArray(workspace)) workspace = { include: workspace };
|
|
525
557
|
let { include: packages = "auto", exclude = DEFAULT_EXCLUDE_WORKSPACE, config: workspaceConfig } = workspace;
|
|
@@ -536,19 +568,35 @@ async function resolveWorkspace(config, options) {
|
|
|
536
568
|
absolute: true
|
|
537
569
|
})).map((file) => path.resolve(file));
|
|
538
570
|
if (packages.length === 0) throw new Error("No workspace packages found, please check your config");
|
|
571
|
+
if (options.filter) {
|
|
572
|
+
if (typeof options.filter === "string" && options.filter.length > 2 && options.filter[0] === "/" && options.filter.at(-1) === "/") options.filter = new RegExp(options.filter.slice(1, -1));
|
|
573
|
+
packages = packages.filter((path$1) => {
|
|
574
|
+
return typeof options.filter === "string" ? path$1.includes(options.filter) : Array.isArray(options.filter) ? options.filter.some((filter) => path$1.includes(filter)) : options.filter.test(path$1);
|
|
575
|
+
});
|
|
576
|
+
if (packages.length === 0) throw new Error("No packages matched the filters");
|
|
577
|
+
}
|
|
578
|
+
const files = [];
|
|
539
579
|
const configs = (await Promise.all(packages.map(async (cwd) => {
|
|
540
|
-
|
|
580
|
+
debug$1("loading workspace config %s", cwd);
|
|
581
|
+
const { configs: configs$1, file } = await loadConfigFile({
|
|
541
582
|
...options,
|
|
542
583
|
config: workspaceConfig,
|
|
543
584
|
cwd
|
|
544
585
|
}, cwd);
|
|
586
|
+
if (file) {
|
|
587
|
+
debug$1("loaded workspace config file %s", file);
|
|
588
|
+
files.push(file);
|
|
589
|
+
} else debug$1("no workspace config file found in %s", cwd);
|
|
545
590
|
return configs$1.map((config$1) => ({
|
|
546
591
|
...normalized,
|
|
547
592
|
cwd,
|
|
548
593
|
...config$1
|
|
549
594
|
}));
|
|
550
595
|
}))).flat();
|
|
551
|
-
return
|
|
596
|
+
return {
|
|
597
|
+
configs,
|
|
598
|
+
files
|
|
599
|
+
};
|
|
552
600
|
}
|
|
553
601
|
async function resolveConfig(userConfig) {
|
|
554
602
|
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 = {}, copy: copy$1, publicDir, hash, cwd = process.cwd(), name, workspace } = userConfig;
|
|
@@ -612,20 +660,12 @@ async function mergeUserOptions(defaults, user, args) {
|
|
|
612
660
|
|
|
613
661
|
//#endregion
|
|
614
662
|
//#region src/index.ts
|
|
615
|
-
const debug = Debug("tsdown:main");
|
|
616
663
|
/**
|
|
617
664
|
* Build with tsdown.
|
|
618
665
|
*/
|
|
619
666
|
async function build(userOptions = {}) {
|
|
620
667
|
if (typeof userOptions.silent === "boolean") logger.setSilent(userOptions.silent);
|
|
621
|
-
|
|
622
|
-
const { configs, file: configFile } = await resolveOptions(userOptions);
|
|
623
|
-
if (configFile) {
|
|
624
|
-
debug("Loaded config:", configFile);
|
|
625
|
-
configs.forEach((config) => {
|
|
626
|
-
debug("using resolved config: %O", config);
|
|
627
|
-
});
|
|
628
|
-
} else debug("No config file found");
|
|
668
|
+
const { configs, files: configFiles } = await resolveOptions(userOptions);
|
|
629
669
|
let cleanPromise;
|
|
630
670
|
const clean = () => {
|
|
631
671
|
if (cleanPromise) return cleanPromise;
|
|
@@ -637,7 +677,7 @@ async function build(userOptions = {}) {
|
|
|
637
677
|
for (const [i, config] of configs.entries()) {
|
|
638
678
|
const rebuild = rebuilds[i];
|
|
639
679
|
if (!rebuild) continue;
|
|
640
|
-
const watcher = await watchBuild(config,
|
|
680
|
+
const watcher = await watchBuild(config, configFiles, rebuild, restart);
|
|
641
681
|
cleanCbs.push(() => watcher.close());
|
|
642
682
|
}
|
|
643
683
|
if (cleanCbs.length) shortcuts(restart);
|
|
@@ -730,7 +770,7 @@ async function getBuildOptions(config, format, cjsDts, isMultiFormat) {
|
|
|
730
770
|
include: /\.[cm]?[jt]sx?$/,
|
|
731
771
|
exclude: /\.d\.[cm]?ts$/,
|
|
732
772
|
transformOptions: { target }
|
|
733
|
-
}));
|
|
773
|
+
}), RuntimeHelperCheckPlugin(target));
|
|
734
774
|
plugins.push(ShebangPlugin(cwd, name, isMultiFormat));
|
|
735
775
|
}
|
|
736
776
|
if (report && !logger.silent) plugins.push(ReportPlugin(report, cwd, cjsDts, name, isMultiFormat));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from "./logger-BdIBA2vO.js";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-DNOe3jsX.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { bold, green, underline } from "ansis";
|
|
5
5
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger, noop, prettyFormat, prettyName, toArray } from "./logger-BdIBA2vO.js";
|
|
2
2
|
import path, { dirname, normalize, sep } from "node:path";
|
|
3
3
|
import { bold, dim, green, underline } from "ansis";
|
|
4
|
-
import
|
|
4
|
+
import debug from "debug";
|
|
5
5
|
import { access, chmod, cp, rm, stat } from "node:fs/promises";
|
|
6
6
|
import { Buffer } from "node:buffer";
|
|
7
7
|
import { promisify } from "node:util";
|
|
@@ -47,7 +47,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/features/external.ts
|
|
50
|
-
const debug$
|
|
50
|
+
const debug$2 = debug("tsdown:external");
|
|
51
51
|
function ExternalPlugin(options) {
|
|
52
52
|
const deps = options.pkg && Array.from(getProductionDeps(options.pkg));
|
|
53
53
|
return {
|
|
@@ -70,7 +70,7 @@ function ExternalPlugin(options) {
|
|
|
70
70
|
}
|
|
71
71
|
if (deps) shouldExternal ||= deps.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
72
72
|
if (shouldExternal) {
|
|
73
|
-
debug$
|
|
73
|
+
debug$2("External dependency:", id);
|
|
74
74
|
return {
|
|
75
75
|
id,
|
|
76
76
|
external: shouldExternal
|
|
@@ -119,7 +119,7 @@ function formatBytes(bytes) {
|
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/features/report.ts
|
|
122
|
-
const debug =
|
|
122
|
+
const debug$1 = debug("tsdown:report");
|
|
123
123
|
const brotliCompressAsync = promisify(brotliCompress);
|
|
124
124
|
const gzipAsync = promisify(gzip);
|
|
125
125
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -161,19 +161,19 @@ function ReportPlugin(options, cwd, cjsDts, name, isMultiFormat) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
async function calcSize(options, chunk) {
|
|
164
|
-
debug(`Calculating size for`, chunk.fileName);
|
|
164
|
+
debug$1(`Calculating size for`, chunk.fileName);
|
|
165
165
|
const content = chunk.type === "chunk" ? chunk.code : chunk.source;
|
|
166
166
|
const raw = Buffer.byteLength(content, "utf8");
|
|
167
|
-
debug("[size]", chunk.fileName, raw);
|
|
167
|
+
debug$1("[size]", chunk.fileName, raw);
|
|
168
168
|
let gzip$1 = Infinity;
|
|
169
169
|
let brotli = Infinity;
|
|
170
|
-
if (raw > (options.maxCompressSize ?? 1e6)) debug(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
170
|
+
if (raw > (options.maxCompressSize ?? 1e6)) debug$1(chunk.fileName, "file size exceeds limit, skip gzip/brotli");
|
|
171
171
|
else {
|
|
172
172
|
gzip$1 = (await gzipAsync(content)).length;
|
|
173
|
-
debug("[gzip]", chunk.fileName, gzip$1);
|
|
173
|
+
debug$1("[gzip]", chunk.fileName, gzip$1);
|
|
174
174
|
if (options.brotli) {
|
|
175
175
|
brotli = (await brotliCompressAsync(content)).length;
|
|
176
|
-
debug("[brotli]", chunk.fileName, brotli);
|
|
176
|
+
debug$1("[brotli]", chunk.fileName, brotli);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
return {
|
package/dist/plugins.d.ts
CHANGED
package/dist/plugins.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-
|
|
1
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./plugins-AcF8M16F.js";
|
|
2
2
|
import "./logger-BdIBA2vO.js";
|
|
3
3
|
|
|
4
4
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { logger, resolveComma, toArray } from "./logger-BdIBA2vO.js";
|
|
3
|
-
import { version } from "./package-
|
|
3
|
+
import { version } from "./package-DNOe3jsX.js";
|
|
4
4
|
import module from "node:module";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { dim } from "ansis";
|
|
7
|
-
import Debug from "debug";
|
|
8
7
|
import { VERSION } from "rolldown";
|
|
8
|
+
import debug from "debug";
|
|
9
9
|
import { cac } from "cac";
|
|
10
10
|
|
|
11
11
|
//#region src/cli.ts
|
|
@@ -14,7 +14,7 @@ cli.help().version(version);
|
|
|
14
14
|
cli.command("[...files]", "Bundle files", {
|
|
15
15
|
ignoreOptionDefaultValue: true,
|
|
16
16
|
allowUnknownOptions: true
|
|
17
|
-
}).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 [
|
|
17
|
+
}).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 [feat]", "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").option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("-W, --workspace [dir]", "Enable workspace mode").option("-f, --filter <pattern>", "Filter workspace packages, e.g. /regex/ or substring").action(async (input, flags) => {
|
|
18
18
|
logger.setSilent(!!flags.silent);
|
|
19
19
|
logger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
20
20
|
const { build: build$1 } = await import("./index.js");
|
|
@@ -22,7 +22,7 @@ cli.command("[...files]", "Bundle files", {
|
|
|
22
22
|
await build$1(flags);
|
|
23
23
|
});
|
|
24
24
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
25
|
-
const { migrate } = await import("./migrate-
|
|
25
|
+
const { migrate } = await import("./migrate-Bt-9GxhE.js");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
|
@@ -31,10 +31,10 @@ async function runCLI() {
|
|
|
31
31
|
let namespace;
|
|
32
32
|
if (cli.options.debug === true) namespace = "tsdown:*";
|
|
33
33
|
else namespace = resolveComma(toArray(cli.options.debug)).map((v) => `tsdown:${v}`).join(",");
|
|
34
|
-
const enabled =
|
|
34
|
+
const enabled = debug.disable();
|
|
35
35
|
if (enabled) namespace += `,${enabled}`;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
debug.enable(namespace);
|
|
37
|
+
debug("tsdown:debug")("Debugging enabled", namespace);
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
40
|
await cli.runMatchedCommand();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"ansis": "^4.0.0",
|
|
66
66
|
"cac": "^6.7.14",
|
|
67
67
|
"chokidar": "^4.0.3",
|
|
68
|
-
"debug": "^4.4.
|
|
69
|
-
"diff": "^8.0.
|
|
68
|
+
"debug": "^4.4.1",
|
|
69
|
+
"diff": "^8.0.1",
|
|
70
70
|
"empathic": "^1.1.0",
|
|
71
71
|
"hookable": "^5.5.3",
|
|
72
72
|
"rolldown": "1.0.0-beta.8-commit.d95f99e",
|
|
73
|
-
"rolldown-plugin-dts": "^0.
|
|
73
|
+
"rolldown-plugin-dts": "^0.13.1",
|
|
74
74
|
"semver": "^7.7.2",
|
|
75
75
|
"tinyexec": "^1.0.1",
|
|
76
76
|
"tinyglobby": "^0.2.13",
|
|
@@ -82,28 +82,28 @@
|
|
|
82
82
|
"@sxzz/prettier-config": "^2.2.1",
|
|
83
83
|
"@sxzz/test-utils": "^0.5.6",
|
|
84
84
|
"@types/debug": "^4.1.12",
|
|
85
|
-
"@types/node": "^22.15.
|
|
85
|
+
"@types/node": "^22.15.18",
|
|
86
86
|
"@types/semver": "^7.7.0",
|
|
87
|
-
"@unocss/eslint-plugin": "^66.1.
|
|
88
|
-
"bumpp": "^10.1.
|
|
89
|
-
"eslint": "^9.
|
|
90
|
-
"lightningcss": "^1.30.
|
|
87
|
+
"@unocss/eslint-plugin": "^66.1.2",
|
|
88
|
+
"bumpp": "^10.1.1",
|
|
89
|
+
"eslint": "^9.27.0",
|
|
90
|
+
"lightningcss": "^1.30.1",
|
|
91
91
|
"pkg-types": "^2.1.0",
|
|
92
92
|
"prettier": "^3.5.3",
|
|
93
93
|
"publint": "^0.3.12",
|
|
94
|
-
"tsup": "^8.
|
|
94
|
+
"tsup": "^8.5.0",
|
|
95
95
|
"typedoc": "^0.28.4",
|
|
96
96
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
97
97
|
"typescript": "~5.8.3",
|
|
98
|
-
"unocss": "^66.1.
|
|
98
|
+
"unocss": "^66.1.2",
|
|
99
99
|
"unplugin-lightningcss": "^0.4.0",
|
|
100
100
|
"unplugin-unused": "^0.5.0",
|
|
101
101
|
"vite": "^6.3.5",
|
|
102
102
|
"vitepress": "^1.6.3",
|
|
103
|
-
"vitepress-plugin-group-icons": "^1.5.
|
|
103
|
+
"vitepress-plugin-group-icons": "^1.5.5",
|
|
104
104
|
"vitepress-plugin-llms": "^1.1.4",
|
|
105
105
|
"vitest": "^3.1.3",
|
|
106
|
-
"vue": "^3.5.
|
|
106
|
+
"vue": "^3.5.14"
|
|
107
107
|
},
|
|
108
108
|
"engines": {
|
|
109
109
|
"node": ">=18.0.0"
|