tsdown 0.13.0-beta.1 → 0.13.0-beta.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/dist/{config-BHQdCemQ.d.mts → config--Vetp6NA.d.mts} +20 -8
- package/dist/config.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{migrate-OhQ7vqGh.mjs → migrate-DHdrktiR.mjs} +1 -1
- package/dist/package-BCFwezi2.mjs +5 -0
- package/dist/plugins.d.mts +1 -4
- package/dist/plugins.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/dist/{src-DfeORvyH.mjs → src-vU2xJl3a.mjs} +20 -5
- package/package.json +9 -9
- package/dist/package-DN14v3FV.mjs +0 -5
|
@@ -141,6 +141,15 @@ interface OutExtensionObject {
|
|
|
141
141
|
dts?: string;
|
|
142
142
|
}
|
|
143
143
|
type OutExtensionFactory = (context: OutExtensionContext) => OutExtensionObject | undefined;
|
|
144
|
+
interface ChunkAddonObject {
|
|
145
|
+
js?: string;
|
|
146
|
+
css?: string;
|
|
147
|
+
dts?: string;
|
|
148
|
+
}
|
|
149
|
+
type ChunkAddonFunction = (ctx: {
|
|
150
|
+
format: Format;
|
|
151
|
+
}) => ChunkAddonObject | undefined;
|
|
152
|
+
type ChunkAddon = ChunkAddonObject | ChunkAddonFunction;
|
|
144
153
|
//#endregion
|
|
145
154
|
//#region src/features/report.d.ts
|
|
146
155
|
interface ReportOptions {
|
|
@@ -185,7 +194,6 @@ interface Workspace {
|
|
|
185
194
|
* Options for tsdown.
|
|
186
195
|
*/
|
|
187
196
|
interface Options$3 {
|
|
188
|
-
/// build options
|
|
189
197
|
/**
|
|
190
198
|
* Defaults to `'src/index.ts'` if it exists.
|
|
191
199
|
*/
|
|
@@ -206,8 +214,9 @@ interface Options$3 {
|
|
|
206
214
|
* @see https://tsdown.dev/options/platform
|
|
207
215
|
*/
|
|
208
216
|
platform?: "node" | "neutral" | "browser";
|
|
209
|
-
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat
|
|
210
|
-
|
|
217
|
+
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
|
|
218
|
+
cjsDts: boolean;
|
|
219
|
+
}) => Awaitable<InputOptions | void | null>);
|
|
211
220
|
/** @default ['es'] */
|
|
212
221
|
format?: Format | Format[];
|
|
213
222
|
globalName?: string;
|
|
@@ -278,7 +287,9 @@ interface Options$3 {
|
|
|
278
287
|
* `fixedExtension` will be overridden by this option.
|
|
279
288
|
*/
|
|
280
289
|
outExtensions?: OutExtensionFactory;
|
|
281
|
-
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat
|
|
290
|
+
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat, context: {
|
|
291
|
+
cjsDts: boolean;
|
|
292
|
+
}) => Awaitable<OutputOptions | void | null>);
|
|
282
293
|
/** @default true */
|
|
283
294
|
treeshake?: boolean;
|
|
284
295
|
plugins?: InputOptions["plugins"];
|
|
@@ -315,7 +326,6 @@ interface Options$3 {
|
|
|
315
326
|
* @default false
|
|
316
327
|
*/
|
|
317
328
|
fromVite?: boolean | "vitest";
|
|
318
|
-
/// addons
|
|
319
329
|
/**
|
|
320
330
|
* Emit TypeScript declaration files (.d.ts).
|
|
321
331
|
*
|
|
@@ -431,13 +441,15 @@ interface Options$3 {
|
|
|
431
441
|
* Filter workspace packages. This option is only available in workspace mode.
|
|
432
442
|
*/
|
|
433
443
|
filter?: RegExp | string | string[];
|
|
444
|
+
footer?: ChunkAddon;
|
|
445
|
+
banner?: ChunkAddon;
|
|
434
446
|
}
|
|
435
447
|
/**
|
|
436
448
|
* Options without specifying config file path.
|
|
437
449
|
*/
|
|
438
450
|
type UserConfig = Arrayable<Omit<Options$3, "config" | "filter">>;
|
|
439
451
|
type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
440
|
-
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" | "bundle">, {
|
|
452
|
+
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" | "bundle" | "banner" | "footer">, {
|
|
441
453
|
format: NormalizedFormat[];
|
|
442
454
|
target?: string[];
|
|
443
455
|
clean: string[];
|
|
@@ -453,6 +465,6 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
|
|
|
453
465
|
/**
|
|
454
466
|
* Defines the configuration for tsdown.
|
|
455
467
|
*/
|
|
456
|
-
declare function defineConfig
|
|
468
|
+
declare function defineConfig<const T extends UserConfig | UserConfigFn>(options: T): T;
|
|
457
469
|
//#endregion
|
|
458
|
-
export { BuildContext, Options$3 as Options, ReportPlugin, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build$1 as build, buildSingle, defineConfig, logger, shimFile };
|
|
470
|
+
export { type BuildContext, type Options$3 as Options, ReportPlugin, type ResolvedOptions, TsdownChunks, type TsdownHooks, type UserConfig, type UserConfigFn, build$1 as build, buildSingle, defineConfig, logger, shimFile };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn, defineConfig } from "./config
|
|
1
|
+
import { UserConfig, UserConfigFn, defineConfig } from "./config--Vetp6NA.mjs";
|
|
2
2
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, shimFile } from "./config
|
|
1
|
+
import { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, shimFile } from "./config--Vetp6NA.mjs";
|
|
2
2
|
export { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, shimFile };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig } from "./config-CzjtjH-U.mjs";
|
|
2
|
-
import { build, buildSingle, shimFile } from "./src-
|
|
2
|
+
import { build, buildSingle, shimFile } from "./src-vU2xJl3a.mjs";
|
|
3
3
|
import { logger } from "./logger-6IV2T7t1.mjs";
|
|
4
4
|
|
|
5
5
|
export { build, buildSingle, defineConfig, logger, shimFile };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from "./logger-6IV2T7t1.mjs";
|
|
2
|
-
import { version } from "./package-
|
|
2
|
+
import { version } from "./package-BCFwezi2.mjs";
|
|
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";
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { ReportPlugin, ResolvedOptions } from "./config
|
|
1
|
+
import { ReportPlugin, ResolvedOptions } from "./config--Vetp6NA.mjs";
|
|
2
2
|
import { Plugin } from "rolldown";
|
|
3
3
|
import { PackageJson } from "pkg-types";
|
|
4
4
|
|
|
5
5
|
//#region src/features/external.d.ts
|
|
6
6
|
declare function ExternalPlugin(options: ResolvedOptions): Plugin;
|
|
7
|
-
/*
|
|
8
|
-
* Production deps should be excluded from the bundle
|
|
9
|
-
*/
|
|
10
7
|
//#endregion
|
|
11
8
|
//#region src/features/shebang.d.ts
|
|
12
9
|
declare function ShebangPlugin(cwd: string, name?: string, isMultiFormat?: boolean): Plugin;
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./config-CzjtjH-U.mjs";
|
|
2
|
-
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-
|
|
2
|
+
import { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin } from "./src-vU2xJl3a.mjs";
|
|
3
3
|
import "./logger-6IV2T7t1.mjs";
|
|
4
4
|
|
|
5
5
|
export { ExternalPlugin, NodeProtocolPlugin, ReportPlugin, ShebangPlugin };
|
package/dist/run.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { logger, resolveComma, toArray } from "./logger-6IV2T7t1.mjs";
|
|
3
|
-
import { version } from "./package-
|
|
3
|
+
import { version } from "./package-BCFwezi2.mjs";
|
|
4
4
|
import module from "node:module";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { dim } from "ansis";
|
|
@@ -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-DHdrktiR.mjs");
|
|
26
26
|
await migrate(args);
|
|
27
27
|
});
|
|
28
28
|
async function runCLI() {
|
|
@@ -12,7 +12,7 @@ import { tmpdir } from "node:os";
|
|
|
12
12
|
import { promisify } from "node:util";
|
|
13
13
|
import debug from "debug";
|
|
14
14
|
import { glob } from "tinyglobby";
|
|
15
|
-
import { RE_DTS } from "rolldown-plugin-dts/filename";
|
|
15
|
+
import { RE_CSS, RE_DTS, RE_JS } from "rolldown-plugin-dts/filename";
|
|
16
16
|
import { createHooks } from "hookable";
|
|
17
17
|
import { up } from "empathic/package";
|
|
18
18
|
import { Buffer } from "node:buffer";
|
|
@@ -517,6 +517,18 @@ function createChunkFilename(basename, jsExtension, dtsExtension) {
|
|
|
517
517
|
return `${basename}${chunk.name.endsWith(".d") ? dtsExtension : jsExtension}`;
|
|
518
518
|
};
|
|
519
519
|
}
|
|
520
|
+
function resolveChunkAddon(chunkAddon, format) {
|
|
521
|
+
if (!chunkAddon) return;
|
|
522
|
+
return (chunk) => {
|
|
523
|
+
if (typeof chunkAddon === "function") chunkAddon = chunkAddon({ format });
|
|
524
|
+
switch (true) {
|
|
525
|
+
case RE_JS.test(chunk.fileName): return chunkAddon?.js || "";
|
|
526
|
+
case RE_CSS.test(chunk.fileName): return chunkAddon?.css || "";
|
|
527
|
+
case RE_DTS.test(chunk.fileName): return chunkAddon?.dts || "";
|
|
528
|
+
default: return "";
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
520
532
|
|
|
521
533
|
//#endregion
|
|
522
534
|
//#region src/features/publint.ts
|
|
@@ -1184,7 +1196,7 @@ async function buildSingle(config, clean) {
|
|
|
1184
1196
|
}
|
|
1185
1197
|
}
|
|
1186
1198
|
async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
1187
|
-
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, unbundle } = config;
|
|
1199
|
+
const { entry, external, plugins: userPlugins, outDir, platform, alias, treeshake, sourcemap, dts, minify, unused, target, define, shims, tsconfig, cwd, report, env, nodeProtocol, loader, name, unbundle, banner, footer } = config;
|
|
1188
1200
|
const plugins = [];
|
|
1189
1201
|
if (nodeProtocol) plugins.push(NodeProtocolPlugin(nodeProtocol));
|
|
1190
1202
|
if (config.pkg || config.skipNodeModulesBundle) plugins.push(ExternalPlugin(config));
|
|
@@ -1210,6 +1222,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
|
1210
1222
|
}
|
|
1211
1223
|
if (report && !logger.silent) plugins.push(ReportPlugin(report, cwd, cjsDts, name, isMultiFormat));
|
|
1212
1224
|
if (!cjsDts) plugins.push(userPlugins);
|
|
1225
|
+
cjsDts = !!cjsDts;
|
|
1213
1226
|
const inputOptions = await mergeUserOptions({
|
|
1214
1227
|
input: entry,
|
|
1215
1228
|
cwd,
|
|
@@ -1233,7 +1246,7 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
|
1233
1246
|
plugins,
|
|
1234
1247
|
inject: { ...shims && !cjsDts && getShimsInject(format, platform) },
|
|
1235
1248
|
moduleTypes: loader
|
|
1236
|
-
}, config.inputOptions, [format]);
|
|
1249
|
+
}, config.inputOptions, [format, { cjsDts }]);
|
|
1237
1250
|
const [entryFileNames, chunkFileNames] = resolveChunkFilename(config, inputOptions, format);
|
|
1238
1251
|
const outputOptions = await mergeUserOptions({
|
|
1239
1252
|
format: cjsDts ? "es" : format,
|
|
@@ -1244,8 +1257,10 @@ async function getBuildOptions(config, format, isMultiFormat, cjsDts) {
|
|
|
1244
1257
|
entryFileNames,
|
|
1245
1258
|
chunkFileNames,
|
|
1246
1259
|
preserveModules: unbundle,
|
|
1247
|
-
preserveModulesRoot: unbundle ? lowestCommonAncestor(...Object.values(entry)) : void 0
|
|
1248
|
-
|
|
1260
|
+
preserveModulesRoot: unbundle ? lowestCommonAncestor(...Object.values(entry)) : void 0,
|
|
1261
|
+
banner: resolveChunkAddon(banner, format),
|
|
1262
|
+
footer: resolveChunkAddon(footer, format)
|
|
1263
|
+
}, config.outputOptions, [format, { cjsDts }]);
|
|
1249
1264
|
return {
|
|
1250
1265
|
...inputOptions,
|
|
1251
1266
|
output: outputOptions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdown",
|
|
3
|
-
"version": "0.13.0-beta.
|
|
3
|
+
"version": "0.13.0-beta.2",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"diff": "^8.0.2",
|
|
75
75
|
"empathic": "^2.0.0",
|
|
76
76
|
"hookable": "^5.5.3",
|
|
77
|
-
"rolldown": "^1.0.0-beta.
|
|
78
|
-
"rolldown-plugin-dts": "^0.
|
|
77
|
+
"rolldown": "^1.0.0-beta.28",
|
|
78
|
+
"rolldown-plugin-dts": "^0.14.0",
|
|
79
79
|
"semver": "^7.7.2",
|
|
80
80
|
"tinyexec": "^1.0.1",
|
|
81
81
|
"tinyglobby": "^0.2.14",
|
|
@@ -83,18 +83,18 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@arethetypeswrong/core": "^0.18.2",
|
|
86
|
-
"@sxzz/eslint-config": "^7.0.
|
|
86
|
+
"@sxzz/eslint-config": "^7.0.6",
|
|
87
87
|
"@sxzz/prettier-config": "^2.2.3",
|
|
88
|
-
"@sxzz/test-utils": "^0.5.
|
|
88
|
+
"@sxzz/test-utils": "^0.5.7",
|
|
89
89
|
"@types/debug": "^4.1.12",
|
|
90
|
-
"@types/node": "^24.0.
|
|
90
|
+
"@types/node": "^24.0.14",
|
|
91
91
|
"@types/semver": "^7.7.0",
|
|
92
92
|
"@unocss/eslint-plugin": "^66.3.3",
|
|
93
93
|
"@vueuse/core": "^13.5.0",
|
|
94
94
|
"bumpp": "^10.2.0",
|
|
95
|
-
"eslint": "^9.
|
|
95
|
+
"eslint": "^9.31.0",
|
|
96
96
|
"lightningcss": "^1.30.1",
|
|
97
|
-
"oxc-minify": "^0.
|
|
97
|
+
"oxc-minify": "^0.77.2",
|
|
98
98
|
"pkg-types": "^2.2.0",
|
|
99
99
|
"prettier": "^3.6.2",
|
|
100
100
|
"publint": "^0.3.12",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"vite": "npm:rolldown-vite@latest",
|
|
109
109
|
"vitepress": "^2.0.0-alpha.7",
|
|
110
110
|
"vitepress-plugin-group-icons": "^1.6.1",
|
|
111
|
-
"vitepress-plugin-llms": "^1.7.
|
|
111
|
+
"vitepress-plugin-llms": "^1.7.1",
|
|
112
112
|
"vitest": "^3.2.4",
|
|
113
113
|
"vue": "^3.5.17"
|
|
114
114
|
},
|