tsdown 0.8.0 → 0.8.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/README.md +3 -1
- package/dist/{config.d-DBmaLxob.d.ts → config.d-Cr3EGxrH.d.ts} +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +81 -48
- package/dist/{migrate-DKCgygvz.js → migrate-BoWQ25Gi.js} +2 -2
- package/dist/{options.d-C08fnFhO.d.ts → options.d-eIuuoVM5.d.ts} +2 -0
- package/dist/package-CNBd6ypr.js +6 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/run.js +2 -2
- package/package.json +4 -5
- package/dist/package-DtsCM7oZ.js +0 -6
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<img src="./assets/header-illustration.svg" alt="tsdown" width="100%" /><br>
|
|
2
|
+
|
|
1
3
|
# tsdown [](https://npmjs.com/package/tsdown) [](https://github.com/rolldown/tsdown/actions/workflows/unit-test.yml) [](https://jsr.io/@sxzz/tsdown)
|
|
2
4
|
|
|
3
5
|
⚡️ An even faster bundler powered by [Rolldown](https://github.com/rolldown/rolldown).
|
|
@@ -29,7 +31,7 @@ export default defineConfig({
|
|
|
29
31
|
|
|
30
32
|
## Usage
|
|
31
33
|
|
|
32
|
-
```
|
|
34
|
+
```bash
|
|
33
35
|
npx tsdown
|
|
34
36
|
```
|
|
35
37
|
|
package/dist/config.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Options, ResolvedOptions, UserConfig } from "./options.d-
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config.d-
|
|
1
|
+
import { Options, ResolvedOptions, UserConfig } from "./options.d-eIuuoVM5.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-Cr3EGxrH.js";
|
|
3
3
|
import Debug from "debug";
|
|
4
4
|
import { ConsolaInstance } from "consola";
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -242,6 +242,12 @@ async function toObjectEntry(entry) {
|
|
|
242
242
|
}));
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/utils/tsconfig.ts
|
|
247
|
+
async function findTsconfig(cwd, name = "tsconfig.json") {
|
|
248
|
+
return await findUp(name, { cwd }) || false;
|
|
249
|
+
}
|
|
250
|
+
|
|
245
251
|
//#endregion
|
|
246
252
|
//#region src/options.ts
|
|
247
253
|
async function resolveOptions(options) {
|
|
@@ -252,10 +258,28 @@ async function resolveOptions(options) {
|
|
|
252
258
|
...subConfig,
|
|
253
259
|
...options
|
|
254
260
|
};
|
|
255
|
-
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, publint: publint$1 = false, fromVite, alias } = subOptions;
|
|
261
|
+
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, publint: publint$1 = false, fromVite, alias, tsconfig } = subOptions;
|
|
256
262
|
entry = await resolveEntry(entry);
|
|
257
263
|
if (clean === true) clean = [];
|
|
258
264
|
if (publint$1 === true) publint$1 = {};
|
|
265
|
+
if (tsconfig !== false) {
|
|
266
|
+
if (tsconfig === true || tsconfig == null) {
|
|
267
|
+
const isSet = tsconfig;
|
|
268
|
+
tsconfig = await findTsconfig(cwd);
|
|
269
|
+
if (isSet && !tsconfig) logger.warn(`No tsconfig found in \`${cwd}\``);
|
|
270
|
+
} else {
|
|
271
|
+
const tsconfigPath = path.resolve(cwd, tsconfig);
|
|
272
|
+
if (await fsExists(tsconfigPath)) tsconfig = tsconfigPath;
|
|
273
|
+
else if (tsconfig.includes("\\") || tsconfig.includes("/")) {
|
|
274
|
+
logger.warn(`tsconfig \`${tsconfig}\` doesn't exist`);
|
|
275
|
+
tsconfig = false;
|
|
276
|
+
} else {
|
|
277
|
+
tsconfig = await findTsconfig(cwd, tsconfig);
|
|
278
|
+
if (!tsconfig) logger.warn(`No \`${tsconfig}\` found in \`${cwd}\``);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (tsconfig) logger.info(`Using tsconfig: ${underline(tsconfig)}`);
|
|
282
|
+
}
|
|
259
283
|
if (fromVite) {
|
|
260
284
|
const viteUserConfig = await loadViteConfig(fromVite === true ? "vite" : fromVite, cwd);
|
|
261
285
|
if (viteUserConfig) {
|
|
@@ -282,7 +306,8 @@ async function resolveOptions(options) {
|
|
|
282
306
|
shims,
|
|
283
307
|
skipNodeModulesBundle,
|
|
284
308
|
publint: publint$1,
|
|
285
|
-
alias
|
|
309
|
+
alias,
|
|
310
|
+
tsconfig
|
|
286
311
|
};
|
|
287
312
|
return config;
|
|
288
313
|
}));
|
|
@@ -409,7 +434,7 @@ async function build(userOptions = {}) {
|
|
|
409
434
|
const dirname$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
410
435
|
const pkgRoot = path.resolve(dirname$1, "..");
|
|
411
436
|
async function buildSingle(config) {
|
|
412
|
-
const {
|
|
437
|
+
const { outDir, format: formats, clean, dts, watch, onSuccess } = config;
|
|
413
438
|
let onSuccessCleanup;
|
|
414
439
|
const pkg = await readPackageJson(process.cwd());
|
|
415
440
|
await rebuild(true);
|
|
@@ -421,8 +446,8 @@ async function buildSingle(config) {
|
|
|
421
446
|
let hasErrors = false;
|
|
422
447
|
await Promise.all(formats.map(async (format) => {
|
|
423
448
|
try {
|
|
424
|
-
await build$1(await getBuildOptions(format));
|
|
425
|
-
if (format === "cjs" && dts) await build$1(await getBuildOptions(format, true));
|
|
449
|
+
await build$1(await getBuildOptions(config, pkg, format));
|
|
450
|
+
if (format === "cjs" && dts) await build$1(await getBuildOptions(config, pkg, format, true));
|
|
426
451
|
} catch (error) {
|
|
427
452
|
if (watch) {
|
|
428
453
|
logger.error(error);
|
|
@@ -447,51 +472,59 @@ async function buildSingle(config) {
|
|
|
447
472
|
onSuccessCleanup = () => p.kill("SIGTERM");
|
|
448
473
|
} else await onSuccess?.(config);
|
|
449
474
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
if (target && !cjsDts) plugins.push(transformPlugin({
|
|
467
|
-
target: target && (typeof target === "string" ? target : target.join(",")),
|
|
468
|
-
exclude: /\.d\.[cm]?ts$/
|
|
469
|
-
}));
|
|
470
|
-
plugins.push(userPlugins);
|
|
471
|
-
const inputOptions = await mergeUserOptions({
|
|
472
|
-
input: entry,
|
|
473
|
-
external,
|
|
474
|
-
resolve: { alias },
|
|
475
|
-
treeshake,
|
|
476
|
-
platform,
|
|
477
|
-
define,
|
|
478
|
-
plugins,
|
|
479
|
-
inject: { ...shims && !cjsDts && getShimsInject(format, platform) }
|
|
480
|
-
}, config.inputOptions, [format]);
|
|
481
|
-
const outputOptions = await mergeUserOptions({
|
|
482
|
-
format: cjsDts ? "es" : format,
|
|
483
|
-
name: config.globalName,
|
|
484
|
-
sourcemap,
|
|
485
|
-
dir: outDir,
|
|
486
|
-
minify,
|
|
487
|
-
entryFileNames: `[name].${extension}`,
|
|
488
|
-
chunkFileNames: `[name]-[hash].${extension}`
|
|
489
|
-
}, config.outputOptions, [format]);
|
|
490
|
-
return {
|
|
491
|
-
...inputOptions,
|
|
492
|
-
output: outputOptions
|
|
475
|
+
}
|
|
476
|
+
async function getBuildOptions(config, pkg, format, cjsDts) {
|
|
477
|
+
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, fixedExtension, tsconfig } = config;
|
|
478
|
+
const extension = resolveOutputExtension(pkg, format, fixedExtension);
|
|
479
|
+
const plugins = [];
|
|
480
|
+
if (pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config, pkg));
|
|
481
|
+
if (unused && !cjsDts) {
|
|
482
|
+
const { Unused } = await import("unplugin-unused");
|
|
483
|
+
plugins.push(Unused.rolldown(unused === true ? {} : unused));
|
|
484
|
+
}
|
|
485
|
+
if (dts) {
|
|
486
|
+
const { dts: dtsPlugin } = await import("rolldown-plugin-dts");
|
|
487
|
+
const options = {
|
|
488
|
+
tsconfig,
|
|
489
|
+
...dts
|
|
493
490
|
};
|
|
491
|
+
if (format === "es") plugins.push(dtsPlugin(options));
|
|
492
|
+
else if (cjsDts) plugins.push(dtsPlugin({
|
|
493
|
+
...options,
|
|
494
|
+
emitDtsOnly: true
|
|
495
|
+
}));
|
|
494
496
|
}
|
|
497
|
+
if (target && !cjsDts) plugins.push(transformPlugin({
|
|
498
|
+
target: target && (typeof target === "string" ? target : target.join(",")),
|
|
499
|
+
exclude: /\.d\.[cm]?ts$/
|
|
500
|
+
}));
|
|
501
|
+
plugins.push(userPlugins);
|
|
502
|
+
const inputOptions = await mergeUserOptions({
|
|
503
|
+
input: entry,
|
|
504
|
+
external,
|
|
505
|
+
resolve: {
|
|
506
|
+
alias,
|
|
507
|
+
tsconfigFilename: tsconfig || void 0
|
|
508
|
+
},
|
|
509
|
+
treeshake,
|
|
510
|
+
platform,
|
|
511
|
+
define,
|
|
512
|
+
plugins,
|
|
513
|
+
inject: { ...shims && !cjsDts && getShimsInject(format, platform) }
|
|
514
|
+
}, config.inputOptions, [format]);
|
|
515
|
+
const outputOptions = await mergeUserOptions({
|
|
516
|
+
format: cjsDts ? "es" : format,
|
|
517
|
+
name: config.globalName,
|
|
518
|
+
sourcemap,
|
|
519
|
+
dir: outDir,
|
|
520
|
+
minify,
|
|
521
|
+
entryFileNames: `[name].${extension}`,
|
|
522
|
+
chunkFileNames: `[name]-[hash].${extension}`
|
|
523
|
+
}, config.outputOptions, [format]);
|
|
524
|
+
return {
|
|
525
|
+
...inputOptions,
|
|
526
|
+
output: outputOptions
|
|
527
|
+
};
|
|
495
528
|
}
|
|
496
529
|
|
|
497
530
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { version } from "./package-
|
|
1
|
+
import { version } from "./package-CNBd6ypr.js";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import consola from "consola";
|
|
@@ -52,7 +52,7 @@ async function migratePackageJson(dryRun) {
|
|
|
52
52
|
for (const key of Object.keys(pkg.scripts)) if (pkg.scripts[key].includes("tsup")) {
|
|
53
53
|
consola.info(`Migrating \`${key}\` script to tsdown`);
|
|
54
54
|
found = true;
|
|
55
|
-
pkg.scripts[key] = pkg.scripts[key].replaceAll(
|
|
55
|
+
pkg.scripts[key] = pkg.scripts[key].replaceAll(/tsup(?:-node)?/, "tsdown");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
if (pkg.tsup) {
|
|
@@ -26,6 +26,7 @@ interface Options$3 {
|
|
|
26
26
|
external?: ExternalOption;
|
|
27
27
|
noExternal?: Arrayable<string | RegExp> | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
|
|
28
28
|
alias?: Record<string, string>;
|
|
29
|
+
tsconfig?: string | boolean;
|
|
29
30
|
/** @default 'node' */
|
|
30
31
|
platform?: "node" | "neutral" | "browser";
|
|
31
32
|
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat) => Awaitable<InputOptions | void | null>);
|
|
@@ -90,6 +91,7 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inp
|
|
|
90
91
|
format: NormalizedFormat[]
|
|
91
92
|
clean: string[] | false
|
|
92
93
|
dts: false | Options$1
|
|
94
|
+
tsconfig: string | false
|
|
93
95
|
}>, "config" | "fromVite">;
|
|
94
96
|
|
|
95
97
|
//#endregion
|
package/dist/plugins.d.ts
CHANGED
package/dist/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger, setSilent } from "./logger-4bmpqibt.js";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-CNBd6ypr.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { VERSION } from "rolldown";
|
|
5
5
|
import { dim } from "ansis";
|
|
@@ -16,7 +16,7 @@ cli.command("[...files]", "Bundle files", { ignoreOptionDefaultValue: true }).op
|
|
|
16
16
|
await build$1(flags);
|
|
17
17
|
});
|
|
18
18
|
cli.command("migrate", "Migrate from tsup to tsdown").option("-c, --cwd <dir>", "Working directory").option("-d, --dry-run", "Dry run").action(async (args) => {
|
|
19
|
-
const { migrate } = await import("./migrate-
|
|
19
|
+
const { migrate } = await import("./migrate-BoWQ25Gi.js");
|
|
20
20
|
await migrate(args);
|
|
21
21
|
});
|
|
22
22
|
async function runCLI() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "An even faster bundler powered by Rolldown.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"diff": "^7.0.0",
|
|
63
63
|
"find-up-simple": "^1.0.1",
|
|
64
64
|
"rolldown": "^1.0.0-beta.7",
|
|
65
|
-
"rolldown-plugin-dts": "^0.
|
|
65
|
+
"rolldown-plugin-dts": "^0.7.8",
|
|
66
66
|
"tinyexec": "^1.0.1",
|
|
67
67
|
"tinyglobby": "^0.2.12",
|
|
68
68
|
"unconfig": "^7.3.1"
|
|
@@ -70,13 +70,12 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@sxzz/eslint-config": "^6.1.1",
|
|
72
72
|
"@sxzz/prettier-config": "^2.2.1",
|
|
73
|
-
"@sxzz/test-utils": "^0.5.
|
|
73
|
+
"@sxzz/test-utils": "^0.5.5",
|
|
74
74
|
"@types/debug": "^4.1.12",
|
|
75
75
|
"@types/diff": "^7.0.2",
|
|
76
76
|
"@types/node": "^22.14.1",
|
|
77
77
|
"bumpp": "^10.1.0",
|
|
78
78
|
"eslint": "^9.24.0",
|
|
79
|
-
"oxc-transform": "^0.63.0",
|
|
80
79
|
"pkg-types": "^2.1.0",
|
|
81
80
|
"prettier": "^3.5.3",
|
|
82
81
|
"publint": "^0.3.12",
|
|
@@ -85,7 +84,7 @@
|
|
|
85
84
|
"typescript": "~5.8.3",
|
|
86
85
|
"unplugin-ast": "^0.14.6",
|
|
87
86
|
"unplugin-unused": "^0.4.4",
|
|
88
|
-
"vite": "^6.2
|
|
87
|
+
"vite": "^6.3.2",
|
|
89
88
|
"vitest": "^3.1.1"
|
|
90
89
|
},
|
|
91
90
|
"engines": {
|