tsdown 0.10.0 → 0.10.2
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 +1 -1
- package/dist/{config.d-DpTGFaWV.d.ts → config.d-DRSsMo60.d.ts} +4 -1
- package/dist/config.d.ts +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +14 -7
- package/dist/{migrate-Cq1rvewL.js → migrate-Dm7wrtcG.js} +1 -1
- package/dist/{options.d-C1wrHXGf.d.ts → options.d-BCXr2j3p.d.ts} +3 -11
- package/dist/package-DNcXUvW0.js +5 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/run.js +3 -3
- package/package.json +7 -7
- package/dist/package-D9H_HrcE.js +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<img src="./docs/public/og-image.svg" alt="tsdown" width="100%" /><br>
|
|
2
2
|
|
|
3
|
-
# tsdown [](https://npmjs.com/package/tsdown) [](https://github.com/rolldown/tsdown/actions/workflows/tests.yml) [](https://jsr.io/@sxzz/tsdown)
|
|
3
|
+
# tsdown [](https://npmjs.com/package/tsdown) [](https://github.com/rolldown/tsdown/actions/workflows/tests.yml) [](https://jsr.io/@sxzz/tsdown) [](https://stackblitz.com/github/rolldown/tsdown-starter-stackblitz)
|
|
4
4
|
|
|
5
5
|
✨ The elegant bundler for libraries powered by [Rolldown](https://github.com/rolldown/rolldown).
|
|
6
6
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./options.d-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./options.d-BCXr2j3p.js";
|
|
2
2
|
|
|
3
3
|
//#region src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Defines the configuration for tsdown.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Defines the configuration for tsdown.
|
|
9
|
+
*/
|
|
7
10
|
declare function defineConfig(options: UserConfig): UserConfig;
|
|
8
11
|
declare function defineConfig(options: UserConfigFn): UserConfigFn;
|
|
9
12
|
|
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-BCXr2j3p.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-DRSsMo60.js";
|
|
3
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
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-BCXr2j3p.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-DRSsMo60.js";
|
|
3
3
|
import { ConsolaInstance } from "consola";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/logger.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Logger instance
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Logger instance
|
|
11
|
+
*/
|
|
9
12
|
declare const logger: ConsolaInstance;
|
|
10
13
|
|
|
11
14
|
//#endregion
|
|
@@ -15,7 +18,6 @@ declare const logger: ConsolaInstance;
|
|
|
15
18
|
*/
|
|
16
19
|
declare function build(userOptions?: Options): Promise<void>;
|
|
17
20
|
declare const pkgRoot: string;
|
|
18
|
-
|
|
19
21
|
/**
|
|
20
22
|
* Build a single configuration, without watch and shortcuts features.
|
|
21
23
|
*
|
package/dist/index.js
CHANGED
|
@@ -19,15 +19,21 @@ import { up } from "empathic/find";
|
|
|
19
19
|
|
|
20
20
|
//#region src/features/clean.ts
|
|
21
21
|
const debug$3 = Debug("tsdown:clean");
|
|
22
|
+
const RE_LAST_SLASH = /[/\\]$/;
|
|
22
23
|
async function cleanOutDir(configs) {
|
|
23
24
|
const removes = new Set();
|
|
24
25
|
for (const config of configs) {
|
|
25
26
|
if (!config.clean.length) continue;
|
|
26
27
|
const files = await glob(config.clean, {
|
|
27
28
|
cwd: config.cwd,
|
|
28
|
-
absolute: true
|
|
29
|
+
absolute: true,
|
|
30
|
+
onlyFiles: false
|
|
29
31
|
});
|
|
30
|
-
|
|
32
|
+
const normalizedOutDir = config.outDir.replace(RE_LAST_SLASH, "");
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
const normalizedFile = file.replace(RE_LAST_SLASH, "");
|
|
35
|
+
if (normalizedFile !== normalizedOutDir) removes.add(file);
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
if (!removes.size) return;
|
|
33
39
|
logger.info("Cleaning %d files", removes.size);
|
|
@@ -127,12 +133,13 @@ function resolveChunkFilename({ outExtensions, fixedExtension, pkg }, inputOptio
|
|
|
127
133
|
options: inputOptions,
|
|
128
134
|
format,
|
|
129
135
|
pkgType: packageType
|
|
130
|
-
});
|
|
136
|
+
}) || {};
|
|
131
137
|
jsExtension = js;
|
|
132
138
|
dtsExtension = dts;
|
|
133
139
|
}
|
|
134
140
|
jsExtension ||= `.${resolveJsOutputExtension(packageType, format, fixedExtension)}`;
|
|
135
|
-
|
|
141
|
+
const suffix = format === "iife" || format === "umd" ? `.${format}` : "";
|
|
142
|
+
return [createChunkFilename(`[name]${suffix}`, jsExtension, dtsExtension), createChunkFilename(`[name]${suffix}-[hash]`, jsExtension, dtsExtension)];
|
|
136
143
|
}
|
|
137
144
|
function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
138
145
|
if (!dtsExtension) return `${basename}${jsExtension}`;
|
|
@@ -144,11 +151,11 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
|
144
151
|
//#endregion
|
|
145
152
|
//#region src/features/publint.ts
|
|
146
153
|
const debug$2 = Debug("tsdown:publint");
|
|
147
|
-
async function publint(pkg) {
|
|
154
|
+
async function publint(pkg, options) {
|
|
148
155
|
debug$2("Running publint");
|
|
149
156
|
const { publint: publint$1 } = await import("publint");
|
|
150
157
|
const { formatMessage } = await import("publint/utils");
|
|
151
|
-
const { messages } = await publint$1();
|
|
158
|
+
const { messages } = await publint$1(options);
|
|
152
159
|
debug$2("Found %d issues", messages.length);
|
|
153
160
|
if (!messages.length) logger.success("No publint issues found");
|
|
154
161
|
let hasError = false;
|
|
@@ -546,7 +553,7 @@ async function buildSingle(config, clean) {
|
|
|
546
553
|
}));
|
|
547
554
|
if (hasErrors) return;
|
|
548
555
|
await hooks.callHook("build:done", context);
|
|
549
|
-
if (config.publint) if (config.pkg) await publint(config.pkg);
|
|
556
|
+
if (config.publint) if (config.pkg) await publint(config.pkg, config.publint === true ? {} : config.publint);
|
|
550
557
|
else logger.warn("publint is enabled but package.json is not found");
|
|
551
558
|
logger.success(`${first ? "Build" : "Rebuild"} complete in ${green(`${Math.round(performance.now() - startTime)}ms`)}`);
|
|
552
559
|
if (typeof onSuccess === "string") {
|
|
@@ -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";
|
|
@@ -14,7 +14,6 @@ interface BuildContext {
|
|
|
14
14
|
interface RolldownContext {
|
|
15
15
|
buildOptions: BuildOptions;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
18
|
* Hooks for tsdown.
|
|
20
19
|
*/
|
|
@@ -51,7 +50,7 @@ interface OutExtensionObject {
|
|
|
51
50
|
js?: string;
|
|
52
51
|
dts?: string;
|
|
53
52
|
}
|
|
54
|
-
type OutExtensionFactory = (
|
|
53
|
+
type OutExtensionFactory = (context: OutExtensionContext) => OutExtensionObject | undefined;
|
|
55
54
|
|
|
56
55
|
//#endregion
|
|
57
56
|
//#region src/features/report.d.ts
|
|
@@ -83,12 +82,6 @@ type Arrayable<T> = T | T[];
|
|
|
83
82
|
type Sourcemap = boolean | "inline" | "hidden";
|
|
84
83
|
type Format = Exclude<ModuleFormat, "experimental-app">;
|
|
85
84
|
type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
|
|
86
|
-
interface MinifyOptions {
|
|
87
|
-
mangle?: boolean;
|
|
88
|
-
compress?: boolean;
|
|
89
|
-
removeWhitespace?: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
85
|
/**
|
|
93
86
|
* Options for tsdown.
|
|
94
87
|
*/
|
|
@@ -180,7 +173,7 @@ interface Options$3 {
|
|
|
180
173
|
/**
|
|
181
174
|
* Compile-time env variables.
|
|
182
175
|
* @example
|
|
183
|
-
* ```
|
|
176
|
+
* ```json
|
|
184
177
|
* {
|
|
185
178
|
* "DEBUG": true,
|
|
186
179
|
* "NODE_ENV": "production"
|
|
@@ -190,7 +183,6 @@ interface Options$3 {
|
|
|
190
183
|
env?: Record<string, any>;
|
|
191
184
|
hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
|
|
192
185
|
}
|
|
193
|
-
|
|
194
186
|
/**
|
|
195
187
|
* Options without specifying config file path.
|
|
196
188
|
*/
|
package/dist/plugins.d.ts
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-DNcXUvW0.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").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) => {
|
|
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").option("--on-success <command>", "Command to run on success").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-Dm7wrtcG.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.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,20 +63,20 @@
|
|
|
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.7",
|
|
68
68
|
"tinyexec": "^1.0.1",
|
|
69
69
|
"tinyglobby": "^0.2.13",
|
|
70
70
|
"unconfig": "^7.3.2",
|
|
71
71
|
"unplugin-lightningcss": "^0.3.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@sxzz/eslint-config": "^6.
|
|
74
|
+
"@sxzz/eslint-config": "^6.2.0",
|
|
75
75
|
"@sxzz/prettier-config": "^2.2.1",
|
|
76
76
|
"@sxzz/test-utils": "^0.5.5",
|
|
77
77
|
"@types/debug": "^4.1.12",
|
|
78
78
|
"@types/diff": "^7.0.2",
|
|
79
|
-
"@types/node": "^22.15.
|
|
79
|
+
"@types/node": "^22.15.3",
|
|
80
80
|
"@unocss/eslint-plugin": "^66.1.0-beta.12",
|
|
81
81
|
"bumpp": "^10.1.0",
|
|
82
82
|
"eslint": "^9.25.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"prettier": "^3.5.3",
|
|
85
85
|
"publint": "^0.3.12",
|
|
86
86
|
"tsup": "^8.4.0",
|
|
87
|
-
"tsx": "^4.19.
|
|
87
|
+
"tsx": "^4.19.4",
|
|
88
88
|
"typedoc": "^0.28.3",
|
|
89
89
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
90
90
|
"typescript": "~5.8.3",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"vite": "^6.3.3",
|
|
94
94
|
"vitepress": "^1.6.3",
|
|
95
95
|
"vitepress-plugin-group-icons": "^1.5.2",
|
|
96
|
-
"vitepress-plugin-llms": "^1.1.
|
|
96
|
+
"vitepress-plugin-llms": "^1.1.1",
|
|
97
97
|
"vitest": "^3.1.2",
|
|
98
98
|
"vue": "^3.5.13"
|
|
99
99
|
},
|