tsdown 0.9.8 → 0.9.9
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.d-DI49UQhk.d.ts → config.d-Ca2e571o.d.ts} +1 -1
- package/dist/config.d.ts +2 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.js +56 -1
- package/dist/{migrate-fONPr2zj.js → migrate-CygdeFLJ.js} +1 -1
- package/dist/options.d-DF6uzkZt.d.ts +201 -0
- package/dist/package-Cr6J7APF.js +5 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/run.js +2 -2
- package/package.json +8 -6
- package/dist/options.d-BXikSiux.d.ts +0 -206
- package/dist/package-BBoT5Sps.js +0 -5
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { UserConfig, UserConfigFn } from "./options.d-
|
|
2
|
-
import { defineConfig$1 as defineConfig } from "./config.d-
|
|
3
|
-
|
|
1
|
+
import { UserConfig, UserConfigFn } from "./options.d-DF6uzkZt.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-Ca2e571o.js";
|
|
4
3
|
export { UserConfig, UserConfigFn, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-DF6uzkZt.js";
|
|
2
|
+
import { defineConfig$1 as defineConfig } from "./config.d-Ca2e571o.js";
|
|
3
3
|
import { ConsolaInstance } from "consola";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/logger.d.ts
|
|
@@ -15,6 +15,7 @@ declare const logger: ConsolaInstance;
|
|
|
15
15
|
*/
|
|
16
16
|
declare function build(userOptions?: Options): Promise<void>;
|
|
17
17
|
declare const pkgRoot: string;
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
20
|
* Build a single configuration, without watch and shortcuts features.
|
|
20
21
|
*
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { exec } from "tinyexec";
|
|
|
12
12
|
import { readdir, stat } from "node:fs/promises";
|
|
13
13
|
import { glob } from "tinyglobby";
|
|
14
14
|
import { createHooks } from "hookable";
|
|
15
|
+
import LightningCSS from "unplugin-lightningcss/rolldown";
|
|
15
16
|
import readline from "node:readline";
|
|
16
17
|
import { loadConfig } from "unconfig";
|
|
17
18
|
import { up } from "empathic/find";
|
|
@@ -49,6 +50,55 @@ async function createHooks$1(options, pkg) {
|
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/utils/lightningcss.ts
|
|
55
|
+
/**
|
|
56
|
+
* Converts esbuild target [^1] (which is also used by Rolldown [^2]) to Lightning CSS targets [^3].
|
|
57
|
+
*
|
|
58
|
+
* [^1]: https://esbuild.github.io/api/#target
|
|
59
|
+
* [^2]: https://github.com/rolldown/rolldown/blob/v1.0.0-beta.8/packages/rolldown/src/binding.d.ts#L1429-L1431
|
|
60
|
+
* [^3]: https://lightningcss.dev/transpilation.html
|
|
61
|
+
*/
|
|
62
|
+
function esbuildTargetToLightningCSS(target) {
|
|
63
|
+
let targets;
|
|
64
|
+
const targetString = target.join(" ").toLowerCase();
|
|
65
|
+
const matches = [...targetString.matchAll(TARGET_REGEX)];
|
|
66
|
+
for (const match of matches) {
|
|
67
|
+
const name = match[1];
|
|
68
|
+
const browser = ESBUILD_LIGHTNINGCSS_MAPPING[name];
|
|
69
|
+
if (!browser) continue;
|
|
70
|
+
const version = match[2];
|
|
71
|
+
const versionInt = parseVersion(version);
|
|
72
|
+
if (versionInt == null) continue;
|
|
73
|
+
targets = targets || {};
|
|
74
|
+
targets[browser] = versionInt;
|
|
75
|
+
}
|
|
76
|
+
return targets;
|
|
77
|
+
}
|
|
78
|
+
const TARGET_REGEX = /([a-z]+)(\d+(?:\.\d+)*)/g;
|
|
79
|
+
const ESBUILD_LIGHTNINGCSS_MAPPING = {
|
|
80
|
+
chrome: "chrome",
|
|
81
|
+
edge: "edge",
|
|
82
|
+
firefox: "firefox",
|
|
83
|
+
ie: "ie",
|
|
84
|
+
ios: "ios_saf",
|
|
85
|
+
opera: "opera",
|
|
86
|
+
safari: "safari"
|
|
87
|
+
};
|
|
88
|
+
function parseVersion(version) {
|
|
89
|
+
const [major, minor = 0, patch = 0] = version.split("-")[0].split(".").map((v) => Number.parseInt(v, 10));
|
|
90
|
+
if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch)) return null;
|
|
91
|
+
return major << 16 | minor << 8 | patch;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/features/lightningcss.ts
|
|
96
|
+
function LightningCSSPlugin(options) {
|
|
97
|
+
const targets = options.target && esbuildTargetToLightningCSS(options.target);
|
|
98
|
+
if (!targets) return;
|
|
99
|
+
return LightningCSS({ options: { targets } });
|
|
100
|
+
}
|
|
101
|
+
|
|
52
102
|
//#endregion
|
|
53
103
|
//#region src/features/output.ts
|
|
54
104
|
function resolveJsOutputExtension(packageType, format, fixedExtension) {
|
|
@@ -511,7 +561,12 @@ async function getBuildOptions(config, pkg, format, cjsDts) {
|
|
|
511
561
|
}));
|
|
512
562
|
plugins.push(ShebangPlugin(cwd));
|
|
513
563
|
}
|
|
514
|
-
if (report) plugins.push(ReportPlugin(report, cwd, cjsDts));
|
|
564
|
+
if (report && logger.level >= 3) plugins.push(ReportPlugin(report, cwd, cjsDts));
|
|
565
|
+
if (target) plugins.push(
|
|
566
|
+
// Use Lightning CSS to handle CSS input. This is a temporary solution
|
|
567
|
+
// until Rolldown supports CSS syntax lowering natively.
|
|
568
|
+
LightningCSSPlugin({ target })
|
|
569
|
+
);
|
|
515
570
|
plugins.push(userPlugins);
|
|
516
571
|
const inputOptions = await mergeUserOptions({
|
|
517
572
|
input: entry,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, ModuleFormat, OutputOptions, Plugin } from "rolldown";
|
|
2
|
+
import { Hookable } from "hookable";
|
|
3
|
+
import { Options } from "publint";
|
|
4
|
+
import { Options as Options$1 } from "rolldown-plugin-dts";
|
|
5
|
+
import { Options as Options$2 } from "unplugin-unused";
|
|
6
|
+
import { PackageJson } from "pkg-types";
|
|
7
|
+
|
|
8
|
+
//#region src/features/hooks.d.ts
|
|
9
|
+
interface BuildContext {
|
|
10
|
+
options: ResolvedOptions;
|
|
11
|
+
pkg?: PackageJson;
|
|
12
|
+
hooks: Hookable<TsdownHooks>;
|
|
13
|
+
}
|
|
14
|
+
interface RolldownContext {
|
|
15
|
+
buildOptions: BuildOptions;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hooks for tsdown.
|
|
20
|
+
*/
|
|
21
|
+
interface TsdownHooks {
|
|
22
|
+
/**
|
|
23
|
+
* Invoked before each tsdown build starts.
|
|
24
|
+
* Use this hook to perform setup or preparation tasks.
|
|
25
|
+
*/
|
|
26
|
+
"build:prepare": (ctx: BuildContext) => void | Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Invoked before each Rolldown build.
|
|
29
|
+
* For dual-format builds, this hook is called for each format.
|
|
30
|
+
* Useful for configuring or modifying the build context before bundling.
|
|
31
|
+
*/
|
|
32
|
+
"build:before": (ctx: BuildContext & RolldownContext) => void | Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Invoked after each tsdown build completes.
|
|
35
|
+
* Use this hook for cleanup or post-processing tasks.
|
|
36
|
+
*/
|
|
37
|
+
"build:done": (ctx: BuildContext) => void | Promise<void>;
|
|
38
|
+
} //#endregion
|
|
39
|
+
//#region src/utils/package.d.ts
|
|
40
|
+
type PackageType = "module" | "commonjs" | undefined;
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/features/output.d.ts
|
|
44
|
+
interface OutExtensionContext {
|
|
45
|
+
options: InputOptions;
|
|
46
|
+
format: NormalizedFormat;
|
|
47
|
+
/** "type" field in project's package.json */
|
|
48
|
+
pkgType?: PackageType;
|
|
49
|
+
}
|
|
50
|
+
interface OutExtensionObject {
|
|
51
|
+
js?: string;
|
|
52
|
+
dts?: string;
|
|
53
|
+
}
|
|
54
|
+
type OutExtensionFactory = (ctx: OutExtensionContext) => OutExtensionObject;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/features/report.d.ts
|
|
58
|
+
interface ReportOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Enable/disable brotli-compressed size reporting.
|
|
61
|
+
* Compressing large output files can be slow, so disabling this may increase build performance for large projects.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
brotli?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Skip reporting compressed size for files larger than this size.
|
|
68
|
+
* @default 1_000_000 // 1MB
|
|
69
|
+
*/
|
|
70
|
+
maxCompressSize?: number;
|
|
71
|
+
}
|
|
72
|
+
declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: boolean): Plugin;
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/utils/types.d.ts
|
|
76
|
+
type Overwrite<T, U> = Omit<T, keyof U> & U;
|
|
77
|
+
type Awaitable<T> = T | Promise<T>;
|
|
78
|
+
type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
79
|
+
type Arrayable<T> = T | T[];
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/options.d.ts
|
|
83
|
+
type Sourcemap = boolean | "inline" | "hidden";
|
|
84
|
+
type Format = Exclude<ModuleFormat, "experimental-app">;
|
|
85
|
+
type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
|
|
86
|
+
interface MinifyOptions {
|
|
87
|
+
mangle?: boolean;
|
|
88
|
+
compress?: boolean;
|
|
89
|
+
removeWhitespace?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Options for tsdown.
|
|
94
|
+
*/
|
|
95
|
+
interface Options$3 {
|
|
96
|
+
entry?: InputOption;
|
|
97
|
+
external?: ExternalOption;
|
|
98
|
+
noExternal?: Arrayable<string | RegExp> | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
|
|
99
|
+
alias?: Record<string, string>;
|
|
100
|
+
tsconfig?: string | boolean;
|
|
101
|
+
/** @default 'node' */
|
|
102
|
+
platform?: "node" | "neutral" | "browser";
|
|
103
|
+
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat) => Awaitable<InputOptions | void | null>);
|
|
104
|
+
/** @default 'es' */
|
|
105
|
+
format?: Format | Format[];
|
|
106
|
+
globalName?: string;
|
|
107
|
+
/** @default 'dist' */
|
|
108
|
+
outDir?: string;
|
|
109
|
+
sourcemap?: Sourcemap;
|
|
110
|
+
clean?: boolean | string[];
|
|
111
|
+
/** @default false */
|
|
112
|
+
minify?: boolean | "dce-only" | MinifyOptions;
|
|
113
|
+
target?: string | string[];
|
|
114
|
+
define?: Record<string, string>;
|
|
115
|
+
/** @default false */
|
|
116
|
+
shims?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Use a fixed extension for output files.
|
|
119
|
+
* The extension will always be `.cjs` or `.mjs`.
|
|
120
|
+
* Otherwise, it will depend on the package type.
|
|
121
|
+
* @default false
|
|
122
|
+
*/
|
|
123
|
+
fixedExtension?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Custom extensions for output files.
|
|
126
|
+
* `fixedExtension` will be overridden by this option.
|
|
127
|
+
*/
|
|
128
|
+
outExtensions?: OutExtensionFactory;
|
|
129
|
+
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat) => Awaitable<OutputOptions | void | null>);
|
|
130
|
+
/** @default true */
|
|
131
|
+
treeshake?: boolean;
|
|
132
|
+
plugins?: InputOptions["plugins"];
|
|
133
|
+
silent?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Config file path
|
|
136
|
+
*/
|
|
137
|
+
config?: boolean | string;
|
|
138
|
+
watch?: boolean | string | string[];
|
|
139
|
+
/**
|
|
140
|
+
* You can specify command to be executed after a successful build, specially useful for Watch mode
|
|
141
|
+
*/
|
|
142
|
+
onSuccess?: string | ((config: ResolvedOptions) => void | Promise<void>);
|
|
143
|
+
/**
|
|
144
|
+
* Skip bundling node_modules.
|
|
145
|
+
*/
|
|
146
|
+
skipNodeModulesBundle?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Reuse config from Vite or Vitest (experimental)
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
fromVite?: boolean | "vitest";
|
|
152
|
+
/**
|
|
153
|
+
* Emit declaration files
|
|
154
|
+
*/
|
|
155
|
+
dts?: boolean | Options$1;
|
|
156
|
+
/**
|
|
157
|
+
* Enable unused dependencies check with `unplugin-unused`
|
|
158
|
+
* Requires `unplugin-unused` to be installed.
|
|
159
|
+
*/
|
|
160
|
+
unused?: boolean | Options$2;
|
|
161
|
+
/**
|
|
162
|
+
* Run publint after bundling.
|
|
163
|
+
* Requires `publint` to be installed.
|
|
164
|
+
*/
|
|
165
|
+
publint?: boolean | Options;
|
|
166
|
+
/**
|
|
167
|
+
* Enable size reporting after bundling.
|
|
168
|
+
* @default true
|
|
169
|
+
*/
|
|
170
|
+
report?: boolean | ReportOptions;
|
|
171
|
+
/**
|
|
172
|
+
* Compile-time env variables.
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* {
|
|
176
|
+
* "DEBUG": true,
|
|
177
|
+
* "NODE_ENV": "production"
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
env?: Record<string, any>;
|
|
182
|
+
hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Options without specifying config file path.
|
|
187
|
+
*/
|
|
188
|
+
type UserConfig = Arrayable<Omit<Options$3, "config">>;
|
|
189
|
+
type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
190
|
+
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks">, {
|
|
191
|
+
format: NormalizedFormat[];
|
|
192
|
+
target?: string[];
|
|
193
|
+
clean: string[] | false;
|
|
194
|
+
dts: false | Options$1;
|
|
195
|
+
report: false | ReportOptions;
|
|
196
|
+
tsconfig: string | false;
|
|
197
|
+
cwd: string;
|
|
198
|
+
}>, "config" | "fromVite">;
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn };
|
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-Cr6J7APF.js";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { dim } from "ansis";
|
|
6
6
|
import Debug from "debug";
|
|
@@ -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-CygdeFLJ.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.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "The Elegant Bundler for Libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,11 +62,13 @@
|
|
|
62
62
|
"diff": "^7.0.0",
|
|
63
63
|
"empathic": "^1.0.0",
|
|
64
64
|
"hookable": "^5.5.3",
|
|
65
|
+
"lightningcss": "^1.29.3",
|
|
65
66
|
"rolldown": "1.0.0-beta.8-commit.151352b",
|
|
66
|
-
"rolldown-plugin-dts": "^0.
|
|
67
|
+
"rolldown-plugin-dts": "^0.9.4",
|
|
67
68
|
"tinyexec": "^1.0.1",
|
|
68
69
|
"tinyglobby": "^0.2.13",
|
|
69
|
-
"unconfig": "^7.3.2"
|
|
70
|
+
"unconfig": "^7.3.2",
|
|
71
|
+
"unplugin-lightningcss": "^0.3.3"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
74
|
"@sxzz/eslint-config": "^6.1.2",
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
"@sxzz/test-utils": "^0.5.5",
|
|
75
77
|
"@types/debug": "^4.1.12",
|
|
76
78
|
"@types/diff": "^7.0.2",
|
|
77
|
-
"@types/node": "^22.
|
|
79
|
+
"@types/node": "^22.15.2",
|
|
78
80
|
"@unocss/eslint-plugin": "^66.1.0-beta.12",
|
|
79
81
|
"bumpp": "^10.1.0",
|
|
80
82
|
"eslint": "^9.25.1",
|
|
@@ -84,11 +86,11 @@
|
|
|
84
86
|
"tsup": "^8.4.0",
|
|
85
87
|
"tsx": "^4.19.3",
|
|
86
88
|
"typedoc": "^0.28.3",
|
|
87
|
-
"typedoc-plugin-markdown": "^4.6.
|
|
89
|
+
"typedoc-plugin-markdown": "^4.6.3",
|
|
88
90
|
"typescript": "~5.8.3",
|
|
89
91
|
"unocss": "^66.1.0-beta.12",
|
|
90
92
|
"unplugin-unused": "^0.4.4",
|
|
91
|
-
"vite": "^6.3.
|
|
93
|
+
"vite": "^6.3.3",
|
|
92
94
|
"vitepress": "^1.6.3",
|
|
93
95
|
"vitepress-plugin-group-icons": "^1.5.2",
|
|
94
96
|
"vitepress-plugin-llms": "^1.1.0",
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { BuildOptions, ExternalOption, InputOption, InputOptions, InternalModuleFormat, ModuleFormat, OutputOptions, Plugin } from "rolldown";
|
|
2
|
-
import { Hookable } from "hookable";
|
|
3
|
-
import { Options } from "publint";
|
|
4
|
-
import { Options as Options$1 } from "rolldown-plugin-dts";
|
|
5
|
-
import { Options as Options$2 } from "unplugin-unused";
|
|
6
|
-
import { PackageJson } from "pkg-types";
|
|
7
|
-
|
|
8
|
-
//#region src/features/hooks.d.ts
|
|
9
|
-
interface BuildContext {
|
|
10
|
-
options: ResolvedOptions;
|
|
11
|
-
pkg?: PackageJson;
|
|
12
|
-
hooks: Hookable<TsdownHooks>;
|
|
13
|
-
}
|
|
14
|
-
interface RolldownContext {
|
|
15
|
-
buildOptions: BuildOptions;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Hooks for tsdown.
|
|
19
|
-
*/
|
|
20
|
-
interface TsdownHooks {
|
|
21
|
-
/**
|
|
22
|
-
* Invoked before each tsdown build starts.
|
|
23
|
-
* Use this hook to perform setup or preparation tasks.
|
|
24
|
-
*/
|
|
25
|
-
"build:prepare": (ctx: BuildContext) => void | Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Invoked before each Rolldown build.
|
|
28
|
-
* For dual-format builds, this hook is called for each format.
|
|
29
|
-
* Useful for configuring or modifying the build context before bundling.
|
|
30
|
-
*/
|
|
31
|
-
"build:before": (ctx: BuildContext & RolldownContext) => void | Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Invoked after each tsdown build completes.
|
|
34
|
-
* Use this hook for cleanup or post-processing tasks.
|
|
35
|
-
*/
|
|
36
|
-
"build:done": (ctx: BuildContext) => void | Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/utils/package.d.ts
|
|
41
|
-
type PackageType = "module" | "commonjs" | undefined;
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/features/output.d.ts
|
|
45
|
-
interface OutExtensionContext {
|
|
46
|
-
options: InputOptions;
|
|
47
|
-
format: NormalizedFormat;
|
|
48
|
-
/** "type" field in project's package.json */
|
|
49
|
-
pkgType?: PackageType;
|
|
50
|
-
}
|
|
51
|
-
interface OutExtensionObject {
|
|
52
|
-
js?: string;
|
|
53
|
-
dts?: string;
|
|
54
|
-
}
|
|
55
|
-
type OutExtensionFactory = (ctx: OutExtensionContext) => OutExtensionObject;
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/features/report.d.ts
|
|
59
|
-
interface ReportOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Enable/disable brotli-compressed size reporting.
|
|
62
|
-
* Compressing large output files can be slow, so disabling this may increase build performance for large projects.
|
|
63
|
-
*
|
|
64
|
-
* @default false
|
|
65
|
-
*/
|
|
66
|
-
brotli?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Skip reporting compressed size for files larger than this size.
|
|
69
|
-
* @default 1_000_000 // 1MB
|
|
70
|
-
*/
|
|
71
|
-
maxCompressSize?: number;
|
|
72
|
-
}
|
|
73
|
-
declare function ReportPlugin(options: ReportOptions, cwd: string, cjsDts?: boolean): Plugin;
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/utils/types.d.ts
|
|
77
|
-
type Overwrite<
|
|
78
|
-
T,
|
|
79
|
-
U
|
|
80
|
-
> = Omit<T, keyof U> & U;
|
|
81
|
-
type Awaitable<T> = T | Promise<T>;
|
|
82
|
-
type MarkPartial<
|
|
83
|
-
T,
|
|
84
|
-
K extends keyof T
|
|
85
|
-
> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
86
|
-
type Arrayable<T> = T | T[];
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/options.d.ts
|
|
90
|
-
type Sourcemap = boolean | "inline" | "hidden";
|
|
91
|
-
type Format = Exclude<ModuleFormat, "experimental-app">;
|
|
92
|
-
type NormalizedFormat = Exclude<InternalModuleFormat, "app">;
|
|
93
|
-
interface MinifyOptions {
|
|
94
|
-
mangle?: boolean;
|
|
95
|
-
compress?: boolean;
|
|
96
|
-
removeWhitespace?: boolean;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Options for tsdown.
|
|
100
|
-
*/
|
|
101
|
-
interface Options$3 {
|
|
102
|
-
entry?: InputOption;
|
|
103
|
-
external?: ExternalOption;
|
|
104
|
-
noExternal?: Arrayable<string | RegExp> | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
|
|
105
|
-
alias?: Record<string, string>;
|
|
106
|
-
tsconfig?: string | boolean;
|
|
107
|
-
/** @default 'node' */
|
|
108
|
-
platform?: "node" | "neutral" | "browser";
|
|
109
|
-
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat) => Awaitable<InputOptions | void | null>);
|
|
110
|
-
/** @default 'es' */
|
|
111
|
-
format?: Format | Format[];
|
|
112
|
-
globalName?: string;
|
|
113
|
-
/** @default 'dist' */
|
|
114
|
-
outDir?: string;
|
|
115
|
-
sourcemap?: Sourcemap;
|
|
116
|
-
clean?: boolean | string[];
|
|
117
|
-
/** @default false */
|
|
118
|
-
minify?: boolean | "dce-only" | MinifyOptions;
|
|
119
|
-
target?: string | string[];
|
|
120
|
-
define?: Record<string, string>;
|
|
121
|
-
/** @default false */
|
|
122
|
-
shims?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Use a fixed extension for output files.
|
|
125
|
-
* The extension will always be `.cjs` or `.mjs`.
|
|
126
|
-
* Otherwise, it will depend on the package type.
|
|
127
|
-
* @default false
|
|
128
|
-
*/
|
|
129
|
-
fixedExtension?: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* Custom extensions for output files.
|
|
132
|
-
* `fixedExtension` will be overridden by this option.
|
|
133
|
-
*/
|
|
134
|
-
outExtensions?: OutExtensionFactory;
|
|
135
|
-
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat) => Awaitable<OutputOptions | void | null>);
|
|
136
|
-
/** @default true */
|
|
137
|
-
treeshake?: boolean;
|
|
138
|
-
plugins?: InputOptions["plugins"];
|
|
139
|
-
silent?: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Config file path
|
|
142
|
-
*/
|
|
143
|
-
config?: boolean | string;
|
|
144
|
-
watch?: boolean | string | string[];
|
|
145
|
-
/**
|
|
146
|
-
* You can specify command to be executed after a successful build, specially useful for Watch mode
|
|
147
|
-
*/
|
|
148
|
-
onSuccess?: string | ((config: ResolvedOptions) => void | Promise<void>);
|
|
149
|
-
/**
|
|
150
|
-
* Skip bundling node_modules.
|
|
151
|
-
*/
|
|
152
|
-
skipNodeModulesBundle?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Reuse config from Vite or Vitest (experimental)
|
|
155
|
-
* @default false
|
|
156
|
-
*/
|
|
157
|
-
fromVite?: boolean | "vitest";
|
|
158
|
-
/**
|
|
159
|
-
* Emit declaration files
|
|
160
|
-
*/
|
|
161
|
-
dts?: boolean | Options$1;
|
|
162
|
-
/**
|
|
163
|
-
* Enable unused dependencies check with `unplugin-unused`
|
|
164
|
-
* Requires `unplugin-unused` to be installed.
|
|
165
|
-
*/
|
|
166
|
-
unused?: boolean | Options$2;
|
|
167
|
-
/**
|
|
168
|
-
* Run publint after bundling.
|
|
169
|
-
* Requires `publint` to be installed.
|
|
170
|
-
*/
|
|
171
|
-
publint?: boolean | Options;
|
|
172
|
-
/**
|
|
173
|
-
* Enable size reporting after bundling.
|
|
174
|
-
* @default true
|
|
175
|
-
*/
|
|
176
|
-
report?: boolean | ReportOptions;
|
|
177
|
-
/**
|
|
178
|
-
* Compile-time env variables.
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* {
|
|
182
|
-
* "DEBUG": true,
|
|
183
|
-
* "NODE_ENV": "production"
|
|
184
|
-
* }
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
env?: Record<string, any>;
|
|
188
|
-
hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Options without specifying config file path.
|
|
192
|
-
*/
|
|
193
|
-
type UserConfig = Arrayable<Omit<Options$3, "config">>;
|
|
194
|
-
type UserConfigFn = (cliOptions: Options$3) => Awaitable<UserConfig>;
|
|
195
|
-
type ResolvedOptions = Omit<Overwrite<MarkPartial<Options$3, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "external" | "noExternal" | "onSuccess" | "fixedExtension" | "outExtensions" | "hooks">, {
|
|
196
|
-
format: NormalizedFormat[]
|
|
197
|
-
target?: string[]
|
|
198
|
-
clean: string[] | false
|
|
199
|
-
dts: false | Options$1
|
|
200
|
-
report: false | ReportOptions
|
|
201
|
-
tsconfig: string | false
|
|
202
|
-
cwd: string
|
|
203
|
-
}>, "config" | "fromVite">;
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
export { BuildContext, Options$3 as Options, ReportPlugin as ReportPlugin$1, ResolvedOptions, TsdownHooks, UserConfig, UserConfigFn };
|