tsdown 0.13.0-beta.1 → 0.13.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-BHQdCemQ.d.mts → config-9hj-APNF.d.mts} +34 -20
- package/dist/config.d.mts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{migrate-OhQ7vqGh.mjs → migrate-B4LQBP_A.mjs} +1 -1
- package/dist/package-CtrYqHTS.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
|
@@ -2,9 +2,9 @@ import "ansis";
|
|
|
2
2
|
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, OutputAsset, OutputChunk, OutputOptions, Plugin } from "rolldown";
|
|
3
3
|
import { Hookable } from "hookable";
|
|
4
4
|
import { CheckPackageOptions } from "@arethetypeswrong/core";
|
|
5
|
-
import { Options } from "publint";
|
|
6
|
-
import { Options as
|
|
7
|
-
import { Options as
|
|
5
|
+
import { Options as PublintOptions } from "publint";
|
|
6
|
+
import { Options as DtsOptions } from "rolldown-plugin-dts";
|
|
7
|
+
import { Options as UnusedOptions } from "unplugin-unused";
|
|
8
8
|
import { PackageJson } from "pkg-types";
|
|
9
9
|
|
|
10
10
|
//#region src/utils/types.d.ts
|
|
@@ -93,7 +93,7 @@ interface TsdownHooks {
|
|
|
93
93
|
/**
|
|
94
94
|
* Build with tsdown.
|
|
95
95
|
*/
|
|
96
|
-
declare function build$1(userOptions?: Options
|
|
96
|
+
declare function build$1(userOptions?: Options): Promise<void>;
|
|
97
97
|
declare const shimFile: string;
|
|
98
98
|
type TsdownChunks = Partial<Record<NormalizedFormat, Array<OutputChunk | OutputAsset>>>;
|
|
99
99
|
/**
|
|
@@ -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 {
|
|
@@ -184,8 +193,7 @@ interface Workspace {
|
|
|
184
193
|
/**
|
|
185
194
|
* Options for tsdown.
|
|
186
195
|
*/
|
|
187
|
-
interface Options
|
|
188
|
-
/// build options
|
|
196
|
+
interface 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;
|
|
@@ -263,7 +272,8 @@ interface Options$3 {
|
|
|
263
272
|
shims?: boolean;
|
|
264
273
|
/**
|
|
265
274
|
* The name to show in CLI output. This is useful for monorepos or workspaces.
|
|
266
|
-
*
|
|
275
|
+
* When using workspace mode, this option defaults to the package name from package.json.
|
|
276
|
+
* In non-workspace mode, this option must be set explicitly for the name to show in the CLI output.
|
|
267
277
|
*/
|
|
268
278
|
name?: string;
|
|
269
279
|
/**
|
|
@@ -278,7 +288,9 @@ interface Options$3 {
|
|
|
278
288
|
* `fixedExtension` will be overridden by this option.
|
|
279
289
|
*/
|
|
280
290
|
outExtensions?: OutExtensionFactory;
|
|
281
|
-
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat
|
|
291
|
+
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat, context: {
|
|
292
|
+
cjsDts: boolean;
|
|
293
|
+
}) => Awaitable<OutputOptions | void | null>);
|
|
282
294
|
/** @default true */
|
|
283
295
|
treeshake?: boolean;
|
|
284
296
|
plugins?: InputOptions["plugins"];
|
|
@@ -315,7 +327,6 @@ interface Options$3 {
|
|
|
315
327
|
* @default false
|
|
316
328
|
*/
|
|
317
329
|
fromVite?: boolean | "vitest";
|
|
318
|
-
/// addons
|
|
319
330
|
/**
|
|
320
331
|
* Emit TypeScript declaration files (.d.ts).
|
|
321
332
|
*
|
|
@@ -323,19 +334,19 @@ interface Options$3 {
|
|
|
323
334
|
* - If the `types` field is present in `package.json`, declaration file emission is enabled.
|
|
324
335
|
* - If the `types` field is absent, declaration file emission is disabled by default.
|
|
325
336
|
*/
|
|
326
|
-
dts?: boolean |
|
|
337
|
+
dts?: boolean | DtsOptions;
|
|
327
338
|
/**
|
|
328
339
|
* Enable unused dependencies check with `unplugin-unused`
|
|
329
340
|
* Requires `unplugin-unused` to be installed.
|
|
330
341
|
* @default false
|
|
331
342
|
*/
|
|
332
|
-
unused?: boolean |
|
|
343
|
+
unused?: boolean | UnusedOptions;
|
|
333
344
|
/**
|
|
334
345
|
* Run publint after bundling.
|
|
335
346
|
* Requires `publint` to be installed.
|
|
336
347
|
* @default false
|
|
337
348
|
*/
|
|
338
|
-
publint?: boolean |
|
|
349
|
+
publint?: boolean | PublintOptions;
|
|
339
350
|
/**
|
|
340
351
|
* Run `arethetypeswrong` after bundling.
|
|
341
352
|
* Requires `@arethetypeswrong/core` to be installed.
|
|
@@ -431,17 +442,20 @@ interface Options$3 {
|
|
|
431
442
|
* Filter workspace packages. This option is only available in workspace mode.
|
|
432
443
|
*/
|
|
433
444
|
filter?: RegExp | string | string[];
|
|
445
|
+
footer?: ChunkAddon;
|
|
446
|
+
banner?: ChunkAddon;
|
|
434
447
|
}
|
|
435
448
|
/**
|
|
436
449
|
* Options without specifying config file path.
|
|
437
450
|
*/
|
|
438
|
-
type UserConfig = Arrayable<Omit<Options
|
|
439
|
-
type UserConfigFn = (cliOptions: Options
|
|
440
|
-
type
|
|
451
|
+
type UserConfig = Arrayable<Omit<Options, "config" | "filter">>;
|
|
452
|
+
type UserConfigFn = (cliOptions: Options) => Awaitable<UserConfig>;
|
|
453
|
+
type NormalizedUserConfig = Exclude<UserConfig, any[]>;
|
|
454
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options, "publicDir" | "workspace" | "filter">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks" | "removeNodeProtocol" | "copy" | "loader" | "name" | "bundle" | "banner" | "footer">, {
|
|
441
455
|
format: NormalizedFormat[];
|
|
442
456
|
target?: string[];
|
|
443
457
|
clean: string[];
|
|
444
|
-
dts: false |
|
|
458
|
+
dts: false | DtsOptions;
|
|
445
459
|
report: false | ReportOptions;
|
|
446
460
|
tsconfig: string | false;
|
|
447
461
|
pkg?: PackageJson;
|
|
@@ -453,6 +467,6 @@ type ResolvedOptions = Omit<Overwrite<MarkPartial<Omit<Options$3, "publicDir" |
|
|
|
453
467
|
/**
|
|
454
468
|
* Defines the configuration for tsdown.
|
|
455
469
|
*/
|
|
456
|
-
declare function defineConfig
|
|
470
|
+
declare function defineConfig<const T extends UserConfig | UserConfigFn>(options: T): T;
|
|
457
471
|
//#endregion
|
|
458
|
-
export { BuildContext,
|
|
472
|
+
export { type AttwOptions, type BuildContext, type ChunkAddon, type CopyOptions, type DtsOptions, type ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, type Options, type PublintOptions, type ReportOptions, ReportPlugin, type ResolvedOptions, type RolldownContext, Sourcemap, TsdownChunks, type TsdownHooks, type UnusedOptions, type UserConfig, type UserConfigFn, Workspace, 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-9hj-APNF.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-
|
|
2
|
-
export { BuildContext, Options, ResolvedOptions, TsdownChunks, TsdownHooks, UserConfig, UserConfigFn, build, buildSingle, defineConfig, logger, shimFile };
|
|
1
|
+
import { AttwOptions, BuildContext, ChunkAddon, CopyOptions, DtsOptions, ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, build, buildSingle, defineConfig, logger, shimFile } from "./config-9hj-APNF.mjs";
|
|
2
|
+
export { AttwOptions, BuildContext, ChunkAddon, CopyOptions, DtsOptions, ExportsOptions, Format, ModuleTypes, NormalizedFormat, NormalizedUserConfig, Options, PublintOptions, ReportOptions, ResolvedOptions, RolldownContext, Sourcemap, TsdownChunks, TsdownHooks, UnusedOptions, UserConfig, UserConfigFn, Workspace, 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-CtrYqHTS.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-9hj-APNF.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-CtrYqHTS.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-B4LQBP_A.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
|
|
3
|
+
"version": "0.13.0",
|
|
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
|
},
|