Skip to content

Commit 77124d2

Browse files
committed
refactor: replace rolldown-plugin-dts-snapshot with tsnapi
1 parent c5192e2 commit 77124d2

17 files changed

+704
-212
lines changed

.prettierignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
tests/__snapshots__
2-
dts.snapshot.json
1+
__snapshots__
32
skills/**/*.md
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Generated by tsnapi — public API snapshot of `tsdown/config` */
3+
// Interfaces
4+
export interface UserConfig {
5+
entry?: TsdownInputOption;
6+
deps?: DepsConfig;
7+
external?: ExternalOption;
8+
noExternal?: Arrayable<string | RegExp> | NoExternalFn;
9+
inlineOnly?: Arrayable<string | RegExp> | false;
10+
skipNodeModulesBundle?: boolean;
11+
alias?: Record<string, string>;
12+
tsconfig?: string | boolean;
13+
platform?: "node" | "neutral" | "browser";
14+
target?: string | string[] | false;
15+
env?: Record<string, any>;
16+
envFile?: string;
17+
envPrefix?: string | string[];
18+
define?: Record<string, string>;
19+
shims?: boolean;
20+
treeshake?: boolean | TreeshakingOptions;
21+
loader?: ModuleTypes;
22+
removeNodeProtocol?: boolean;
23+
nodeProtocol?: "strip" | boolean;
24+
checks?: ChecksOptions & {
25+
legacyCjs?: boolean;
26+
};
27+
plugins?: InputOptions["plugins"];
28+
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
29+
cjsDts: boolean;
30+
}) => Awaitable<InputOptions | void | null>);
31+
format?: Format | Format[] | Partial<Record<Format, Partial<ResolvedConfig>>>;
32+
globalName?: string;
33+
outDir?: string;
34+
write?: boolean;
35+
sourcemap?: Sourcemap;
36+
clean?: boolean | string[];
37+
minify?: boolean | "dce-only" | MinifyOptions;
38+
footer?: ChunkAddon;
39+
banner?: ChunkAddon;
40+
unbundle?: boolean;
41+
root?: string;
42+
bundle?: boolean;
43+
fixedExtension?: boolean;
44+
outExtensions?: OutExtensionFactory;
45+
hash?: boolean;
46+
cjsDefault?: boolean;
47+
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat, context: {
48+
cjsDts: boolean;
49+
}) => Awaitable<OutputOptions | void | null>);
50+
cwd?: string;
51+
name?: string;
52+
logLevel?: LogLevel;
53+
failOnWarn?: boolean | CIOption;
54+
customLogger?: Logger;
55+
fromVite?: boolean | "vitest";
56+
watch?: boolean | Arrayable<string>;
57+
ignoreWatch?: Arrayable<string | RegExp>;
58+
devtools?: WithEnabled<DevtoolsOptions>;
59+
onSuccess?: string | ((config: ResolvedConfig, signal: AbortSignal) => void | Promise<void>);
60+
dts?: WithEnabled<DtsOptions>;
61+
unused?: WithEnabled<UnusedOptions>;
62+
publint?: WithEnabled<PublintOptions>;
63+
attw?: WithEnabled<AttwOptions>;
64+
report?: WithEnabled<ReportOptions>;
65+
globImport?: boolean;
66+
exports?: WithEnabled<ExportsOptions>;
67+
css?: _$_tsdown_css0.CssOptions;
68+
injectStyle?: boolean;
69+
publicDir?: CopyOptions | CopyOptionsFn;
70+
copy?: CopyOptions | CopyOptionsFn;
71+
hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
72+
exe?: WithEnabled<ExeOptions>;
73+
workspace?: Workspace | Arrayable<string> | true;
74+
}
75+
76+
// Types
77+
export type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
78+
export type UserConfigFn = (inlineConfig: InlineConfig, context: {
79+
ci: boolean;
80+
rootConfig?: UserConfig;
81+
}) => Awaitable<Arrayable<UserConfig>>;
82+
83+
// Functions
84+
export declare function defineConfig(_: UserConfigExport): UserConfigExport;
85+
export declare function mergeConfig(_: InlineConfig, ..._: InlineConfig[]): InlineConfig;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Generated by tsnapi — public API snapshot of `tsdown/config` */
3+
export function defineConfig(_) {}
4+
export function mergeConfig(_, ..._) {}
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
/**
2+
* Generated by tsnapi — public API snapshot of `tsdown` */
3+
// Interfaces
4+
export interface AttwOptions extends CheckPackageOptions {
5+
module?: typeof _$_arethetypeswrong_core0;
6+
profile?: "strict" | "node16" | "esm-only";
7+
level?: "error" | "warn";
8+
ignoreRules?: ("no-resolution" | "untyped-resolution" | "false-cjs" | "false-esm" | "cjs-resolves-to-esm" | "fallback-condition" | "cjs-only-exports-default" | "named-exports" | "false-export-default" | "missing-export-equals" | "unexpected-module-syntax" | "internal-resolution-error" | (string & {}))[];
9+
}
10+
export interface BuildContext {
11+
options: ResolvedConfig;
12+
hooks: Hookable<TsdownHooks>;
13+
}
14+
export interface ChunkAddonObject {
15+
js?: string;
16+
css?: string;
17+
dts?: string;
18+
}
19+
export interface CopyEntry {
20+
from: string | string[];
21+
to?: string;
22+
flatten?: boolean;
23+
verbose?: boolean;
24+
rename?: string | ((name: string, extension: string, fullPath: string) => string);
25+
}
26+
export interface DepsConfig {
27+
neverBundle?: ExternalOption;
28+
alwaysBundle?: Arrayable<string | RegExp> | NoExternalFn;
29+
onlyBundle?: Arrayable<string | RegExp> | false;
30+
onlyAllowBundle?: Arrayable<string | RegExp> | false;
31+
skipNodeModulesBundle?: boolean;
32+
}
33+
export interface DevtoolsOptions extends NonNullable<InputOptions["devtools"]> {
34+
ui?: boolean | Partial<StartOptions>;
35+
clean?: boolean;
36+
}
37+
export interface DtsOptions extends Options$1 {
38+
cjsReexport?: boolean;
39+
}
40+
export interface ExeOptions extends ExeExtensionOptions {
41+
seaConfig?: Omit<SeaConfig, "main" | "output" | "mainFormat">;
42+
fileName?: string | ((chunk: RolldownChunk) => string);
43+
outDir?: string;
44+
}
45+
export interface ExportsOptions {
46+
devExports?: boolean | string;
47+
packageJson?: boolean;
48+
all?: boolean;
49+
exclude?: (RegExp | string)[];
50+
legacy?: boolean;
51+
customExports?: Record<string, any> | ((exports: Record<string, any>, context: {
52+
pkg: PackageJson;
53+
chunks: ChunksByFormat;
54+
isPublish: boolean;
55+
}) => Awaitable<Record<string, any>>);
56+
inlinedDependencies?: boolean;
57+
bin?: boolean | string | Record<string, string>;
58+
}
59+
export interface InlineConfig extends UserConfig {
60+
config?: boolean | string;
61+
configLoader?: "auto" | "native" | "unrun";
62+
filter?: RegExp | Arrayable<string>;
63+
}
64+
export interface Logger {
65+
level: LogLevel;
66+
options?: LoggerOptions;
67+
info: (...args: any[]) => void;
68+
warn: (...args: any[]) => void;
69+
warnOnce: (...args: any[]) => void;
70+
error: (...args: any[]) => void;
71+
success: (...args: any[]) => void;
72+
clearScreen: (type: LogType) => void;
73+
}
74+
export interface OutExtensionContext {
75+
options: InputOptions;
76+
format: NormalizedFormat;
77+
pkgType?: PackageType;
78+
}
79+
export interface OutExtensionObject {
80+
js?: string;
81+
dts?: string;
82+
}
83+
export interface PackageJsonWithPath extends PackageJson {
84+
packageJsonPath: string;
85+
}
86+
export interface PublintOptions extends Omit<Options, "pack" | "pkgDir"> {
87+
module?: [typeof _$publint, typeof _$publint_utils0];
88+
}
89+
export interface ReportOptions {
90+
gzip?: boolean;
91+
brotli?: boolean;
92+
maxCompressSize?: number;
93+
}
94+
export interface ResolvedDepsConfig {
95+
neverBundle?: ExternalOption;
96+
alwaysBundle?: NoExternalFn;
97+
onlyBundle?: Array<string | RegExp> | false;
98+
skipNodeModulesBundle: boolean;
99+
}
100+
export interface RolldownContext {
101+
buildOptions: BuildOptions;
102+
}
103+
export interface SeaConfig {
104+
main?: string;
105+
executable?: string;
106+
output?: string;
107+
mainFormat?: "commonjs" | "module";
108+
disableExperimentalSEAWarning?: boolean;
109+
useSnapshot?: boolean;
110+
useCodeCache?: boolean;
111+
execArgv?: string[];
112+
execArgvExtension?: "none" | "env" | "cli";
113+
assets?: Record<string, string>;
114+
}
115+
export interface TsdownBundle extends AsyncDisposable {
116+
chunks: RolldownChunk[];
117+
config: ResolvedConfig;
118+
inlinedDeps: Map<string, Set<string>>;
119+
}
120+
export interface TsdownHooks {
121+
"build:prepare": (ctx: BuildContext) => void | Promise<void>;
122+
"build:before": (ctx: BuildContext & RolldownContext) => void | Promise<void>;
123+
"build:done": (ctx: BuildContext & {
124+
chunks: RolldownChunk[];
125+
}) => void | Promise<void>;
126+
}
127+
export interface UserConfig {
128+
entry?: TsdownInputOption;
129+
deps?: DepsConfig;
130+
external?: ExternalOption;
131+
noExternal?: Arrayable<string | RegExp> | NoExternalFn;
132+
inlineOnly?: Arrayable<string | RegExp> | false;
133+
skipNodeModulesBundle?: boolean;
134+
alias?: Record<string, string>;
135+
tsconfig?: string | boolean;
136+
platform?: "node" | "neutral" | "browser";
137+
target?: string | string[] | false;
138+
env?: Record<string, any>;
139+
envFile?: string;
140+
envPrefix?: string | string[];
141+
define?: Record<string, string>;
142+
shims?: boolean;
143+
treeshake?: boolean | TreeshakingOptions;
144+
loader?: ModuleTypes;
145+
removeNodeProtocol?: boolean;
146+
nodeProtocol?: "strip" | boolean;
147+
checks?: ChecksOptions & {
148+
legacyCjs?: boolean;
149+
};
150+
plugins?: InputOptions["plugins"];
151+
inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
152+
cjsDts: boolean;
153+
}) => Awaitable<InputOptions | void | null>);
154+
format?: Format | Format[] | Partial<Record<Format, Partial<ResolvedConfig>>>;
155+
globalName?: string;
156+
outDir?: string;
157+
write?: boolean;
158+
sourcemap?: Sourcemap;
159+
clean?: boolean | string[];
160+
minify?: boolean | "dce-only" | MinifyOptions;
161+
footer?: ChunkAddon;
162+
banner?: ChunkAddon;
163+
unbundle?: boolean;
164+
root?: string;
165+
bundle?: boolean;
166+
fixedExtension?: boolean;
167+
outExtensions?: OutExtensionFactory;
168+
hash?: boolean;
169+
cjsDefault?: boolean;
170+
outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat, context: {
171+
cjsDts: boolean;
172+
}) => Awaitable<OutputOptions | void | null>);
173+
cwd?: string;
174+
name?: string;
175+
logLevel?: LogLevel;
176+
failOnWarn?: boolean | CIOption;
177+
customLogger?: Logger;
178+
fromVite?: boolean | "vitest";
179+
watch?: boolean | Arrayable<string>;
180+
ignoreWatch?: Arrayable<string | RegExp>;
181+
devtools?: WithEnabled<DevtoolsOptions>;
182+
onSuccess?: string | ((config: ResolvedConfig, signal: AbortSignal) => void | Promise<void>);
183+
dts?: WithEnabled<DtsOptions>;
184+
unused?: WithEnabled<UnusedOptions>;
185+
publint?: WithEnabled<PublintOptions>;
186+
attw?: WithEnabled<AttwOptions>;
187+
report?: WithEnabled<ReportOptions>;
188+
globImport?: boolean;
189+
exports?: WithEnabled<ExportsOptions>;
190+
css?: _$_tsdown_css0.CssOptions;
191+
injectStyle?: boolean;
192+
publicDir?: CopyOptions | CopyOptionsFn;
193+
copy?: CopyOptions | CopyOptionsFn;
194+
hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
195+
exe?: WithEnabled<ExeOptions>;
196+
workspace?: Workspace | Arrayable<string> | true;
197+
}
198+
export interface Workspace {
199+
include?: Arrayable<string> | "auto";
200+
exclude?: Arrayable<string>;
201+
config?: boolean | string;
202+
}
203+
204+
// Types
205+
export type ChunkAddon = ChunkAddonObject | ChunkAddonFunction | string;
206+
export type ChunkAddonFunction = (ctx: {
207+
format: Format;
208+
fileName: string;
209+
}) => ChunkAddonObject | string | undefined;
210+
export type CIOption = "ci-only" | "local-only";
211+
export type CopyOptions = Arrayable<string | CopyEntry>;
212+
export type CopyOptionsFn = (options: ResolvedConfig) => Awaitable<CopyOptions>;
213+
export type Format = ModuleFormat;
214+
export type NoExternalFn = (id: string, importer: string | undefined) => boolean | null | undefined | void;
215+
export type NormalizedFormat = InternalModuleFormat;
216+
export type OutExtensionFactory = (context: OutExtensionContext) => OutExtensionObject | undefined;
217+
export type PackageType = "module" | "commonjs" | undefined;
218+
export type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "injectStyle" | "removeNodeProtocol" | "external" | "noExternal" | "inlineOnly" | "skipNodeModulesBundle" | "logLevel" | "failOnWarn" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks" | "css">, {
219+
entry: Record<string, string>;
220+
rawEntry?: TsdownInputOption;
221+
nameLabel: string | undefined;
222+
format: NormalizedFormat;
223+
target?: string[];
224+
clean: string[];
225+
pkg?: PackageJsonWithPath;
226+
nodeProtocol: "strip" | boolean;
227+
logger: Logger;
228+
ignoreWatch: Array<string | RegExp>;
229+
deps: ResolvedDepsConfig;
230+
root: string;
231+
dts: false | DtsOptions;
232+
report: false | ReportOptions;
233+
tsconfig: false | string;
234+
exports: false | ExportsOptions;
235+
devtools: false | DevtoolsOptions;
236+
publint: false | PublintOptions;
237+
attw: false | AttwOptions;
238+
unused: false | UnusedOptions;
239+
exe: false | ExeOptions;
240+
}>;
241+
export type RolldownChunk = (OutputChunk | OutputAsset) & {
242+
outDir: string;
243+
};
244+
export type Sourcemap = boolean | "inline" | "hidden";
245+
export type TsdownInputOption = Arrayable<string | Record<string, Arrayable<string>>>;
246+
export type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
247+
export type UserConfigFn = (inlineConfig: InlineConfig, context: {
248+
ci: boolean;
249+
rootConfig?: UserConfig;
250+
}) => Awaitable<Arrayable<UserConfig>>;
251+
export type WithEnabled<T> = boolean | undefined | CIOption | (T & {
252+
enabled?: boolean | CIOption;
253+
});
254+
255+
// Functions
256+
export declare function build(_?: InlineConfig): Promise<TsdownBundle[]>;
257+
export declare function buildWithConfigs(_: ResolvedConfig[], _: string[], _: () => void): Promise<TsdownBundle[]>;
258+
export declare function defineConfig(_: UserConfigExport): UserConfigExport;
259+
export declare function enableDebug(_?: boolean | Arrayable<string>): void;
260+
export declare function mergeConfig(_: InlineConfig, ..._: InlineConfig[]): InlineConfig;
261+
export declare function resolveUserConfig(_: UserConfig, _: InlineConfig): Promise<ResolvedConfig[]>;
262+
263+
// Variables
264+
export declare const globalLogger: Logger;
265+
266+
// Other
267+
export { Rolldown }
268+
export { TreeshakingOptions }
269+
export { UnusedOptions }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Generated by tsnapi — public API snapshot of `tsdown` */
3+
export async function build(_) {}
4+
export async function buildWithConfigs(_, _, _) {}
5+
export { defineConfig }
6+
export function enableDebug(_) {}
7+
export var globalLogger /* const */
8+
export function mergeConfig(_, ..._) {}
9+
export async function resolveUserConfig(_, _) {}
10+
export { Rolldown }

0 commit comments

Comments
 (0)