@rollipop/rolldown 0.0.0-beta.3 → 1.0.0-rc.1
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/cli-setup.mjs +1 -1
- package/dist/cli.mjs +121 -114
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +8 -8
- package/dist/experimental-index.d.mts +43 -43
- package/dist/experimental-index.mjs +6 -6
- package/dist/filter-index.d.mts +197 -4
- package/dist/filter-index.mjs +1 -1
- package/dist/get-log-filter.d.mts +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +27 -8
- package/dist/parallel-plugin-worker.mjs +4 -4
- package/dist/parallel-plugin.d.mts +4 -4
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +2 -2
- package/dist/plugins-index.d.mts +3 -4
- package/dist/plugins-index.mjs +3 -3
- package/dist/shared/binding-B92Lq__Q.d.mts +1687 -0
- package/dist/shared/{binding-uOeDeDzp.mjs → binding-tNJoEqAa.mjs} +28 -26
- package/dist/shared/{bindingify-input-options-CuBDHglZ.mjs → bindingify-input-options-CfhrNd_y.mjs} +117 -58
- package/dist/shared/{constructors-D9F4Aj4h.d.mts → constructors--k1uxZrh.d.mts} +2 -2
- package/dist/shared/{constructors-DmSv3tnW.mjs → constructors-414MPkgB.mjs} +1 -1
- package/dist/shared/define-config-D8xP5iyL.d.mts +3463 -0
- package/dist/shared/{load-config-Bo3y98vw.mjs → load-config-Qtd9pHJ5.mjs} +1 -1
- package/dist/shared/logging-wIy4zY9I.d.mts +50 -0
- package/dist/shared/{normalize-string-or-regex-0f6WITto.mjs → normalize-string-or-regex-DeB7vQ75.mjs} +2 -2
- package/dist/shared/{parse-ast-index-B0iVLbj6.mjs → parse-ast-index-BcP4Ts_P.mjs} +3 -3
- package/dist/shared/{prompt-BZ-QjPVS.mjs → prompt-tlfjalEt.mjs} +1 -1
- package/dist/shared/rolldown-BMzJcmQ7.mjs +42 -0
- package/dist/shared/{rolldown-build-BqHWBpp7.mjs → rolldown-build-DWeKtJOy.mjs} +123 -47
- package/dist/shared/{watch-Ce8bKBAn.mjs → watch-HmN4U4B9.mjs} +34 -6
- package/package.json +18 -16
- package/dist/shared/binding-C9YdqoUG.d.mts +0 -1657
- package/dist/shared/define-config-glNgjHCc.d.mts +0 -2573
- package/dist/shared/logging-DsnCZi19.d.mts +0 -42
- package/dist/shared/rolldown-mAJGca5O.mjs +0 -11
- /package/dist/shared/{define-config-BF4P-Pum.mjs → define-config-BVG4QvnP.mjs} +0 -0
- /package/dist/shared/{logs-N5Akftom.mjs → logs-NH298mHo.mjs} +0 -0
- /package/dist/shared/{misc-0HsaOsAX.mjs → misc-CCZIsXVO.mjs} +0 -0
|
@@ -1,2573 +0,0 @@
|
|
|
1
|
-
import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-DsnCZi19.mjs";
|
|
2
|
-
import { C as BindingWatcherBundler, L as TransformOptions$1, N as ParserOptions, O as JsxOptions, P as PreRenderedChunk, T as ExternalMemoryStatus, a as BindingHookResolveIdExtraArgs, d as BindingTransformHookExtraArgs, k as MinifyOptions$1, l as BindingRenderedChunk, s as BindingMagicString, t as BindingBuiltinPluginName, w as BindingWatcherEvent } from "./binding-C9YdqoUG.mjs";
|
|
3
|
-
import { TopLevelFilterExpression } from "@rollipop/rolldown-pluginutils";
|
|
4
|
-
import { Program } from "@oxc-project/types";
|
|
5
|
-
|
|
6
|
-
//#region src/types/misc.d.ts
|
|
7
|
-
/** @inline */
|
|
8
|
-
type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
|
|
9
|
-
/** @inline */
|
|
10
|
-
type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/types/module-info.d.ts
|
|
13
|
-
/** @category Plugin APIs */
|
|
14
|
-
interface ModuleInfo extends ModuleOptions {
|
|
15
|
-
/**
|
|
16
|
-
* Unsupported at rolldown
|
|
17
|
-
*/
|
|
18
|
-
ast: any;
|
|
19
|
-
code: string | null;
|
|
20
|
-
id: string;
|
|
21
|
-
importers: string[];
|
|
22
|
-
dynamicImporters: string[];
|
|
23
|
-
importedIds: string[];
|
|
24
|
-
dynamicallyImportedIds: string[];
|
|
25
|
-
exports: string[];
|
|
26
|
-
isEntry: boolean;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/utils/asset-source.d.ts
|
|
30
|
-
type AssetSource = string | Uint8Array;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/types/external-memory-handle.d.ts
|
|
33
|
-
declare const symbolForExternalMemoryHandle: "__rolldown_external_memory_handle__";
|
|
34
|
-
/**
|
|
35
|
-
* Interface for objects that hold external memory that can be explicitly freed.
|
|
36
|
-
*/
|
|
37
|
-
interface ExternalMemoryHandle {
|
|
38
|
-
/**
|
|
39
|
-
* Frees the external memory held by this object.
|
|
40
|
-
* @param keepDataAlive - If true, evaluates all lazy fields before freeing memory.
|
|
41
|
-
* This will take time but prevents errors when accessing properties after freeing.
|
|
42
|
-
* @returns Status object with `freed` boolean and optional `reason` string.
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
[symbolForExternalMemoryHandle]: (keepDataAlive?: boolean) => ExternalMemoryStatus;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Frees the external memory held by the given handle.
|
|
49
|
-
*
|
|
50
|
-
* This is useful when you want to manually release memory held by Rust objects
|
|
51
|
-
* (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
|
|
52
|
-
*
|
|
53
|
-
* @param handle - The object with external memory to free
|
|
54
|
-
* @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
|
|
55
|
-
* This will take time to copy data from Rust to JavaScript, but prevents errors
|
|
56
|
-
* when accessing properties after the memory is freed.
|
|
57
|
-
* @returns Status object with `freed` boolean and optional `reason` string.
|
|
58
|
-
* - `{ freed: true }` if memory was successfully freed
|
|
59
|
-
* - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* import { freeExternalMemory } from '@rollipop/rolldown/experimental';
|
|
64
|
-
*
|
|
65
|
-
* const output = await bundle.generate();
|
|
66
|
-
* const chunk = output.output[0];
|
|
67
|
-
*
|
|
68
|
-
* // Use the chunk...
|
|
69
|
-
*
|
|
70
|
-
* // Manually free the memory (fast, but accessing properties after will throw)
|
|
71
|
-
* const status = freeExternalMemory(chunk); // { freed: true }
|
|
72
|
-
* const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
|
|
73
|
-
*
|
|
74
|
-
* // Keep data alive before freeing (slower, but data remains accessible)
|
|
75
|
-
* freeExternalMemory(chunk, true); // Evaluates all lazy fields first
|
|
76
|
-
* console.log(chunk.code); // OK - data was copied to JavaScript before freeing
|
|
77
|
-
*
|
|
78
|
-
* // Without keepDataAlive, accessing chunk properties after freeing will throw an error
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
declare function freeExternalMemory(handle: ExternalMemoryHandle, keepDataAlive?: boolean): ExternalMemoryStatus;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/types/rolldown-output.d.ts
|
|
84
|
-
/** @category Plugin APIs */
|
|
85
|
-
interface OutputAsset extends ExternalMemoryHandle {
|
|
86
|
-
type: "asset";
|
|
87
|
-
fileName: string;
|
|
88
|
-
/** @deprecated Use "originalFileNames" instead. */
|
|
89
|
-
originalFileName: string | null;
|
|
90
|
-
originalFileNames: string[];
|
|
91
|
-
source: AssetSource;
|
|
92
|
-
/** @deprecated Use "names" instead. */
|
|
93
|
-
name: string | undefined;
|
|
94
|
-
names: string[];
|
|
95
|
-
}
|
|
96
|
-
/** @category Plugin APIs */
|
|
97
|
-
interface SourceMap {
|
|
98
|
-
file: string;
|
|
99
|
-
mappings: string;
|
|
100
|
-
names: string[];
|
|
101
|
-
sources: string[];
|
|
102
|
-
sourcesContent: string[];
|
|
103
|
-
version: number;
|
|
104
|
-
debugId?: string;
|
|
105
|
-
x_google_ignoreList?: number[];
|
|
106
|
-
toString(): string;
|
|
107
|
-
toUrl(): string;
|
|
108
|
-
}
|
|
109
|
-
/** @category Plugin APIs */
|
|
110
|
-
interface RenderedModule {
|
|
111
|
-
readonly code: string | null;
|
|
112
|
-
renderedLength: number;
|
|
113
|
-
renderedExports: string[];
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The information about the chunk being rendered.
|
|
117
|
-
*
|
|
118
|
-
* Unlike {@link OutputChunk}, `code` and `map` are not set as the chunk has not been rendered yet.
|
|
119
|
-
* All referenced chunk file names in each property that would contain hashes will contain hash placeholders instead.
|
|
120
|
-
*
|
|
121
|
-
* @category Plugin APIs
|
|
122
|
-
*/
|
|
123
|
-
interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
|
|
124
|
-
type: "chunk";
|
|
125
|
-
modules: {
|
|
126
|
-
[id: string]: RenderedModule;
|
|
127
|
-
};
|
|
128
|
-
name: string;
|
|
129
|
-
isEntry: boolean;
|
|
130
|
-
isDynamicEntry: boolean;
|
|
131
|
-
facadeModuleId: string | null;
|
|
132
|
-
moduleIds: Array<string>;
|
|
133
|
-
exports: Array<string>;
|
|
134
|
-
fileName: string;
|
|
135
|
-
imports: Array<string>;
|
|
136
|
-
dynamicImports: Array<string>;
|
|
137
|
-
}
|
|
138
|
-
/** @category Plugin APIs */
|
|
139
|
-
interface OutputChunk extends ExternalMemoryHandle {
|
|
140
|
-
type: "chunk";
|
|
141
|
-
code: string;
|
|
142
|
-
name: string;
|
|
143
|
-
isEntry: boolean;
|
|
144
|
-
exports: string[];
|
|
145
|
-
fileName: string;
|
|
146
|
-
modules: {
|
|
147
|
-
[id: string]: RenderedModule;
|
|
148
|
-
};
|
|
149
|
-
imports: string[];
|
|
150
|
-
dynamicImports: string[];
|
|
151
|
-
facadeModuleId: string | null;
|
|
152
|
-
isDynamicEntry: boolean;
|
|
153
|
-
moduleIds: string[];
|
|
154
|
-
map: SourceMap | null;
|
|
155
|
-
sourcemapFileName: string | null;
|
|
156
|
-
preliminaryFileName: string;
|
|
157
|
-
}
|
|
158
|
-
/** @category Programmatic APIs */
|
|
159
|
-
interface RolldownOutput extends ExternalMemoryHandle {
|
|
160
|
-
output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/types/utils.d.ts
|
|
164
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
165
|
-
type NullValue<T = void> = T | undefined | null | void;
|
|
166
|
-
type PartialNull<T> = { [P in keyof T]: T[P] | null };
|
|
167
|
-
type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
|
|
168
|
-
type MaybeArray<T> = T | T[];
|
|
169
|
-
type StringOrRegExp = string | RegExp;
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/options/output-options.d.ts
|
|
172
|
-
type GeneratedCodePreset = "es5" | "es2015";
|
|
173
|
-
interface GeneratedCodeOptions {
|
|
174
|
-
/**
|
|
175
|
-
* Whether to use Symbol.toStringTag for namespace objects.
|
|
176
|
-
* @default false
|
|
177
|
-
*/
|
|
178
|
-
symbols?: boolean;
|
|
179
|
-
/**
|
|
180
|
-
* Allows choosing one of the presets listed above while overriding some options.
|
|
181
|
-
*
|
|
182
|
-
* ```js
|
|
183
|
-
* export default {
|
|
184
|
-
* output: {
|
|
185
|
-
* generatedCode: {
|
|
186
|
-
* preset: 'es2015',
|
|
187
|
-
* symbols: false
|
|
188
|
-
* }
|
|
189
|
-
* }
|
|
190
|
-
* };
|
|
191
|
-
* ```
|
|
192
|
-
*
|
|
193
|
-
* @default 'es2015'
|
|
194
|
-
*/
|
|
195
|
-
preset?: GeneratedCodePreset;
|
|
196
|
-
/**
|
|
197
|
-
* Whether to add readable names to internal variables for profiling purposes.
|
|
198
|
-
*
|
|
199
|
-
* When enabled, generated code will use descriptive variable names that correspond
|
|
200
|
-
* to the original module names, making it easier to profile and debug the bundled code.
|
|
201
|
-
*
|
|
202
|
-
* @default false
|
|
203
|
-
*
|
|
204
|
-
* {@include ./docs/output-generated-code-profiler-names.md}
|
|
205
|
-
*/
|
|
206
|
-
profilerNames?: boolean;
|
|
207
|
-
}
|
|
208
|
-
/** @inline */
|
|
209
|
-
type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
|
|
210
|
-
/** @inline */
|
|
211
|
-
type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
212
|
-
/** @inline */
|
|
213
|
-
type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
|
|
214
|
-
/** @inline */
|
|
215
|
-
type SanitizeFileNameFunction = (name: string) => string;
|
|
216
|
-
/** @category Plugin APIs */
|
|
217
|
-
interface PreRenderedAsset {
|
|
218
|
-
type: "asset";
|
|
219
|
-
name?: string;
|
|
220
|
-
names: string[];
|
|
221
|
-
originalFileName?: string;
|
|
222
|
-
originalFileNames: string[];
|
|
223
|
-
source: string | Uint8Array;
|
|
224
|
-
}
|
|
225
|
-
/** @inline */
|
|
226
|
-
type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
|
|
227
|
-
/** @inline */
|
|
228
|
-
type PathsFunction$1 = (id: string) => string;
|
|
229
|
-
/** @inline */
|
|
230
|
-
type ManualChunksFunction = (moduleId: string, meta: {
|
|
231
|
-
getModuleInfo: (moduleId: string) => ModuleInfo | null;
|
|
232
|
-
}) => string | NullValue;
|
|
233
|
-
/** @inline */
|
|
234
|
-
type GlobalsFunction = (name: string) => string;
|
|
235
|
-
/** @inline */
|
|
236
|
-
type AdvancedChunksNameFunction = (moduleId: string, ctx: ChunkingContext) => string | NullValue;
|
|
237
|
-
/** @inline */
|
|
238
|
-
type AdvancedChunksTestFunction = (id: string) => boolean | undefined | void;
|
|
239
|
-
type MinifyOptions = Omit<MinifyOptions$1, "module" | "sourcemap">;
|
|
240
|
-
interface ChunkingContext {
|
|
241
|
-
getModuleInfo(moduleId: string): ModuleInfo | null;
|
|
242
|
-
}
|
|
243
|
-
interface OutputOptions {
|
|
244
|
-
/**
|
|
245
|
-
* The directory in which all generated chunks are placed.
|
|
246
|
-
*
|
|
247
|
-
* The {@linkcode file | output.file} option should be used instead if only a single chunk is generated.
|
|
248
|
-
*
|
|
249
|
-
* @default 'dist'
|
|
250
|
-
*/
|
|
251
|
-
dir?: string;
|
|
252
|
-
/**
|
|
253
|
-
* The file path for the single generated chunk.
|
|
254
|
-
*
|
|
255
|
-
* The {@linkcode dir | output.dir} option should be used instead if multiple chunks are generated.
|
|
256
|
-
*/
|
|
257
|
-
file?: string;
|
|
258
|
-
/**
|
|
259
|
-
* Which exports mode to use.
|
|
260
|
-
*
|
|
261
|
-
* {@include ./docs/output-exports.md}
|
|
262
|
-
*
|
|
263
|
-
* @default 'auto'
|
|
264
|
-
*/
|
|
265
|
-
exports?: "auto" | "named" | "default" | "none";
|
|
266
|
-
/**
|
|
267
|
-
* Specify the character set that Rolldown is allowed to use in file hashes.
|
|
268
|
-
*
|
|
269
|
-
* - `'base64'`: Uses url-safe base64 characters (0-9, a-z, A-Z, -, _). This will produce the shortest hashes.
|
|
270
|
-
* - `'base36'`: Uses alphanumeric characters (0-9, a-z)
|
|
271
|
-
* - `'hex'`: Uses hexadecimal characters (0-9, a-f)
|
|
272
|
-
*
|
|
273
|
-
* @default 'base64'
|
|
274
|
-
*/
|
|
275
|
-
hashCharacters?: "base64" | "base36" | "hex";
|
|
276
|
-
/**
|
|
277
|
-
* Expected format of generated code.
|
|
278
|
-
*
|
|
279
|
-
* - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
|
|
280
|
-
* - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
|
|
281
|
-
* - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
|
|
282
|
-
* - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
|
|
283
|
-
*
|
|
284
|
-
* @default 'esm'
|
|
285
|
-
*/
|
|
286
|
-
format?: ModuleFormat;
|
|
287
|
-
/**
|
|
288
|
-
* Whether to generate sourcemaps.
|
|
289
|
-
*
|
|
290
|
-
* - `false`: No sourcemap will be generated.
|
|
291
|
-
* - `true`: A separate sourcemap file will be generated.
|
|
292
|
-
* - `'inline'`: The sourcemap will be appended to the output file as a data URL.
|
|
293
|
-
* - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (`//# sourceMappingURL` comment) will not be included in the output file.
|
|
294
|
-
*
|
|
295
|
-
* @default false
|
|
296
|
-
*/
|
|
297
|
-
sourcemap?: boolean | "inline" | "hidden";
|
|
298
|
-
/**
|
|
299
|
-
* The base URL for the links to the sourcemap file in the output file.
|
|
300
|
-
*
|
|
301
|
-
* By default, relative URLs are generated. If this option is set, an absolute URL with that base URL will be generated. This is useful when deploying source maps to a different location than your code, such as a CDN or separate debugging server.
|
|
302
|
-
*/
|
|
303
|
-
sourcemapBaseUrl?: string;
|
|
304
|
-
/**
|
|
305
|
-
* Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
|
|
306
|
-
*
|
|
307
|
-
* When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
|
|
308
|
-
*
|
|
309
|
-
* @default false
|
|
310
|
-
*/
|
|
311
|
-
sourcemapDebugIds?: boolean;
|
|
312
|
-
/**
|
|
313
|
-
* Control which source files are included in the sourcemap ignore list.
|
|
314
|
-
*
|
|
315
|
-
* Files in the ignore list are excluded from debugger stepping and error stack traces.
|
|
316
|
-
*
|
|
317
|
-
* - `false`: Include no source files in the ignore list
|
|
318
|
-
* - `true`: Include all source files in the ignore list
|
|
319
|
-
* - `string`: Files containing this string in their path will be included in the ignore list
|
|
320
|
-
* - `RegExp`: Files matching this regular expression will be included in the ignore list
|
|
321
|
-
* - `function`: Custom function to determine if a source should be ignored
|
|
322
|
-
*
|
|
323
|
-
* :::tip Performance
|
|
324
|
-
* Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
|
|
325
|
-
* Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
|
|
326
|
-
* :::
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* ```js
|
|
330
|
-
* // ✅ Preferred: Use RegExp for better performance
|
|
331
|
-
* sourcemapIgnoreList: /node_modules/
|
|
332
|
-
*
|
|
333
|
-
* // ✅ Preferred: Use string pattern for better performance
|
|
334
|
-
* sourcemapIgnoreList: "vendor"
|
|
335
|
-
*
|
|
336
|
-
* // ! Use sparingly: Function calls have high overhead
|
|
337
|
-
* sourcemapIgnoreList: (source, sourcemapPath) => {
|
|
338
|
-
* return source.includes('node_modules') || source.includes('.min.');
|
|
339
|
-
* }
|
|
340
|
-
* ```
|
|
341
|
-
*
|
|
342
|
-
* @default /node_modules/
|
|
343
|
-
*/
|
|
344
|
-
sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | StringOrRegExp;
|
|
345
|
-
/**
|
|
346
|
-
* A transformation to apply to each path in a sourcemap.
|
|
347
|
-
*
|
|
348
|
-
* @example
|
|
349
|
-
* ```js
|
|
350
|
-
* export default defineConfig({
|
|
351
|
-
* output: {
|
|
352
|
-
* sourcemap: true,
|
|
353
|
-
* sourcemapPathTransform: (source, sourcemapPath) => {
|
|
354
|
-
* // Remove 'src/' prefix from all source paths
|
|
355
|
-
* return source.replace(/^src\//, '');
|
|
356
|
-
* },
|
|
357
|
-
* },
|
|
358
|
-
* });
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
sourcemapPathTransform?: SourcemapPathTransformOption;
|
|
362
|
-
/**
|
|
363
|
-
* A string to prepend to the bundle before `renderChunk` hook.
|
|
364
|
-
*
|
|
365
|
-
* See {@linkcode intro | output.intro}, {@linkcode postBanner | output.postBanner} as well.
|
|
366
|
-
*
|
|
367
|
-
* {@include ./docs/output-banner.md}
|
|
368
|
-
*/
|
|
369
|
-
banner?: string | AddonFunction;
|
|
370
|
-
/**
|
|
371
|
-
* A string to append to the bundle before `renderChunk` hook.
|
|
372
|
-
*
|
|
373
|
-
* See {@linkcode outro | output.outro}, {@linkcode postFooter | output.postFooter} as well.
|
|
374
|
-
*
|
|
375
|
-
* {@include ./docs/output-footer.md}
|
|
376
|
-
*/
|
|
377
|
-
footer?: string | AddonFunction;
|
|
378
|
-
/**
|
|
379
|
-
* A string to prepend to the bundle after `renderChunk` hook and minification.
|
|
380
|
-
*
|
|
381
|
-
* See {@linkcode banner | output.banner}, {@linkcode intro | output.intro} as well.
|
|
382
|
-
*/
|
|
383
|
-
postBanner?: string | AddonFunction;
|
|
384
|
-
/**
|
|
385
|
-
* A string to append to the bundle after `renderChunk` hook and minification.
|
|
386
|
-
*
|
|
387
|
-
* See {@linkcode footer | output.footer}, {@linkcode outro | output.outro} as well.
|
|
388
|
-
*/
|
|
389
|
-
postFooter?: string | AddonFunction;
|
|
390
|
-
/**
|
|
391
|
-
* A string to prepend inside any format-specific wrapper.
|
|
392
|
-
*
|
|
393
|
-
* See {@linkcode banner | output.banner}, {@linkcode postBanner | output.postBanner} as well.
|
|
394
|
-
*/
|
|
395
|
-
intro?: string | AddonFunction;
|
|
396
|
-
/**
|
|
397
|
-
* A string to append inside any format-specific wrapper.
|
|
398
|
-
*
|
|
399
|
-
* See {@linkcode footer | output.footer}, {@linkcode postFooter | output.postFooter} as well.
|
|
400
|
-
*/
|
|
401
|
-
outro?: string | AddonFunction;
|
|
402
|
-
/**
|
|
403
|
-
* Whether to extend the global variable defined by the {@linkcode OutputOptions.name | name} option in `umd` or `iife` formats.
|
|
404
|
-
*
|
|
405
|
-
* When `true`, the global variable will be defined as `global.name = global.name || {}`.
|
|
406
|
-
* When `false`, the global defined by name will be overwritten like `global.name = {}`.
|
|
407
|
-
*
|
|
408
|
-
* @default false
|
|
409
|
-
*/
|
|
410
|
-
extend?: boolean;
|
|
411
|
-
/**
|
|
412
|
-
* Whether to add a `__esModule: true` property when generating exports for non-ES formats.
|
|
413
|
-
*
|
|
414
|
-
* This property signifies that the exported value is the namespace of an ES module and that the default export of this module corresponds to the `.default` property of the exported object.
|
|
415
|
-
*
|
|
416
|
-
* - `true`: Always add the property when using named exports mode, which is similar to what other tools do.
|
|
417
|
-
* - `"if-default-prop"`: Only add the property when using named exports mode and there also is a default export. The subtle difference is that if there is no default export, consumers of the CommonJS version of your library will get all named exports as default export instead of an error or `undefined`.
|
|
418
|
-
* - `false`: Never add the property even if the default export would become a property `.default`.
|
|
419
|
-
*
|
|
420
|
-
* @default 'if-default-prop'
|
|
421
|
-
*/
|
|
422
|
-
esModule?: boolean | "if-default-prop";
|
|
423
|
-
/**
|
|
424
|
-
* The pattern to use for naming custom emitted assets to include in the build output, or a function that is called per asset to return such a pattern.
|
|
425
|
-
*
|
|
426
|
-
* Patterns support the following placeholders:
|
|
427
|
-
* - `[extname]`: The file extension of the asset including a leading dot, e.g. `.css`.
|
|
428
|
-
* - `[ext]`: The file extension without a leading dot, e.g. css.
|
|
429
|
-
* - `[hash]`: A hash based on the content of the asset. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
|
|
430
|
-
* - `[name]`: The file name of the asset excluding any extension.
|
|
431
|
-
*
|
|
432
|
-
* Forward slashes (`/`) can be used to place files in sub-directories.
|
|
433
|
-
*
|
|
434
|
-
* See also {@linkcode chunkFileNames | output.chunkFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
|
|
435
|
-
*
|
|
436
|
-
* @default 'assets/[name]-[hash][extname]'
|
|
437
|
-
*/
|
|
438
|
-
assetFileNames?: string | AssetFileNamesFunction;
|
|
439
|
-
/**
|
|
440
|
-
* The pattern to use for chunks created from entry points, or a function that is called per entry chunk to return such a pattern.
|
|
441
|
-
*
|
|
442
|
-
* Patterns support the following placeholders:
|
|
443
|
-
* - `[format]`: The rendering format defined in the output options, e.g. `es` or `cjs`.
|
|
444
|
-
* - `[hash]`: A hash based only on the content of the final generated chunk, including transformations in `renderChunk` and any referenced file hashes. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
|
|
445
|
-
* - `[name]`: The file name (without extension) of the entry point, unless the object form of input was used to define a different name.
|
|
446
|
-
*
|
|
447
|
-
* Forward slashes (`/`) can be used to place files in sub-directories. This pattern will also be used for every file when setting the {@linkcode preserveModules | output.preserveModules} option.
|
|
448
|
-
*
|
|
449
|
-
* See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode chunkFileNames | output.chunkFileNames}.
|
|
450
|
-
*
|
|
451
|
-
* @default '[name].js'
|
|
452
|
-
*/
|
|
453
|
-
entryFileNames?: string | ChunkFileNamesFunction;
|
|
454
|
-
/**
|
|
455
|
-
* The pattern to use for naming shared chunks created when code-splitting, or a function that is called per chunk to return such a pattern.
|
|
456
|
-
*
|
|
457
|
-
* Patterns support the following placeholders:
|
|
458
|
-
* - `[format]`: The rendering format defined in the output options, e.g. `es` or `cjs`.
|
|
459
|
-
* - `[hash]`: A hash based only on the content of the final generated chunk, including transformations in `renderChunk` and any referenced file hashes. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
|
|
460
|
-
* - `[name]`: The name of the chunk. This can be explicitly set via the {@linkcode codeSplitting | output.codeSplitting} option or when the chunk is created by a plugin via `this.emitFile`. Otherwise, it will be derived from the chunk contents.
|
|
461
|
-
*
|
|
462
|
-
* Forward slashes (`/`) can be used to place files in sub-directories.
|
|
463
|
-
*
|
|
464
|
-
* See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
|
|
465
|
-
*
|
|
466
|
-
* @default '[name]-[hash].js'
|
|
467
|
-
*/
|
|
468
|
-
chunkFileNames?: string | ChunkFileNamesFunction;
|
|
469
|
-
/**
|
|
470
|
-
* @default '[name].css'
|
|
471
|
-
* @experimental
|
|
472
|
-
* @hidden not ready for public usage yet
|
|
473
|
-
*/
|
|
474
|
-
cssEntryFileNames?: string | ChunkFileNamesFunction;
|
|
475
|
-
/**
|
|
476
|
-
* @default '[name]-[hash].css'
|
|
477
|
-
* @experimental
|
|
478
|
-
* @hidden not ready for public usage yet
|
|
479
|
-
*/
|
|
480
|
-
cssChunkFileNames?: string | ChunkFileNamesFunction;
|
|
481
|
-
/**
|
|
482
|
-
* Whether to enable chunk name sanitization (removal of non-URL-safe characters like `\0`, `?` and `*`).
|
|
483
|
-
*
|
|
484
|
-
* Set `false` to disable the sanitization. You can also provide a custom sanitization function.
|
|
485
|
-
*
|
|
486
|
-
* @default true
|
|
487
|
-
*/
|
|
488
|
-
sanitizeFileName?: boolean | SanitizeFileNameFunction;
|
|
489
|
-
/**
|
|
490
|
-
* Control code minification.
|
|
491
|
-
*
|
|
492
|
-
* - `true`: Enable full minification including code compression and dead code elimination
|
|
493
|
-
* - `false`: Disable minification (default)
|
|
494
|
-
* - `'dce-only'`: Only perform dead code elimination without code compression
|
|
495
|
-
* - `MinifyOptions`: Fine-grained control over minification settings
|
|
496
|
-
*
|
|
497
|
-
* @default false
|
|
498
|
-
*/
|
|
499
|
-
minify?: boolean | "dce-only" | MinifyOptions;
|
|
500
|
-
/**
|
|
501
|
-
* Specifies the global variable name that contains the exports of `umd` / `iife` bundles.
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* ```js
|
|
505
|
-
* export default defineConfig({
|
|
506
|
-
* output: {
|
|
507
|
-
* format: 'iife',
|
|
508
|
-
* name: 'MyBundle',
|
|
509
|
-
* }
|
|
510
|
-
* });
|
|
511
|
-
* ```
|
|
512
|
-
* ```js
|
|
513
|
-
* // output
|
|
514
|
-
* var MyBundle = (function () {
|
|
515
|
-
* // ...
|
|
516
|
-
* })();
|
|
517
|
-
* ```
|
|
518
|
-
*
|
|
519
|
-
* {@include ./docs/output-name.md}
|
|
520
|
-
*/
|
|
521
|
-
name?: string;
|
|
522
|
-
/**
|
|
523
|
-
* Specifies `id: variableName` pairs necessary for external imports in `umd` / `iife` bundles.
|
|
524
|
-
*
|
|
525
|
-
* @example
|
|
526
|
-
* ```js
|
|
527
|
-
* export default defineConfig({
|
|
528
|
-
* external: ['jquery'],
|
|
529
|
-
* output: {
|
|
530
|
-
* format: 'iife',
|
|
531
|
-
* name: 'MyBundle',
|
|
532
|
-
* globals: {
|
|
533
|
-
* jquery: '$',
|
|
534
|
-
* }
|
|
535
|
-
* }
|
|
536
|
-
* });
|
|
537
|
-
* ```
|
|
538
|
-
* ```js
|
|
539
|
-
* // input
|
|
540
|
-
* import $ from 'jquery';
|
|
541
|
-
* ```
|
|
542
|
-
* ```js
|
|
543
|
-
* // output
|
|
544
|
-
* var MyBundle = (function ($) {
|
|
545
|
-
* // ...
|
|
546
|
-
* })($);
|
|
547
|
-
* ```
|
|
548
|
-
*/
|
|
549
|
-
globals?: Record<string, string> | GlobalsFunction;
|
|
550
|
-
/**
|
|
551
|
-
* Maps external module IDs to paths.
|
|
552
|
-
*
|
|
553
|
-
* Allows customizing the path used when importing external dependencies.
|
|
554
|
-
* This is particularly useful for loading dependencies from CDNs or custom locations.
|
|
555
|
-
*
|
|
556
|
-
* - Object form: Maps module IDs to their replacement paths
|
|
557
|
-
* - Function form: Takes a module ID and returns its replacement path
|
|
558
|
-
*
|
|
559
|
-
* @example
|
|
560
|
-
* ```js
|
|
561
|
-
* {
|
|
562
|
-
* paths: {
|
|
563
|
-
* 'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
|
|
564
|
-
* }
|
|
565
|
-
* }
|
|
566
|
-
* ```
|
|
567
|
-
*
|
|
568
|
-
* @example
|
|
569
|
-
* ```js
|
|
570
|
-
* {
|
|
571
|
-
* paths: (id) => {
|
|
572
|
-
* if (id.startsWith('lodash')) {
|
|
573
|
-
* return `https://cdn.jsdelivr.net/npm/${id}`
|
|
574
|
-
* }
|
|
575
|
-
* return id
|
|
576
|
-
* }
|
|
577
|
-
* }
|
|
578
|
-
* ```
|
|
579
|
-
*/
|
|
580
|
-
paths?: Record<string, string> | PathsFunction$1;
|
|
581
|
-
/**
|
|
582
|
-
* Which language features Rolldown can safely use in generated code.
|
|
583
|
-
*
|
|
584
|
-
* This will not transpile any user code but only change the code Rolldown uses in wrappers and helpers.
|
|
585
|
-
*/
|
|
586
|
-
generatedCode?: Partial<GeneratedCodeOptions>;
|
|
587
|
-
/**
|
|
588
|
-
* Whether to generate code to support live bindings for external imports.
|
|
589
|
-
*
|
|
590
|
-
* With the default value of `true`, Rolldown will generate code to support live bindings for external imports.
|
|
591
|
-
*
|
|
592
|
-
* When set to `false`, Rolldown will assume that exports from external modules do not change. This will allow Rolldown to generate smaller code. Note that this can cause issues when there are circular dependencies involving an external dependency.
|
|
593
|
-
*
|
|
594
|
-
* @default true
|
|
595
|
-
*
|
|
596
|
-
* {@include ./docs/output-external-live-bindings.md}
|
|
597
|
-
*/
|
|
598
|
-
externalLiveBindings?: boolean;
|
|
599
|
-
/**
|
|
600
|
-
* Whether to inline dynamic imports instead of creating new chunks to create a single bundle.
|
|
601
|
-
*
|
|
602
|
-
* This option can be used only when a single input is provided.
|
|
603
|
-
*
|
|
604
|
-
* @default false
|
|
605
|
-
*/
|
|
606
|
-
inlineDynamicImports?: boolean;
|
|
607
|
-
/**
|
|
608
|
-
* Whether to keep external dynamic imports as `import(...)` expressions in CommonJS output.
|
|
609
|
-
*
|
|
610
|
-
* If set to `false`, external dynamic imports will be rewritten to use `require(...)` calls.
|
|
611
|
-
* This may be necessary to support environments that do not support dynamic `import()` in CommonJS modules like old Node.js versions.
|
|
612
|
-
*
|
|
613
|
-
* @default true
|
|
614
|
-
*/
|
|
615
|
-
dynamicImportInCjs?: boolean;
|
|
616
|
-
/**
|
|
617
|
-
* Allows you to do manual chunking. Provided for Rollup compatibility.
|
|
618
|
-
*
|
|
619
|
-
* You could use this option for migration purpose. Under the hood,
|
|
620
|
-
*
|
|
621
|
-
* ```js
|
|
622
|
-
* {
|
|
623
|
-
* manualChunks: (moduleId, meta) => {
|
|
624
|
-
* if (moduleId.includes('node_modules')) {
|
|
625
|
-
* return 'vendor';
|
|
626
|
-
* }
|
|
627
|
-
* return null;
|
|
628
|
-
* }
|
|
629
|
-
* }
|
|
630
|
-
* ```
|
|
631
|
-
*
|
|
632
|
-
* will be transformed to
|
|
633
|
-
*
|
|
634
|
-
* ```js
|
|
635
|
-
* {
|
|
636
|
-
* codeSplitting: {
|
|
637
|
-
* groups: [
|
|
638
|
-
* {
|
|
639
|
-
* name(moduleId) {
|
|
640
|
-
* if (moduleId.includes('node_modules')) {
|
|
641
|
-
* return 'vendor';
|
|
642
|
-
* }
|
|
643
|
-
* return null;
|
|
644
|
-
* },
|
|
645
|
-
* },
|
|
646
|
-
* ],
|
|
647
|
-
* }
|
|
648
|
-
* }
|
|
649
|
-
*
|
|
650
|
-
* ```
|
|
651
|
-
*
|
|
652
|
-
* Note that unlike Rollup, object form is not supported.
|
|
653
|
-
*
|
|
654
|
-
* @deprecated
|
|
655
|
-
* Please use {@linkcode codeSplitting | output.codeSplitting} instead.
|
|
656
|
-
*
|
|
657
|
-
* :::warning
|
|
658
|
-
* If `manualChunks` and `codeSplitting` are both specified, `manualChunks` option will be ignored.
|
|
659
|
-
* :::
|
|
660
|
-
*/
|
|
661
|
-
manualChunks?: ManualChunksFunction;
|
|
662
|
-
/**
|
|
663
|
-
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/advanced-chunks).
|
|
664
|
-
*
|
|
665
|
-
* @example
|
|
666
|
-
* **Basic vendor chunk**
|
|
667
|
-
* ```js
|
|
668
|
-
* export default defineConfig({
|
|
669
|
-
* output: {
|
|
670
|
-
* codeSplitting: {
|
|
671
|
-
* minSize: 20000,
|
|
672
|
-
* groups: [
|
|
673
|
-
* {
|
|
674
|
-
* name: 'vendor',
|
|
675
|
-
* test: /node_modules/,
|
|
676
|
-
* },
|
|
677
|
-
* ],
|
|
678
|
-
* },
|
|
679
|
-
* },
|
|
680
|
-
* });
|
|
681
|
-
* ```
|
|
682
|
-
* {@include ./docs/output-advanced-chunks.md}
|
|
683
|
-
*/
|
|
684
|
-
codeSplitting?: {
|
|
685
|
-
/**
|
|
686
|
-
* By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
|
|
687
|
-
*
|
|
688
|
-
* If you want to disable this behavior, it's recommended to both set
|
|
689
|
-
* - {@linkcode InputOptions.preserveEntrySignatures | preserveEntrySignatures}: `false | 'allow-extension'`
|
|
690
|
-
* - `experimental.strictExecutionOrder`: `true`
|
|
691
|
-
*
|
|
692
|
-
* to avoid generating invalid chunks.
|
|
693
|
-
*
|
|
694
|
-
* @default true
|
|
695
|
-
*/
|
|
696
|
-
includeDependenciesRecursively?: boolean;
|
|
697
|
-
/**
|
|
698
|
-
* Global fallback of {@linkcode CodeSplittingGroup.minSize | group.minSize}, if it's not specified in the group.
|
|
699
|
-
*/
|
|
700
|
-
minSize?: number;
|
|
701
|
-
/**
|
|
702
|
-
* Global fallback of {@linkcode CodeSplittingGroup.maxSize | group.maxSize}, if it's not specified in the group.
|
|
703
|
-
*/
|
|
704
|
-
maxSize?: number;
|
|
705
|
-
/**
|
|
706
|
-
* Global fallback of {@linkcode CodeSplittingGroup.maxModuleSize | group.maxModuleSize}, if it's not specified in the group.
|
|
707
|
-
*/
|
|
708
|
-
maxModuleSize?: number;
|
|
709
|
-
/**
|
|
710
|
-
* Global fallback of {@linkcode CodeSplittingGroup.minModuleSize | group.minModuleSize}, if it's not specified in the group.
|
|
711
|
-
*/
|
|
712
|
-
minModuleSize?: number;
|
|
713
|
-
/**
|
|
714
|
-
* Global fallback of {@linkcode CodeSplittingGroup.minShareCount | group.minShareCount}, if it's not specified in the group.
|
|
715
|
-
*/
|
|
716
|
-
minShareCount?: number;
|
|
717
|
-
/**
|
|
718
|
-
* Groups to be used for code splitting.
|
|
719
|
-
*/
|
|
720
|
-
groups?: CodeSplittingGroup[];
|
|
721
|
-
};
|
|
722
|
-
/**
|
|
723
|
-
* @deprecated Please use {@linkcode codeSplitting | output.codeSplitting} instead.
|
|
724
|
-
*
|
|
725
|
-
* Allows you to do manual chunking.
|
|
726
|
-
*
|
|
727
|
-
* :::warning
|
|
728
|
-
* If `advancedChunks` and `codeSplitting` are both specified, `advancedChunks` option will be ignored.
|
|
729
|
-
* :::
|
|
730
|
-
*/
|
|
731
|
-
advancedChunks?: {
|
|
732
|
-
includeDependenciesRecursively?: boolean;
|
|
733
|
-
minSize?: number;
|
|
734
|
-
maxSize?: number;
|
|
735
|
-
maxModuleSize?: number;
|
|
736
|
-
minModuleSize?: number;
|
|
737
|
-
minShareCount?: number;
|
|
738
|
-
groups?: CodeSplittingGroup[];
|
|
739
|
-
};
|
|
740
|
-
/**
|
|
741
|
-
* Control comments in the output.
|
|
742
|
-
*
|
|
743
|
-
* - `none`: no comments
|
|
744
|
-
* - `inline`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
|
|
745
|
-
*/
|
|
746
|
-
legalComments?: "none" | "inline";
|
|
747
|
-
/**
|
|
748
|
-
* The list of plugins to use only for this output.
|
|
749
|
-
*/
|
|
750
|
-
plugins?: RolldownOutputPluginOption;
|
|
751
|
-
/**
|
|
752
|
-
* Whether to add a polyfill for `require()` function in non-CommonJS formats.
|
|
753
|
-
*
|
|
754
|
-
* This option is useful when you want to inject your own `require` implementation.
|
|
755
|
-
*
|
|
756
|
-
* @default true
|
|
757
|
-
*/
|
|
758
|
-
polyfillRequire?: boolean;
|
|
759
|
-
/**
|
|
760
|
-
* This option is not implemented yet.
|
|
761
|
-
* @hidden
|
|
762
|
-
*/
|
|
763
|
-
hoistTransitiveImports?: false;
|
|
764
|
-
/**
|
|
765
|
-
* Whether to use preserve modules mode.
|
|
766
|
-
*
|
|
767
|
-
* {@include ./docs/output-preserve-modules.md}
|
|
768
|
-
*
|
|
769
|
-
* @default false
|
|
770
|
-
*/
|
|
771
|
-
preserveModules?: boolean;
|
|
772
|
-
/**
|
|
773
|
-
* Specifies the directory name for "virtual" files that might be emitted by plugins when using preserve modules mode.
|
|
774
|
-
*
|
|
775
|
-
* @default '_virtual'
|
|
776
|
-
*/
|
|
777
|
-
virtualDirname?: string;
|
|
778
|
-
/**
|
|
779
|
-
* A directory path to input modules that should be stripped away from {@linkcode dir | output.dir} when using preserve modules mode.
|
|
780
|
-
*
|
|
781
|
-
* {@include ./docs/output-preserve-modules-root.md}
|
|
782
|
-
*/
|
|
783
|
-
preserveModulesRoot?: string;
|
|
784
|
-
/**
|
|
785
|
-
* Whether to use `var` declarations at the top level scope instead of function / class / let / const expressions.
|
|
786
|
-
*
|
|
787
|
-
* Enabling this option can improve runtime performance of the generated code in certain environments.
|
|
788
|
-
*
|
|
789
|
-
* @default false
|
|
790
|
-
*
|
|
791
|
-
* {@include ./docs/output-top-level-var.md}
|
|
792
|
-
*/
|
|
793
|
-
topLevelVar?: boolean;
|
|
794
|
-
/**
|
|
795
|
-
* Whether to minify internal exports as single letter variables to allow for better minification.
|
|
796
|
-
*
|
|
797
|
-
* @default
|
|
798
|
-
* `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
|
|
799
|
-
*
|
|
800
|
-
* {@include ./docs/output-minify-internal-exports.md}
|
|
801
|
-
*/
|
|
802
|
-
minifyInternalExports?: boolean;
|
|
803
|
-
/**
|
|
804
|
-
* Clean output directory ({@linkcode dir | output.dir}) before emitting output.
|
|
805
|
-
*
|
|
806
|
-
* @default false
|
|
807
|
-
*
|
|
808
|
-
* {@include ./docs/output-clean-dir.md}
|
|
809
|
-
*/
|
|
810
|
-
cleanDir?: boolean;
|
|
811
|
-
/**
|
|
812
|
-
* Keep `name` property of functions and classes after bundling.
|
|
813
|
-
*
|
|
814
|
-
* When enabled, the bundler will preserve the original `name` property value of functions and
|
|
815
|
-
* classes in the output. This is useful for debugging and some frameworks that rely on it for
|
|
816
|
-
* registration and binding purposes.
|
|
817
|
-
*
|
|
818
|
-
* @default false
|
|
819
|
-
*/
|
|
820
|
-
keepNames?: boolean;
|
|
821
|
-
/**
|
|
822
|
-
* Reserved global identifiers to be avoided when generating export binding names for module chunks.
|
|
823
|
-
*
|
|
824
|
-
* @default []
|
|
825
|
-
*/
|
|
826
|
-
globalIdentifiers?: string[];
|
|
827
|
-
}
|
|
828
|
-
type CodeSplittingGroup = {
|
|
829
|
-
/**
|
|
830
|
-
* Name of the group. It will be also used as the name of the chunk and replace the `[name]` placeholder in the {@linkcode OutputOptions.chunkFileNames | output.chunkFileNames} option.
|
|
831
|
-
*
|
|
832
|
-
* For example,
|
|
833
|
-
*
|
|
834
|
-
* ```js
|
|
835
|
-
* import { defineConfig } from '@rollipop/rolldown';
|
|
836
|
-
*
|
|
837
|
-
* export default defineConfig({
|
|
838
|
-
* advancedChunks: {
|
|
839
|
-
* groups: [
|
|
840
|
-
* {
|
|
841
|
-
* name: 'libs',
|
|
842
|
-
* test: /node_modules/,
|
|
843
|
-
* },
|
|
844
|
-
* ],
|
|
845
|
-
* },
|
|
846
|
-
* });
|
|
847
|
-
* ```
|
|
848
|
-
* will create a chunk named `libs-[hash].js` in the end.
|
|
849
|
-
*
|
|
850
|
-
* It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
|
|
851
|
-
*
|
|
852
|
-
* #### Dynamic `name()`
|
|
853
|
-
*
|
|
854
|
-
* If `name` is a function, it will be called with the module id as the argument. The function should return a string or `null`. If it returns `null`, the module will be ignored by this group.
|
|
855
|
-
*
|
|
856
|
-
* Notice, each returned new name will be treated as a separate group.
|
|
857
|
-
*
|
|
858
|
-
* For example,
|
|
859
|
-
*
|
|
860
|
-
* ```js
|
|
861
|
-
* import { defineConfig } from '@rollipop/rolldown';
|
|
862
|
-
*
|
|
863
|
-
* export default defineConfig({
|
|
864
|
-
* advancedChunks: {
|
|
865
|
-
* groups: [
|
|
866
|
-
* {
|
|
867
|
-
* name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
|
|
868
|
-
* minSize: 100 * 1024,
|
|
869
|
-
* },
|
|
870
|
-
* ],
|
|
871
|
-
* },
|
|
872
|
-
* });
|
|
873
|
-
* ```
|
|
874
|
-
*
|
|
875
|
-
* :::warning
|
|
876
|
-
* Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
|
|
877
|
-
* :::
|
|
878
|
-
*/
|
|
879
|
-
name: string | AdvancedChunksNameFunction;
|
|
880
|
-
/**
|
|
881
|
-
* Controls which modules are captured in this group.
|
|
882
|
-
*
|
|
883
|
-
* - If `test` is a string, the module whose id contains the string will be captured.
|
|
884
|
-
* - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
885
|
-
* - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
886
|
-
* - If `test` is empty, any module will be considered as matched.
|
|
887
|
-
*
|
|
888
|
-
* :::warning
|
|
889
|
-
* When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
|
|
890
|
-
* - ✅ Recommended: `/node_modules[\\/]react/`
|
|
891
|
-
* - ❌ Not recommended: `/node_modules/react/`
|
|
892
|
-
* :::
|
|
893
|
-
*/
|
|
894
|
-
test?: StringOrRegExp | AdvancedChunksTestFunction;
|
|
895
|
-
/**
|
|
896
|
-
* Priority of the group. Group with higher priority will be chosen first to match modules and create chunks. When converting the group to a chunk, modules of that group will be removed from other groups.
|
|
897
|
-
*
|
|
898
|
-
* If two groups have the same priority, the group whose index is smaller will be chosen.
|
|
899
|
-
*
|
|
900
|
-
* @example
|
|
901
|
-
* ```js
|
|
902
|
-
* import { defineConfig } from '@rollipop/rolldown';
|
|
903
|
-
*
|
|
904
|
-
* export default defineConfig({
|
|
905
|
-
* advancedChunks: {
|
|
906
|
-
* groups: [
|
|
907
|
-
* {
|
|
908
|
-
* name: 'react',
|
|
909
|
-
* test: /node_modules[\\/]react/,
|
|
910
|
-
* priority: 2,
|
|
911
|
-
* },
|
|
912
|
-
* {
|
|
913
|
-
* name: 'other-libs',
|
|
914
|
-
* test: /node_modules/,
|
|
915
|
-
* priority: 1,
|
|
916
|
-
* },
|
|
917
|
-
* ],
|
|
918
|
-
* });
|
|
919
|
-
* ```
|
|
920
|
-
*
|
|
921
|
-
* @default 0
|
|
922
|
-
*/
|
|
923
|
-
priority?: number;
|
|
924
|
-
/**
|
|
925
|
-
* Minimum size in bytes of the desired chunk. If the accumulated size of the captured modules by this group is smaller than this value, it will be ignored. Modules in this group will fall back to the `automatic chunking` if they are not captured by any other group.
|
|
926
|
-
*
|
|
927
|
-
* @default 0
|
|
928
|
-
*/
|
|
929
|
-
minSize?: number;
|
|
930
|
-
/**
|
|
931
|
-
* Controls if a module should be captured based on how many entry chunks reference it.
|
|
932
|
-
*
|
|
933
|
-
* @default 1
|
|
934
|
-
*/
|
|
935
|
-
minShareCount?: number;
|
|
936
|
-
/**
|
|
937
|
-
* If the accumulated size in bytes of the captured modules by this group is larger than this value, this group will be split into multiple groups that each has size close to this value.
|
|
938
|
-
*
|
|
939
|
-
* @default Infinity
|
|
940
|
-
*/
|
|
941
|
-
maxSize?: number;
|
|
942
|
-
/**
|
|
943
|
-
* Controls whether a module can only be captured if its size in bytes is smaller than or equal to this value.
|
|
944
|
-
*
|
|
945
|
-
* @default Infinity
|
|
946
|
-
*/
|
|
947
|
-
maxModuleSize?: number;
|
|
948
|
-
/**
|
|
949
|
-
* Controls whether a module can only be captured if its size in bytes is larger than or equal to this value.
|
|
950
|
-
*
|
|
951
|
-
* @default 0
|
|
952
|
-
*/
|
|
953
|
-
minModuleSize?: number;
|
|
954
|
-
};
|
|
955
|
-
/**
|
|
956
|
-
* Alias for {@linkcode CodeSplittingGroup}. Use this type for the `codeSplitting.groups` option.
|
|
957
|
-
*/
|
|
958
|
-
type AdvancedChunksGroup = CodeSplittingGroup;
|
|
959
|
-
//#endregion
|
|
960
|
-
//#region src/api/build.d.ts
|
|
961
|
-
interface BuildOptions extends InputOptions {
|
|
962
|
-
/**
|
|
963
|
-
* Write the output to the file system
|
|
964
|
-
*
|
|
965
|
-
* @default true
|
|
966
|
-
*/
|
|
967
|
-
write?: boolean;
|
|
968
|
-
output?: OutputOptions;
|
|
969
|
-
}
|
|
970
|
-
/** @category Programmatic APIs */
|
|
971
|
-
declare function build(options: BuildOptions): Promise<RolldownOutput>;
|
|
972
|
-
/**
|
|
973
|
-
* Build multiple outputs __sequentially__.
|
|
974
|
-
*/
|
|
975
|
-
declare function build(options: BuildOptions[]): Promise<RolldownOutput[]>;
|
|
976
|
-
//#endregion
|
|
977
|
-
//#region src/api/rolldown/rolldown-build.d.ts
|
|
978
|
-
/** @category Programmatic APIs */
|
|
979
|
-
declare class RolldownBuild {
|
|
980
|
-
#private;
|
|
981
|
-
static asyncRuntimeShutdown: boolean;
|
|
982
|
-
constructor(inputOptions: InputOptions);
|
|
983
|
-
get closed(): boolean;
|
|
984
|
-
generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
|
|
985
|
-
write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
|
|
986
|
-
/**
|
|
987
|
-
* Close the build and free resources.
|
|
988
|
-
*/
|
|
989
|
-
close(): Promise<void>;
|
|
990
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
991
|
-
get watchFiles(): Promise<string[]>;
|
|
992
|
-
}
|
|
993
|
-
//#endregion
|
|
994
|
-
//#region src/api/rolldown/index.d.ts
|
|
995
|
-
/** @category Programmatic APIs */
|
|
996
|
-
declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
|
|
997
|
-
//#endregion
|
|
998
|
-
//#region src/options/watch-options.d.ts
|
|
999
|
-
/** @category Programmatic APIs */
|
|
1000
|
-
interface WatchOptions extends InputOptions {
|
|
1001
|
-
output?: OutputOptions | OutputOptions[];
|
|
1002
|
-
}
|
|
1003
|
-
//#endregion
|
|
1004
|
-
//#region src/api/watch/watch-emitter.d.ts
|
|
1005
|
-
type WatcherEvent = "close" | "event" | "restart" | "change";
|
|
1006
|
-
type ChangeEvent$1 = "create" | "update" | "delete";
|
|
1007
|
-
type RolldownWatchBuild = BindingWatcherBundler;
|
|
1008
|
-
/** @category Programmatic APIs */
|
|
1009
|
-
type RolldownWatcherEvent = {
|
|
1010
|
-
code: "START";
|
|
1011
|
-
} | {
|
|
1012
|
-
code: "BUNDLE_START";
|
|
1013
|
-
} | {
|
|
1014
|
-
code: "BUNDLE_END";
|
|
1015
|
-
duration: number;
|
|
1016
|
-
output: readonly string[];
|
|
1017
|
-
result: RolldownWatchBuild;
|
|
1018
|
-
} | {
|
|
1019
|
-
code: "END";
|
|
1020
|
-
} | {
|
|
1021
|
-
code: "ERROR";
|
|
1022
|
-
error: Error;
|
|
1023
|
-
result: RolldownWatchBuild;
|
|
1024
|
-
};
|
|
1025
|
-
declare class WatcherEmitter {
|
|
1026
|
-
listeners: Map<WatcherEvent, Array<(...parameters: any[]) => MaybePromise<void>>>;
|
|
1027
|
-
timer: any;
|
|
1028
|
-
constructor();
|
|
1029
|
-
on(event: "change", listener: (id: string, change: {
|
|
1030
|
-
event: ChangeEvent$1;
|
|
1031
|
-
}) => MaybePromise<void>): this;
|
|
1032
|
-
on(event: "event", listener: (data: RolldownWatcherEvent) => MaybePromise<void>): this;
|
|
1033
|
-
on(event: "restart" | "close", listener: () => MaybePromise<void>): this;
|
|
1034
|
-
off(event: WatcherEvent, listener: (...parameters: any[]) => MaybePromise<void>): this;
|
|
1035
|
-
clear(event: WatcherEvent): void;
|
|
1036
|
-
onEvent(event: BindingWatcherEvent): Promise<void>;
|
|
1037
|
-
close(): Promise<void>;
|
|
1038
|
-
}
|
|
1039
|
-
/** @category Programmatic APIs */
|
|
1040
|
-
type RolldownWatcher = WatcherEmitter;
|
|
1041
|
-
//#endregion
|
|
1042
|
-
//#region src/api/watch/index.d.ts
|
|
1043
|
-
/** @category Programmatic APIs */
|
|
1044
|
-
declare const watch: (input: WatchOptions | WatchOptions[]) => RolldownWatcher;
|
|
1045
|
-
//#endregion
|
|
1046
|
-
//#region src/log/log-handler.d.ts
|
|
1047
|
-
type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
|
|
1048
|
-
type LoggingFunctionWithPosition = (log: RollupLog | string | (() => RollupLog | string), pos?: number | {
|
|
1049
|
-
column: number;
|
|
1050
|
-
line: number;
|
|
1051
|
-
}) => void;
|
|
1052
|
-
type WarningHandlerWithDefault = (warning: RollupLog, defaultHandler: LoggingFunction) => void;
|
|
1053
|
-
//#endregion
|
|
1054
|
-
//#region src/options/generated/checks-options.d.ts
|
|
1055
|
-
interface ChecksOptions {
|
|
1056
|
-
/**
|
|
1057
|
-
* Whether to emit warnings when detecting circular dependency
|
|
1058
|
-
*
|
|
1059
|
-
* Circular dependencies lead to a bigger bundle size and sometimes cause execution order issues and are better to avoid.
|
|
1060
|
-
* @default false
|
|
1061
|
-
* */
|
|
1062
|
-
circularDependency?: boolean;
|
|
1063
|
-
/**
|
|
1064
|
-
* Whether to emit warnings when detecting uses of direct `eval`s
|
|
1065
|
-
*
|
|
1066
|
-
* See [Avoiding Direct `eval` in Troubleshooting page](https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval) for more details.
|
|
1067
|
-
* @default true
|
|
1068
|
-
* */
|
|
1069
|
-
eval?: boolean;
|
|
1070
|
-
/**
|
|
1071
|
-
* Whether to emit warnings when the `output.globals` option is missing when needed
|
|
1072
|
-
*
|
|
1073
|
-
* See [`output.globals`](https://rolldown.rs/reference/OutputOptions.globals).
|
|
1074
|
-
* @default true
|
|
1075
|
-
* */
|
|
1076
|
-
missingGlobalName?: boolean;
|
|
1077
|
-
/**
|
|
1078
|
-
* Whether to emit warnings when the `output.name` option is missing when needed
|
|
1079
|
-
*
|
|
1080
|
-
* See [`output.name`](https://rolldown.rs/reference/OutputOptions.name).
|
|
1081
|
-
* @default true
|
|
1082
|
-
* */
|
|
1083
|
-
missingNameOptionForIifeExport?: boolean;
|
|
1084
|
-
/**
|
|
1085
|
-
* Whether to emit warnings when the way to export values is ambiguous
|
|
1086
|
-
*
|
|
1087
|
-
* See [`output.exports`](https://rolldown.rs/reference/OutputOptions.exports).
|
|
1088
|
-
* @default true
|
|
1089
|
-
* */
|
|
1090
|
-
mixedExports?: boolean;
|
|
1091
|
-
/**
|
|
1092
|
-
* Whether to emit warnings when an entrypoint cannot be resolved
|
|
1093
|
-
* @default true
|
|
1094
|
-
* */
|
|
1095
|
-
unresolvedEntry?: boolean;
|
|
1096
|
-
/**
|
|
1097
|
-
* Whether to emit warnings when an import cannot be resolved
|
|
1098
|
-
* @default true
|
|
1099
|
-
* */
|
|
1100
|
-
unresolvedImport?: boolean;
|
|
1101
|
-
/**
|
|
1102
|
-
* Whether to emit warnings when files generated have the same name with different contents
|
|
1103
|
-
* @default true
|
|
1104
|
-
* */
|
|
1105
|
-
filenameConflict?: boolean;
|
|
1106
|
-
/**
|
|
1107
|
-
* Whether to emit warnings when a CommonJS variable is used in an ES module
|
|
1108
|
-
*
|
|
1109
|
-
* CommonJS variables like `module` and `exports` are treated as global variables in ES modules and may not work as expected.
|
|
1110
|
-
* @default true
|
|
1111
|
-
* */
|
|
1112
|
-
commonJsVariableInEsm?: boolean;
|
|
1113
|
-
/**
|
|
1114
|
-
* Whether to emit warnings when an imported variable is not exported
|
|
1115
|
-
*
|
|
1116
|
-
* If the code is importing a variable that is not exported by the imported module, the value will always be `undefined`. This might be a mistake in the code.
|
|
1117
|
-
* @default true
|
|
1118
|
-
* */
|
|
1119
|
-
importIsUndefined?: boolean;
|
|
1120
|
-
/**
|
|
1121
|
-
* Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`)
|
|
1122
|
-
*
|
|
1123
|
-
* See [`import.meta` in Non-ESM Output Formats page](https://rolldown.rs/in-depth/non-esm-output-formats#import-meta) for more details.
|
|
1124
|
-
* @default true
|
|
1125
|
-
* */
|
|
1126
|
-
emptyImportMeta?: boolean;
|
|
1127
|
-
/**
|
|
1128
|
-
* Whether to emit warnings when detecting tolerated transform
|
|
1129
|
-
* @default true
|
|
1130
|
-
* */
|
|
1131
|
-
toleratedTransform?: boolean;
|
|
1132
|
-
/**
|
|
1133
|
-
* Whether to emit warnings when a namespace is called as a function
|
|
1134
|
-
*
|
|
1135
|
-
* A module namespace object is an object and not a function. Calling it as a function will cause a runtime error.
|
|
1136
|
-
* @default true
|
|
1137
|
-
* */
|
|
1138
|
-
cannotCallNamespace?: boolean;
|
|
1139
|
-
/**
|
|
1140
|
-
* Whether to emit warnings when a config value is overridden by another config value with a higher priority
|
|
1141
|
-
* @default true
|
|
1142
|
-
* */
|
|
1143
|
-
configurationFieldConflict?: boolean;
|
|
1144
|
-
/**
|
|
1145
|
-
* Whether to emit warnings when a plugin that is covered by a built-in feature is used
|
|
1146
|
-
*
|
|
1147
|
-
* Using built-in features is generally more performant than using plugins.
|
|
1148
|
-
* @default true
|
|
1149
|
-
* */
|
|
1150
|
-
preferBuiltinFeature?: boolean;
|
|
1151
|
-
/**
|
|
1152
|
-
* Whether to emit warnings when Rolldown could not clean the output directory
|
|
1153
|
-
*
|
|
1154
|
-
* See [`output.cleanDir`](https://rolldown.rs/reference/OutputOptions.cleanDir).
|
|
1155
|
-
* @default true
|
|
1156
|
-
* */
|
|
1157
|
-
couldNotCleanDirectory?: boolean;
|
|
1158
|
-
/**
|
|
1159
|
-
* Whether to emit warnings when plugins take significant time during the build process
|
|
1160
|
-
*
|
|
1161
|
-
* {@include ../docs/checks-plugin-timings.md}
|
|
1162
|
-
* @default true
|
|
1163
|
-
* */
|
|
1164
|
-
pluginTimings?: boolean;
|
|
1165
|
-
}
|
|
1166
|
-
//#endregion
|
|
1167
|
-
//#region src/options/transform-options.d.ts
|
|
1168
|
-
interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
|
|
1169
|
-
/**
|
|
1170
|
-
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1171
|
-
*
|
|
1172
|
-
* @example
|
|
1173
|
-
* **Replace the global variable `IS_PROD` with `true`**
|
|
1174
|
-
* ```js rolldown.config.js
|
|
1175
|
-
* export default defineConfig({
|
|
1176
|
-
* transform: { define: { IS_PROD: 'true' } }
|
|
1177
|
-
* })
|
|
1178
|
-
* ```
|
|
1179
|
-
* Result:
|
|
1180
|
-
* ```js
|
|
1181
|
-
* // Input
|
|
1182
|
-
* if (IS_PROD) {
|
|
1183
|
-
* console.log('Production mode')
|
|
1184
|
-
* }
|
|
1185
|
-
*
|
|
1186
|
-
* // After bundling
|
|
1187
|
-
* if (true) {
|
|
1188
|
-
* console.log('Production mode')
|
|
1189
|
-
* }
|
|
1190
|
-
* ```
|
|
1191
|
-
*
|
|
1192
|
-
* **Replace the property accessor `process.env.NODE_ENV` with `'production'`**
|
|
1193
|
-
* ```js rolldown.config.js
|
|
1194
|
-
* export default defineConfig({
|
|
1195
|
-
* transform: { define: { 'process.env.NODE_ENV': "'production'" } }
|
|
1196
|
-
* })
|
|
1197
|
-
* ```
|
|
1198
|
-
* Result:
|
|
1199
|
-
* ```js
|
|
1200
|
-
* // Input
|
|
1201
|
-
* if (process.env.NODE_ENV === 'production') {
|
|
1202
|
-
* console.log('Production mode')
|
|
1203
|
-
* }
|
|
1204
|
-
*
|
|
1205
|
-
* // After bundling
|
|
1206
|
-
* if ('production' === 'production') {
|
|
1207
|
-
* console.log('Production mode')
|
|
1208
|
-
* }
|
|
1209
|
-
* ```
|
|
1210
|
-
*/
|
|
1211
|
-
define?: Record<string, string>;
|
|
1212
|
-
/**
|
|
1213
|
-
* Inject import statements on demand.
|
|
1214
|
-
*
|
|
1215
|
-
* The API is aligned with `@rollup/plugin-inject`.
|
|
1216
|
-
*
|
|
1217
|
-
* #### Supported patterns
|
|
1218
|
-
* ```js
|
|
1219
|
-
* {
|
|
1220
|
-
* // import { Promise } from 'es6-promise'
|
|
1221
|
-
* Promise: ['es6-promise', 'Promise'],
|
|
1222
|
-
*
|
|
1223
|
-
* // import { Promise as P } from 'es6-promise'
|
|
1224
|
-
* P: ['es6-promise', 'Promise'],
|
|
1225
|
-
*
|
|
1226
|
-
* // import $ from 'jquery'
|
|
1227
|
-
* $: 'jquery',
|
|
1228
|
-
*
|
|
1229
|
-
* // import * as fs from 'node:fs'
|
|
1230
|
-
* fs: ['node:fs', '*'],
|
|
1231
|
-
*
|
|
1232
|
-
* // Inject shims for property access pattern
|
|
1233
|
-
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1234
|
-
* }
|
|
1235
|
-
* ```
|
|
1236
|
-
*/
|
|
1237
|
-
inject?: Record<string, string | [string, string]>;
|
|
1238
|
-
/**
|
|
1239
|
-
* Remove labeled statements with these label names.
|
|
1240
|
-
*
|
|
1241
|
-
* Labeled statements are JavaScript statements prefixed with a label identifier.
|
|
1242
|
-
* This option allows you to strip specific labeled statements from the output,
|
|
1243
|
-
* which is useful for removing debug-only code in production builds.
|
|
1244
|
-
*
|
|
1245
|
-
* @example
|
|
1246
|
-
* ```js rolldown.config.js
|
|
1247
|
-
* export default defineConfig({
|
|
1248
|
-
* transform: { dropLabels: ['DEBUG', 'DEV'] }
|
|
1249
|
-
* })
|
|
1250
|
-
* ```
|
|
1251
|
-
* Result:
|
|
1252
|
-
* ```js
|
|
1253
|
-
* // Input
|
|
1254
|
-
* DEBUG: console.log('Debug info');
|
|
1255
|
-
* DEV: {
|
|
1256
|
-
* console.log('Development mode');
|
|
1257
|
-
* }
|
|
1258
|
-
* console.log('Production code');
|
|
1259
|
-
*
|
|
1260
|
-
* // After bundling
|
|
1261
|
-
* console.log('Production code');
|
|
1262
|
-
* ```
|
|
1263
|
-
*/
|
|
1264
|
-
dropLabels?: string[];
|
|
1265
|
-
/**
|
|
1266
|
-
* Controls how JSX syntax is transformed.
|
|
1267
|
-
*
|
|
1268
|
-
* - If set to `false`, an error will be thrown if JSX syntax is encountered.
|
|
1269
|
-
* - If set to `'react'`, JSX syntax will be transformed to classic runtime React code.
|
|
1270
|
-
* - If set to `'react-jsx'`, JSX syntax will be transformed to automatic runtime React code.
|
|
1271
|
-
* - If set to `'preserve'`, JSX syntax will be preserved as-is.
|
|
1272
|
-
*/
|
|
1273
|
-
jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
|
|
1274
|
-
}
|
|
1275
|
-
//#endregion
|
|
1276
|
-
//#region src/options/normalized-input-options.d.ts
|
|
1277
|
-
/** @category Plugin APIs */
|
|
1278
|
-
interface NormalizedInputOptions {
|
|
1279
|
-
input: string[] | Record<string, string>;
|
|
1280
|
-
cwd: string;
|
|
1281
|
-
platform: InputOptions["platform"];
|
|
1282
|
-
shimMissingExports: boolean;
|
|
1283
|
-
context: string;
|
|
1284
|
-
}
|
|
1285
|
-
//#endregion
|
|
1286
|
-
//#region src/options/normalized-output-options.d.ts
|
|
1287
|
-
type PathsFunction = (id: string) => string;
|
|
1288
|
-
/** @category Plugin APIs */
|
|
1289
|
-
type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
|
|
1290
|
-
/** @category Plugin APIs */
|
|
1291
|
-
interface NormalizedOutputOptions {
|
|
1292
|
-
name: string | undefined;
|
|
1293
|
-
file: string | undefined;
|
|
1294
|
-
dir: string | undefined;
|
|
1295
|
-
entryFileNames: string | ChunkFileNamesFunction;
|
|
1296
|
-
chunkFileNames: string | ChunkFileNamesFunction;
|
|
1297
|
-
assetFileNames: string | AssetFileNamesFunction;
|
|
1298
|
-
format: InternalModuleFormat;
|
|
1299
|
-
exports: NonNullable<OutputOptions["exports"]>;
|
|
1300
|
-
sourcemap: boolean | "inline" | "hidden";
|
|
1301
|
-
sourcemapBaseUrl: string | undefined;
|
|
1302
|
-
cssEntryFileNames: string | ChunkFileNamesFunction;
|
|
1303
|
-
cssChunkFileNames: string | ChunkFileNamesFunction;
|
|
1304
|
-
inlineDynamicImports: boolean;
|
|
1305
|
-
dynamicImportInCjs: boolean;
|
|
1306
|
-
externalLiveBindings: boolean;
|
|
1307
|
-
banner: AddonFunction;
|
|
1308
|
-
footer: AddonFunction;
|
|
1309
|
-
postBanner: AddonFunction;
|
|
1310
|
-
postFooter: AddonFunction;
|
|
1311
|
-
intro: AddonFunction;
|
|
1312
|
-
outro: AddonFunction;
|
|
1313
|
-
esModule: boolean | "if-default-prop";
|
|
1314
|
-
extend: boolean;
|
|
1315
|
-
globals: Record<string, string> | GlobalsFunction;
|
|
1316
|
-
paths: Record<string, string> | PathsFunction | undefined;
|
|
1317
|
-
hashCharacters: "base64" | "base36" | "hex";
|
|
1318
|
-
sourcemapDebugIds: boolean;
|
|
1319
|
-
sourcemapIgnoreList: boolean | SourcemapIgnoreListOption | StringOrRegExp | undefined;
|
|
1320
|
-
sourcemapPathTransform: SourcemapPathTransformOption | undefined;
|
|
1321
|
-
minify: false | MinifyOptions | "dce-only";
|
|
1322
|
-
legalComments: "none" | "inline";
|
|
1323
|
-
polyfillRequire: boolean;
|
|
1324
|
-
plugins: RolldownPlugin[];
|
|
1325
|
-
preserveModules: boolean;
|
|
1326
|
-
virtualDirname: string;
|
|
1327
|
-
preserveModulesRoot?: string;
|
|
1328
|
-
topLevelVar?: boolean;
|
|
1329
|
-
minifyInternalExports?: boolean;
|
|
1330
|
-
}
|
|
1331
|
-
//#endregion
|
|
1332
|
-
//#region src/plugin/fs.d.ts
|
|
1333
|
-
/** @category Plugin APIs */
|
|
1334
|
-
interface RolldownFsModule {
|
|
1335
|
-
appendFile(path: string, data: string | Uint8Array, options?: {
|
|
1336
|
-
encoding?: BufferEncoding | null;
|
|
1337
|
-
mode?: string | number;
|
|
1338
|
-
flag?: string | number;
|
|
1339
|
-
}): Promise<void>;
|
|
1340
|
-
copyFile(source: string, destination: string, mode?: string | number): Promise<void>;
|
|
1341
|
-
mkdir(path: string, options?: {
|
|
1342
|
-
recursive?: boolean;
|
|
1343
|
-
mode?: string | number;
|
|
1344
|
-
}): Promise<void>;
|
|
1345
|
-
mkdtemp(prefix: string): Promise<string>;
|
|
1346
|
-
readdir(path: string, options?: {
|
|
1347
|
-
withFileTypes?: false;
|
|
1348
|
-
}): Promise<string[]>;
|
|
1349
|
-
readdir(path: string, options?: {
|
|
1350
|
-
withFileTypes: true;
|
|
1351
|
-
}): Promise<RolldownDirectoryEntry[]>;
|
|
1352
|
-
readFile(path: string, options?: {
|
|
1353
|
-
encoding?: null;
|
|
1354
|
-
flag?: string | number;
|
|
1355
|
-
signal?: AbortSignal;
|
|
1356
|
-
}): Promise<Uint8Array>;
|
|
1357
|
-
readFile(path: string, options?: {
|
|
1358
|
-
encoding: BufferEncoding;
|
|
1359
|
-
flag?: string | number;
|
|
1360
|
-
signal?: AbortSignal;
|
|
1361
|
-
}): Promise<string>;
|
|
1362
|
-
realpath(path: string): Promise<string>;
|
|
1363
|
-
rename(oldPath: string, newPath: string): Promise<void>;
|
|
1364
|
-
rmdir(path: string, options?: {
|
|
1365
|
-
recursive?: boolean;
|
|
1366
|
-
}): Promise<void>;
|
|
1367
|
-
stat(path: string): Promise<RolldownFileStats>;
|
|
1368
|
-
lstat(path: string): Promise<RolldownFileStats>;
|
|
1369
|
-
unlink(path: string): Promise<void>;
|
|
1370
|
-
writeFile(path: string, data: string | Uint8Array, options?: {
|
|
1371
|
-
encoding?: BufferEncoding | null;
|
|
1372
|
-
mode?: string | number;
|
|
1373
|
-
flag?: string | number;
|
|
1374
|
-
}): Promise<void>;
|
|
1375
|
-
}
|
|
1376
|
-
/** @category Plugin APIs */
|
|
1377
|
-
type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
1378
|
-
/** @category Plugin APIs */
|
|
1379
|
-
interface RolldownDirectoryEntry {
|
|
1380
|
-
isFile(): boolean;
|
|
1381
|
-
isDirectory(): boolean;
|
|
1382
|
-
isSymbolicLink(): boolean;
|
|
1383
|
-
name: string;
|
|
1384
|
-
}
|
|
1385
|
-
/** @category Plugin APIs */
|
|
1386
|
-
interface RolldownFileStats {
|
|
1387
|
-
isFile(): boolean;
|
|
1388
|
-
isDirectory(): boolean;
|
|
1389
|
-
isSymbolicLink(): boolean;
|
|
1390
|
-
size: number;
|
|
1391
|
-
mtime: Date;
|
|
1392
|
-
ctime: Date;
|
|
1393
|
-
atime: Date;
|
|
1394
|
-
birthtime: Date;
|
|
1395
|
-
}
|
|
1396
|
-
//#endregion
|
|
1397
|
-
//#region src/plugin/hook-filter.d.ts
|
|
1398
|
-
/** @category Plugin APIs */
|
|
1399
|
-
type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
|
|
1400
|
-
include?: MaybeArray<Value>;
|
|
1401
|
-
exclude?: MaybeArray<Value>;
|
|
1402
|
-
};
|
|
1403
|
-
interface FormalModuleTypeFilter {
|
|
1404
|
-
include?: ModuleType[];
|
|
1405
|
-
}
|
|
1406
|
-
/** @category Plugin APIs */
|
|
1407
|
-
type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
|
|
1408
|
-
/** @category Plugin APIs */
|
|
1409
|
-
interface HookFilter {
|
|
1410
|
-
/**
|
|
1411
|
-
* This filter is used to do a pre-test to determine whether the hook should be called.
|
|
1412
|
-
*
|
|
1413
|
-
* @example
|
|
1414
|
-
* Include all `id`s that contain `node_modules` in the path.
|
|
1415
|
-
* ```js
|
|
1416
|
-
* { id: '**'+'/node_modules/**' }
|
|
1417
|
-
* ```
|
|
1418
|
-
* @example
|
|
1419
|
-
* Include all `id`s that contain `node_modules` or `src` in the path.
|
|
1420
|
-
* ```js
|
|
1421
|
-
* { id: ['**'+'/node_modules/**', '**'+'/src/**'] }
|
|
1422
|
-
* ```
|
|
1423
|
-
* @example
|
|
1424
|
-
* Include all `id`s that start with `http`
|
|
1425
|
-
* ```js
|
|
1426
|
-
* { id: /^http/ }
|
|
1427
|
-
* ```
|
|
1428
|
-
* @example
|
|
1429
|
-
* Exclude all `id`s that contain `node_modules` in the path.
|
|
1430
|
-
* ```js
|
|
1431
|
-
* { id: { exclude: '**'+'/node_modules/**' } }
|
|
1432
|
-
* ```
|
|
1433
|
-
* @example
|
|
1434
|
-
* Formal pattern to define includes and excludes.
|
|
1435
|
-
* ```
|
|
1436
|
-
* { id : {
|
|
1437
|
-
* include: ['**'+'/foo/**', /bar/],
|
|
1438
|
-
* exclude: ['**'+'/baz/**', /qux/]
|
|
1439
|
-
* }}
|
|
1440
|
-
* ```
|
|
1441
|
-
*/
|
|
1442
|
-
id?: GeneralHookFilter;
|
|
1443
|
-
moduleType?: ModuleTypeFilter;
|
|
1444
|
-
code?: GeneralHookFilter;
|
|
1445
|
-
}
|
|
1446
|
-
type TUnionWithTopLevelFilterExpressionArray<T> = T | TopLevelFilterExpression[];
|
|
1447
|
-
//#endregion
|
|
1448
|
-
//#region src/plugin/minimal-plugin-context.d.ts
|
|
1449
|
-
/** @category Plugin APIs */
|
|
1450
|
-
interface PluginContextMeta {
|
|
1451
|
-
rollupVersion: string;
|
|
1452
|
-
rolldownVersion: string;
|
|
1453
|
-
watchMode: boolean;
|
|
1454
|
-
}
|
|
1455
|
-
/** @category Plugin APIs */
|
|
1456
|
-
interface MinimalPluginContext {
|
|
1457
|
-
readonly pluginName: string;
|
|
1458
|
-
error: (e: RollupError | string) => never;
|
|
1459
|
-
info: LoggingFunction;
|
|
1460
|
-
warn: LoggingFunction;
|
|
1461
|
-
debug: LoggingFunction;
|
|
1462
|
-
meta: PluginContextMeta;
|
|
1463
|
-
}
|
|
1464
|
-
//#endregion
|
|
1465
|
-
//#region src/plugin/parallel-plugin.d.ts
|
|
1466
|
-
type ParallelPlugin = {
|
|
1467
|
-
_parallel: {
|
|
1468
|
-
fileUrl: string;
|
|
1469
|
-
options: unknown;
|
|
1470
|
-
};
|
|
1471
|
-
};
|
|
1472
|
-
/** @internal */
|
|
1473
|
-
type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
|
|
1474
|
-
declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
|
|
1475
|
-
//#endregion
|
|
1476
|
-
//#region src/plugin/plugin-context.d.ts
|
|
1477
|
-
/** @category Plugin APIs */
|
|
1478
|
-
interface EmittedAsset {
|
|
1479
|
-
type: "asset";
|
|
1480
|
-
name?: string;
|
|
1481
|
-
fileName?: string;
|
|
1482
|
-
originalFileName?: string;
|
|
1483
|
-
source: AssetSource;
|
|
1484
|
-
}
|
|
1485
|
-
interface EmittedChunk {
|
|
1486
|
-
type: "chunk";
|
|
1487
|
-
name?: string;
|
|
1488
|
-
fileName?: string;
|
|
1489
|
-
preserveSignature?: "strict" | "allow-extension" | "exports-only" | false;
|
|
1490
|
-
id: string;
|
|
1491
|
-
importer?: string;
|
|
1492
|
-
}
|
|
1493
|
-
interface EmittedPrebuiltChunk {
|
|
1494
|
-
type: "prebuilt-chunk";
|
|
1495
|
-
fileName: string;
|
|
1496
|
-
code: string;
|
|
1497
|
-
exports?: string[];
|
|
1498
|
-
map?: SourceMap;
|
|
1499
|
-
sourcemapFileName?: string;
|
|
1500
|
-
}
|
|
1501
|
-
/** @category Plugin APIs */
|
|
1502
|
-
type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
|
|
1503
|
-
interface PluginContextResolveOptions {
|
|
1504
|
-
isEntry?: boolean;
|
|
1505
|
-
skipSelf?: boolean;
|
|
1506
|
-
custom?: CustomPluginOptions;
|
|
1507
|
-
}
|
|
1508
|
-
/** @category Plugin APIs */
|
|
1509
|
-
type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
1510
|
-
/** @category Plugin APIs */
|
|
1511
|
-
interface PluginContext extends MinimalPluginContext {
|
|
1512
|
-
fs: RolldownFsModule;
|
|
1513
|
-
emitFile(file: EmittedFile): string;
|
|
1514
|
-
getFileName(referenceId: string): string;
|
|
1515
|
-
getModuleIds(): IterableIterator<string>;
|
|
1516
|
-
getModuleInfo: GetModuleInfo;
|
|
1517
|
-
addWatchFile(id: string): void;
|
|
1518
|
-
load(options: {
|
|
1519
|
-
id: string;
|
|
1520
|
-
resolveDependencies?: boolean;
|
|
1521
|
-
} & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
|
|
1522
|
-
parse(input: string, options?: ParserOptions | null): Program;
|
|
1523
|
-
resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
|
|
1524
|
-
}
|
|
1525
|
-
//#endregion
|
|
1526
|
-
//#region src/plugin/transform-plugin-context.d.ts
|
|
1527
|
-
/** @category Plugin APIs */
|
|
1528
|
-
interface TransformPluginContext extends PluginContext {
|
|
1529
|
-
debug: LoggingFunctionWithPosition;
|
|
1530
|
-
info: LoggingFunctionWithPosition;
|
|
1531
|
-
warn: LoggingFunctionWithPosition;
|
|
1532
|
-
error(e: RollupError | string, pos?: number | {
|
|
1533
|
-
column: number;
|
|
1534
|
-
line: number;
|
|
1535
|
-
}): never;
|
|
1536
|
-
getCombinedSourcemap(): SourceMap;
|
|
1537
|
-
}
|
|
1538
|
-
//#endregion
|
|
1539
|
-
//#region src/types/module-side-effects.d.ts
|
|
1540
|
-
interface ModuleSideEffectsRule {
|
|
1541
|
-
test?: RegExp;
|
|
1542
|
-
external?: boolean;
|
|
1543
|
-
sideEffects: boolean;
|
|
1544
|
-
}
|
|
1545
|
-
type ModuleSideEffectsOption = boolean | readonly string[] | ModuleSideEffectsRule[] | ((id: string, external: boolean) => boolean | undefined) | "no-external";
|
|
1546
|
-
/**
|
|
1547
|
-
* When passing an object, you can fine-tune the tree-shaking behavior.
|
|
1548
|
-
*/
|
|
1549
|
-
type TreeshakingOptions = {
|
|
1550
|
-
/**
|
|
1551
|
-
* **Values:**
|
|
1552
|
-
*
|
|
1553
|
-
* - **`true`**: All modules are assumed to have side effects and will be included in the bundle even if none of their exports are used.
|
|
1554
|
-
* - **`false`**: No modules have side effects. This enables aggressive tree-shaking, removing any modules whose exports are not used.
|
|
1555
|
-
* - **`string[]`**: Array of module IDs that have side effects. Only modules in this list will be preserved if unused; all others can be tree-shaken when their exports are unused.
|
|
1556
|
-
* - **`'no-external'`**: Assumes no external modules have side effects while preserving the default behavior for local modules.
|
|
1557
|
-
* - **`ModuleSideEffectsRule[]`**: Array of rules with `test`, `external`, and `sideEffects` properties for fine-grained control.
|
|
1558
|
-
* - **`function`**: Function that receives `(id, external)` and returns whether the module has side effects.
|
|
1559
|
-
*
|
|
1560
|
-
* **Important:** Setting this to `false` or using an array/string assumes that your modules and their dependencies have no side effects other than their exports. Only use this if you're certain that removing unused modules won't break your application.
|
|
1561
|
-
*
|
|
1562
|
-
* > [!NOTE]
|
|
1563
|
-
* > **Performance: Prefer `ModuleSideEffectsRule[]` over functions**
|
|
1564
|
-
* >
|
|
1565
|
-
* > When possible, use rule-based configuration instead of functions. Rules are processed entirely in Rust, while JavaScript functions require runtime calls between Rust and JavaScript, which can hurt CPU utilization during builds.
|
|
1566
|
-
* >
|
|
1567
|
-
* > **Functions should be a last resort**: Only use the function signature when your logic cannot be expressed with patterns or simple string matching.
|
|
1568
|
-
* >
|
|
1569
|
-
* > **Rule advantages**: `ModuleSideEffectsRule[]` provides better performance by avoiding Rust-JavaScript runtime calls, clearer intent, and easier maintenance.
|
|
1570
|
-
*
|
|
1571
|
-
* @example
|
|
1572
|
-
* ```js
|
|
1573
|
-
* // Assume no modules have side effects (aggressive tree-shaking)
|
|
1574
|
-
* treeshake: {
|
|
1575
|
-
* moduleSideEffects: false
|
|
1576
|
-
* }
|
|
1577
|
-
*
|
|
1578
|
-
* // Only specific modules have side effects (string array)
|
|
1579
|
-
* treeshake: {
|
|
1580
|
-
* moduleSideEffects: [
|
|
1581
|
-
* 'lodash',
|
|
1582
|
-
* 'react-dom',
|
|
1583
|
-
* ]
|
|
1584
|
-
* }
|
|
1585
|
-
*
|
|
1586
|
-
* // Use rules for pattern matching and granular control
|
|
1587
|
-
* treeshake: {
|
|
1588
|
-
* moduleSideEffects: [
|
|
1589
|
-
* { test: /^node:/, sideEffects: true },
|
|
1590
|
-
* { test: /\.css$/, sideEffects: true },
|
|
1591
|
-
* { test: /some-package/, sideEffects: false, external: false },
|
|
1592
|
-
* ]
|
|
1593
|
-
* }
|
|
1594
|
-
*
|
|
1595
|
-
* // Custom function to determine side effects
|
|
1596
|
-
* treeshake: {
|
|
1597
|
-
* moduleSideEffects: (id, external) => {
|
|
1598
|
-
* if (external) return false; // external modules have no side effects
|
|
1599
|
-
* return id.includes('/side-effects/') || id.endsWith('.css');
|
|
1600
|
-
* }
|
|
1601
|
-
* }
|
|
1602
|
-
*
|
|
1603
|
-
* // Assume no external modules have side effects
|
|
1604
|
-
* treeshake: {
|
|
1605
|
-
* moduleSideEffects: 'no-external',
|
|
1606
|
-
* }
|
|
1607
|
-
* ```
|
|
1608
|
-
*
|
|
1609
|
-
* **Common Use Cases:**
|
|
1610
|
-
* - **CSS files**: `{ test: /\.css$/, sideEffects: true }` - preserve CSS imports
|
|
1611
|
-
* - **Polyfills**: Add specific polyfill modules to the array
|
|
1612
|
-
* - **Plugins**: Modules that register themselves globally on import
|
|
1613
|
-
* - **Library development**: Set to `false` for libraries where unused exports should be removed
|
|
1614
|
-
*
|
|
1615
|
-
* @default true
|
|
1616
|
-
*/
|
|
1617
|
-
moduleSideEffects?: ModuleSideEffectsOption;
|
|
1618
|
-
/**
|
|
1619
|
-
* Whether to respect `/*@__PURE__*\/` annotations and other tree-shaking hints in the code.
|
|
1620
|
-
*
|
|
1621
|
-
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#pure-annotations) for more details.
|
|
1622
|
-
*
|
|
1623
|
-
* @default true
|
|
1624
|
-
*/
|
|
1625
|
-
annotations?: boolean;
|
|
1626
|
-
/**
|
|
1627
|
-
* Array of function names that should be considered pure (no side effects) even if they can't be automatically detected as pure.
|
|
1628
|
-
*
|
|
1629
|
-
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#define-pure-functions) for more details.
|
|
1630
|
-
*
|
|
1631
|
-
* @example
|
|
1632
|
-
* ```js
|
|
1633
|
-
* treeshake: {
|
|
1634
|
-
* manualPureFunctions: ['console.log', 'debug.trace']
|
|
1635
|
-
* }
|
|
1636
|
-
* ```
|
|
1637
|
-
* @default []
|
|
1638
|
-
*/
|
|
1639
|
-
manualPureFunctions?: readonly string[];
|
|
1640
|
-
/**
|
|
1641
|
-
* Whether to assume that accessing unknown global properties might have side effects.
|
|
1642
|
-
*
|
|
1643
|
-
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-global-variable-access-side-effects) for more details.
|
|
1644
|
-
*
|
|
1645
|
-
* @default true
|
|
1646
|
-
*/
|
|
1647
|
-
unknownGlobalSideEffects?: boolean;
|
|
1648
|
-
/**
|
|
1649
|
-
* Whether to enable tree-shaking for CommonJS modules. When `true`, unused exports from CommonJS modules can be eliminated from the bundle, similar to ES modules. When disabled, CommonJS modules will always be included in their entirety.
|
|
1650
|
-
*
|
|
1651
|
-
* This option allows rolldown to analyze `exports.property` assignments in CommonJS modules and remove unused exports while preserving the module's side effects.
|
|
1652
|
-
*
|
|
1653
|
-
* @example
|
|
1654
|
-
* ```js
|
|
1655
|
-
* // source.js (CommonJS)
|
|
1656
|
-
* exports.used = 'This will be kept';
|
|
1657
|
-
* exports.unused = 'This will be tree-shaken away';
|
|
1658
|
-
*
|
|
1659
|
-
* // main.js
|
|
1660
|
-
* import { used } from './source.js';
|
|
1661
|
-
* // With commonjs: true, only the 'used' export is included in the bundle
|
|
1662
|
-
* // With commonjs: false, both exports are included
|
|
1663
|
-
* ```
|
|
1664
|
-
* @default true
|
|
1665
|
-
*/
|
|
1666
|
-
commonjs?: boolean;
|
|
1667
|
-
/**
|
|
1668
|
-
* Controls whether reading properties from objects is considered to have side effects.
|
|
1669
|
-
*
|
|
1670
|
-
* Set to `false` for more aggressive tree-shaking behavior.
|
|
1671
|
-
*
|
|
1672
|
-
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-property-read-side-effects) for more details.
|
|
1673
|
-
*
|
|
1674
|
-
* @default 'always'
|
|
1675
|
-
*/
|
|
1676
|
-
propertyReadSideEffects?: false | "always";
|
|
1677
|
-
/**
|
|
1678
|
-
* Controls whether writing properties to objects is considered to have side effects.
|
|
1679
|
-
*
|
|
1680
|
-
* Set to `false` for more aggressive behavior.
|
|
1681
|
-
*
|
|
1682
|
-
* @default 'always'
|
|
1683
|
-
*/
|
|
1684
|
-
propertyWriteSideEffects?: false | "always";
|
|
1685
|
-
};
|
|
1686
|
-
//#endregion
|
|
1687
|
-
//#region src/types/output-bundle.d.ts
|
|
1688
|
-
/** @category Plugin APIs */
|
|
1689
|
-
interface OutputBundle {
|
|
1690
|
-
[fileName: string]: OutputAsset | OutputChunk;
|
|
1691
|
-
}
|
|
1692
|
-
//#endregion
|
|
1693
|
-
//#region src/types/sourcemap.d.ts
|
|
1694
|
-
/** @category Plugin APIs */
|
|
1695
|
-
interface ExistingRawSourceMap {
|
|
1696
|
-
file?: string | null;
|
|
1697
|
-
mappings: string;
|
|
1698
|
-
names?: string[];
|
|
1699
|
-
sources?: (string | null)[];
|
|
1700
|
-
sourcesContent?: (string | null)[];
|
|
1701
|
-
sourceRoot?: string;
|
|
1702
|
-
version?: number;
|
|
1703
|
-
x_google_ignoreList?: number[];
|
|
1704
|
-
}
|
|
1705
|
-
type SourceMapInput = ExistingRawSourceMap | string | null;
|
|
1706
|
-
//#endregion
|
|
1707
|
-
//#region src/version.d.ts
|
|
1708
|
-
/** @category Plugin APIs */
|
|
1709
|
-
declare const VERSION: string;
|
|
1710
|
-
//#endregion
|
|
1711
|
-
//#region src/builtin-plugin/utils.d.ts
|
|
1712
|
-
declare class BuiltinPlugin {
|
|
1713
|
-
name: BindingBuiltinPluginName;
|
|
1714
|
-
_options?: unknown;
|
|
1715
|
-
/** Vite-specific option to control plugin ordering */
|
|
1716
|
-
enforce?: "pre" | "post";
|
|
1717
|
-
constructor(name: BindingBuiltinPluginName, _options?: unknown);
|
|
1718
|
-
}
|
|
1719
|
-
//#endregion
|
|
1720
|
-
//#region src/constants/plugin.d.ts
|
|
1721
|
-
declare const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "buildEnd", "onLog", "resolveDynamicImport", "closeBundle", "closeWatcher", "watchChange"];
|
|
1722
|
-
declare const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES: readonly ["augmentChunkHash", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "generateBundle"];
|
|
1723
|
-
declare const ENUMERATED_PLUGIN_HOOK_NAMES: [...typeof ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ...typeof ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, "footer", "banner", "intro", "outro"];
|
|
1724
|
-
/**
|
|
1725
|
-
* Names of all defined hooks. It's like
|
|
1726
|
-
* ```ts
|
|
1727
|
-
* type DefinedHookNames = {
|
|
1728
|
-
* options: 'options',
|
|
1729
|
-
* buildStart: 'buildStart',
|
|
1730
|
-
* ...
|
|
1731
|
-
* }
|
|
1732
|
-
* ```
|
|
1733
|
-
*/
|
|
1734
|
-
type DefinedHookNames = { readonly [K in (typeof ENUMERATED_PLUGIN_HOOK_NAMES)[number]]: K };
|
|
1735
|
-
/**
|
|
1736
|
-
* Names of all defined hooks. It's like
|
|
1737
|
-
* ```js
|
|
1738
|
-
* const DEFINED_HOOK_NAMES ={
|
|
1739
|
-
* options: 'options',
|
|
1740
|
-
* buildStart: 'buildStart',
|
|
1741
|
-
* ...
|
|
1742
|
-
* }
|
|
1743
|
-
* ```
|
|
1744
|
-
*/
|
|
1745
|
-
declare const DEFINED_HOOK_NAMES: DefinedHookNames;
|
|
1746
|
-
//#endregion
|
|
1747
|
-
//#region src/plugin/with-filter.d.ts
|
|
1748
|
-
type OverrideFilterObject = {
|
|
1749
|
-
transform?: HookFilterExtension<"transform">["filter"];
|
|
1750
|
-
resolveId?: HookFilterExtension<"resolveId">["filter"];
|
|
1751
|
-
load?: HookFilterExtension<"load">["filter"];
|
|
1752
|
-
pluginNamePattern?: StringOrRegExp[];
|
|
1753
|
-
};
|
|
1754
|
-
declare function withFilter<A, T extends RolldownPluginOption<A>>(pluginOption: T, filterObject: OverrideFilterObject | OverrideFilterObject[]): T;
|
|
1755
|
-
//#endregion
|
|
1756
|
-
//#region src/plugin/index.d.ts
|
|
1757
|
-
type ModuleSideEffects = boolean | "no-treeshake" | null;
|
|
1758
|
-
/** @category Plugin APIs */
|
|
1759
|
-
type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
|
|
1760
|
-
/** @category Plugin APIs */
|
|
1761
|
-
type ImportKind = BindingHookResolveIdExtraArgs["kind"];
|
|
1762
|
-
/** @category Plugin APIs */
|
|
1763
|
-
interface CustomPluginOptions {
|
|
1764
|
-
[plugin: string]: any;
|
|
1765
|
-
}
|
|
1766
|
-
/** @category Plugin APIs */
|
|
1767
|
-
interface ModuleOptions {
|
|
1768
|
-
moduleSideEffects: ModuleSideEffects;
|
|
1769
|
-
meta: CustomPluginOptions;
|
|
1770
|
-
invalidate?: boolean;
|
|
1771
|
-
packageJsonPath?: string;
|
|
1772
|
-
}
|
|
1773
|
-
/** @category Plugin APIs */
|
|
1774
|
-
interface ResolvedId extends ModuleOptions {
|
|
1775
|
-
external: boolean | "absolute";
|
|
1776
|
-
id: string;
|
|
1777
|
-
}
|
|
1778
|
-
/** @category Plugin APIs */
|
|
1779
|
-
interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
|
|
1780
|
-
external?: boolean | "absolute" | "relative";
|
|
1781
|
-
id: string;
|
|
1782
|
-
}
|
|
1783
|
-
/** @category Plugin APIs */
|
|
1784
|
-
interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
1785
|
-
code: string;
|
|
1786
|
-
map?: SourceMapInput;
|
|
1787
|
-
moduleType?: ModuleType;
|
|
1788
|
-
}
|
|
1789
|
-
/** @category Plugin APIs */
|
|
1790
|
-
interface ResolveIdExtraOptions {
|
|
1791
|
-
custom?: CustomPluginOptions;
|
|
1792
|
-
isEntry: boolean;
|
|
1793
|
-
kind: BindingHookResolveIdExtraArgs["kind"];
|
|
1794
|
-
}
|
|
1795
|
-
/** @category Plugin APIs */
|
|
1796
|
-
type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
1797
|
-
/** @category Plugin APIs */
|
|
1798
|
-
type LoadResult = NullValue | string | SourceDescription;
|
|
1799
|
-
/** @category Plugin APIs */
|
|
1800
|
-
type TransformResult = NullValue | string | (Omit<SourceDescription, "code"> & {
|
|
1801
|
-
code?: string | BindingMagicString;
|
|
1802
|
-
});
|
|
1803
|
-
type RenderedChunkMeta = {
|
|
1804
|
-
chunks: Record<string, RenderedChunk>;
|
|
1805
|
-
};
|
|
1806
|
-
/** @category Plugin APIs */
|
|
1807
|
-
interface FunctionPluginHooks {
|
|
1808
|
-
[DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
|
|
1809
|
-
[DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
|
|
1810
|
-
[DEFINED_HOOK_NAMES.outputOptions]: (this: MinimalPluginContext, options: OutputOptions) => NullValue | OutputOptions;
|
|
1811
|
-
[DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
|
|
1812
|
-
[DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
|
|
1813
|
-
/**
|
|
1814
|
-
* @deprecated
|
|
1815
|
-
* This hook is only for rollup plugin compatibility. Please use `resolveId` instead.
|
|
1816
|
-
*/
|
|
1817
|
-
[DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
|
|
1818
|
-
[DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
|
|
1819
|
-
[DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
|
|
1820
|
-
moduleType: ModuleType;
|
|
1821
|
-
magicString?: BindingMagicString;
|
|
1822
|
-
ast?: Program;
|
|
1823
|
-
}) => TransformResult;
|
|
1824
|
-
[DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
|
|
1825
|
-
[DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
|
|
1826
|
-
[DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
|
|
1827
|
-
[DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | {
|
|
1828
|
-
code: string;
|
|
1829
|
-
map?: SourceMapInput;
|
|
1830
|
-
};
|
|
1831
|
-
[DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
|
|
1832
|
-
[DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
|
|
1833
|
-
[DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
|
|
1834
|
-
[DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
|
|
1835
|
-
[DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext, error?: Error) => void;
|
|
1836
|
-
[DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
|
|
1837
|
-
event: ChangeEvent;
|
|
1838
|
-
}) => void;
|
|
1839
|
-
[DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
|
|
1840
|
-
}
|
|
1841
|
-
type ChangeEvent = "create" | "update" | "delete";
|
|
1842
|
-
type PluginOrder = "pre" | "post" | null;
|
|
1843
|
-
type ObjectHookMeta = {
|
|
1844
|
-
order?: PluginOrder;
|
|
1845
|
-
};
|
|
1846
|
-
/** @category Plugin APIs */
|
|
1847
|
-
type ObjectHook<T, O = {}> = T | ({
|
|
1848
|
-
handler: T;
|
|
1849
|
-
} & ObjectHookMeta & O);
|
|
1850
|
-
type SyncPluginHooks = DefinedHookNames["augmentChunkHash" | "onLog" | "outputOptions"];
|
|
1851
|
-
/** @category Plugin APIs */
|
|
1852
|
-
type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
|
|
1853
|
-
type FirstPluginHooks = DefinedHookNames["load" | "resolveDynamicImport" | "resolveId"];
|
|
1854
|
-
type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "onLog" | "options" | "outputOptions" | "renderChunk" | "transform"];
|
|
1855
|
-
type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
|
|
1856
|
-
type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
|
|
1857
|
-
/** @internal */
|
|
1858
|
-
type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
1859
|
-
/** @category Plugin APIs */
|
|
1860
|
-
type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
|
|
1861
|
-
filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
|
|
1862
|
-
} : K extends "load" ? {
|
|
1863
|
-
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
|
|
1864
|
-
} : K extends "resolveId" ? {
|
|
1865
|
-
filter?: TUnionWithTopLevelFilterExpressionArray<{
|
|
1866
|
-
id?: GeneralHookFilter<RegExp>;
|
|
1867
|
-
}>;
|
|
1868
|
-
} : K extends "renderChunk" ? {
|
|
1869
|
-
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
|
|
1870
|
-
} : {};
|
|
1871
|
-
type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
|
|
1872
|
-
/**
|
|
1873
|
-
* @deprecated
|
|
1874
|
-
* this is only for rollup Plugin type compatibility.
|
|
1875
|
-
* hooks always work as `sequential: true`.
|
|
1876
|
-
*/
|
|
1877
|
-
sequential?: boolean;
|
|
1878
|
-
} : {})> };
|
|
1879
|
-
type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
|
|
1880
|
-
type AddonHook = string | AddonHookFunction;
|
|
1881
|
-
interface OutputPlugin extends Partial<{ [K in keyof PluginHooks as K & OutputPluginHooks]: PluginHooks[K] }>, Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
|
|
1882
|
-
name: string;
|
|
1883
|
-
}
|
|
1884
|
-
/** @category Plugin APIs */
|
|
1885
|
-
interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
|
|
1886
|
-
api?: A;
|
|
1887
|
-
}
|
|
1888
|
-
type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
|
|
1889
|
-
type RolldownPluginOption<A = any> = MaybePromise<NullValue<RolldownPlugin<A>> | {
|
|
1890
|
-
name: string;
|
|
1891
|
-
} | false | RolldownPluginOption[]>;
|
|
1892
|
-
type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
|
|
1893
|
-
type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | {
|
|
1894
|
-
name: string;
|
|
1895
|
-
} | false | RolldownOutputPluginOption[]>;
|
|
1896
|
-
//#endregion
|
|
1897
|
-
//#region src/options/input-options.d.ts
|
|
1898
|
-
/**
|
|
1899
|
-
* @inline
|
|
1900
|
-
*/
|
|
1901
|
-
type InputOption = string | string[] | Record<string, string>;
|
|
1902
|
-
/**
|
|
1903
|
-
* @param id The id of the module being checked.
|
|
1904
|
-
* @param parentId The id of the module importing the id being checked.
|
|
1905
|
-
* @param isResolved Whether the id has been resolved.
|
|
1906
|
-
* @returns Whether the module should be treated as external.
|
|
1907
|
-
*/
|
|
1908
|
-
type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
|
|
1909
|
-
/** @inline */
|
|
1910
|
-
type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
|
|
1911
|
-
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
1912
|
-
interface WatcherOptions {
|
|
1913
|
-
/**
|
|
1914
|
-
* Whether to skip the `bundle.write()` step when a rebuild is triggered.
|
|
1915
|
-
* @default false
|
|
1916
|
-
*/
|
|
1917
|
-
skipWrite?: boolean;
|
|
1918
|
-
/**
|
|
1919
|
-
* Configures how long Rolldown will wait for further changes until it triggers
|
|
1920
|
-
* a rebuild in milliseconds.
|
|
1921
|
-
*
|
|
1922
|
-
* Even if this value is set to 0, there's a small debounce timeout configured
|
|
1923
|
-
* in the file system watcher. Setting this to a value greater than 0 will mean
|
|
1924
|
-
* that Rolldown will only trigger a rebuild if there was no change for the
|
|
1925
|
-
* configured number of milliseconds. If several configurations are watched,
|
|
1926
|
-
* Rolldown will use the largest configured build delay.
|
|
1927
|
-
*
|
|
1928
|
-
* @default 0
|
|
1929
|
-
*/
|
|
1930
|
-
buildDelay?: number;
|
|
1931
|
-
/**
|
|
1932
|
-
* An optional object of options that will be passed to the [notify](https://github.com/rolldown/notify) file watcher.
|
|
1933
|
-
*/
|
|
1934
|
-
notify?: {
|
|
1935
|
-
/**
|
|
1936
|
-
* Interval between each re-scan attempt in milliseconds.
|
|
1937
|
-
*
|
|
1938
|
-
* This option is only used when polling backend is used.
|
|
1939
|
-
*
|
|
1940
|
-
* @default 30_000
|
|
1941
|
-
*/
|
|
1942
|
-
pollInterval?: number;
|
|
1943
|
-
/**
|
|
1944
|
-
* Whether to compare file contents when checking for changes.
|
|
1945
|
-
*
|
|
1946
|
-
* This is especially important for pseudo filesystems like those on Linux
|
|
1947
|
-
* under `/sys` and `/proc` which are not obligated to respect any other
|
|
1948
|
-
* filesystem norms such as modification timestamps, file sizes, etc. By
|
|
1949
|
-
* enabling this feature, performance will be significantly impacted as
|
|
1950
|
-
* all files will need to be read and hashed at each interval.
|
|
1951
|
-
*
|
|
1952
|
-
* This option is only used when polling backend is used.
|
|
1953
|
-
*
|
|
1954
|
-
* @default false
|
|
1955
|
-
*/
|
|
1956
|
-
compareContents?: boolean;
|
|
1957
|
-
};
|
|
1958
|
-
/**
|
|
1959
|
-
* Filter to limit the file-watching to certain files.
|
|
1960
|
-
*
|
|
1961
|
-
* Strings are treated as glob patterns.
|
|
1962
|
-
* Note that this only filters the module graph but does not allow adding
|
|
1963
|
-
* additional watch files.
|
|
1964
|
-
*
|
|
1965
|
-
* @example
|
|
1966
|
-
* ```js
|
|
1967
|
-
* export default defineConfig({
|
|
1968
|
-
* watch: {
|
|
1969
|
-
* include: 'src/**',
|
|
1970
|
-
* },
|
|
1971
|
-
* })
|
|
1972
|
-
* ```
|
|
1973
|
-
* @default []
|
|
1974
|
-
*/
|
|
1975
|
-
include?: StringOrRegExp | StringOrRegExp[];
|
|
1976
|
-
/**
|
|
1977
|
-
* Filter to prevent files from being watched.
|
|
1978
|
-
*
|
|
1979
|
-
* Strings are treated as glob patterns.
|
|
1980
|
-
*
|
|
1981
|
-
* @example
|
|
1982
|
-
* ```js
|
|
1983
|
-
* export default defineConfig({
|
|
1984
|
-
* watch: {
|
|
1985
|
-
* exclude: 'node_modules/**',
|
|
1986
|
-
* },
|
|
1987
|
-
* })
|
|
1988
|
-
* ```
|
|
1989
|
-
* @default []
|
|
1990
|
-
*/
|
|
1991
|
-
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
1992
|
-
/**
|
|
1993
|
-
* An optional function that will be called immediately every time
|
|
1994
|
-
* a module changes that is part of the build.
|
|
1995
|
-
*
|
|
1996
|
-
* This is different from the `watchChange` plugin hook, which is
|
|
1997
|
-
* only called once the running build has finished. This may for
|
|
1998
|
-
* instance be used to prevent additional steps from being performed
|
|
1999
|
-
* if we know another build will be started anyway once the current
|
|
2000
|
-
* build finished. This callback may be called multiple times per
|
|
2001
|
-
* build as it tracks every change.
|
|
2002
|
-
*
|
|
2003
|
-
* @param id The id of the changed module.
|
|
2004
|
-
*/
|
|
2005
|
-
onInvalidate?: (id: string) => void;
|
|
2006
|
-
/**
|
|
2007
|
-
* Whether to clear the screen when a rebuild is triggered.
|
|
2008
|
-
* @default true
|
|
2009
|
-
*/
|
|
2010
|
-
clearScreen?: boolean;
|
|
2011
|
-
}
|
|
2012
|
-
/** @inline */
|
|
2013
|
-
type MakeAbsoluteExternalsRelative = boolean | "ifRelativeSource";
|
|
2014
|
-
type DevModeOptions = boolean | {
|
|
2015
|
-
host?: string;
|
|
2016
|
-
port?: number;
|
|
2017
|
-
implement?: string;
|
|
2018
|
-
lazy?: boolean;
|
|
2019
|
-
};
|
|
2020
|
-
type OptimizationOptions = {
|
|
2021
|
-
/**
|
|
2022
|
-
* Inline imported constant values during bundling instead of preserving variable references.
|
|
2023
|
-
*
|
|
2024
|
-
* When enabled, constant values from imported modules will be inlined at their usage sites,
|
|
2025
|
-
* potentially reducing bundle size and improving runtime performance by eliminating variable lookups.
|
|
2026
|
-
*
|
|
2027
|
-
* **Options:**
|
|
2028
|
-
* - `true`: equivalent to `{ mode: 'all', pass: 1 }`, enabling constant inlining for all eligible constants with a single pass.
|
|
2029
|
-
* - `false`: Disable constant inlining
|
|
2030
|
-
* - `{ mode: 'smart' | 'all', pass?: number }`:
|
|
2031
|
-
* - `mode: 'smart'`: Only inline constants in specific scenarios where it is likely to reduce bundle size and improve performance.
|
|
2032
|
-
* Smart mode inlines constants in these specific scenarios:
|
|
2033
|
-
* 1. `if (test) {} else {}` - condition expressions in if statements
|
|
2034
|
-
* 2. `test ? a : b` - condition expressions in ternary operators
|
|
2035
|
-
* 3. `test1 || test2` - logical OR expressions
|
|
2036
|
-
* 4. `test1 && test2` - logical AND expressions
|
|
2037
|
-
* 5. `test1 ?? test2` - nullish coalescing expressions
|
|
2038
|
-
* - `mode: 'all'`: Inline all imported constants wherever they are used.
|
|
2039
|
-
* - `pass`: Number of passes to perform for inlining constants.
|
|
2040
|
-
*
|
|
2041
|
-
* @example
|
|
2042
|
-
* ```js
|
|
2043
|
-
* // Input files:
|
|
2044
|
-
* // constants.js
|
|
2045
|
-
* export const API_URL = 'https://api.example.com';
|
|
2046
|
-
*
|
|
2047
|
-
* // main.js
|
|
2048
|
-
* import { API_URL } from './constants.js';
|
|
2049
|
-
* console.log(API_URL);
|
|
2050
|
-
*
|
|
2051
|
-
* // With inlineConst: true, the bundled output becomes:
|
|
2052
|
-
* console.log('https://api.example.com');
|
|
2053
|
-
*
|
|
2054
|
-
* // Instead of:
|
|
2055
|
-
* const API_URL = 'https://api.example.com';
|
|
2056
|
-
* console.log(API_URL);
|
|
2057
|
-
* ```
|
|
2058
|
-
*
|
|
2059
|
-
* @default false
|
|
2060
|
-
*/
|
|
2061
|
-
inlineConst?: boolean | {
|
|
2062
|
-
mode?: "all" | "smart";
|
|
2063
|
-
pass?: number;
|
|
2064
|
-
};
|
|
2065
|
-
/**
|
|
2066
|
-
* Use PIFE pattern for module wrappers.
|
|
2067
|
-
*
|
|
2068
|
-
* Enabling this option improves the start up performance of the generated bundle with the cost of a slight increase in bundle size.
|
|
2069
|
-
*
|
|
2070
|
-
* {@include ./docs/optimization-pife-for-module-wrappers.md}
|
|
2071
|
-
*
|
|
2072
|
-
* @default true
|
|
2073
|
-
*/
|
|
2074
|
-
pifeForModuleWrappers?: boolean;
|
|
2075
|
-
};
|
|
2076
|
-
/** @inline */
|
|
2077
|
-
type AttachDebugOptions = "none" | "simple" | "full";
|
|
2078
|
-
/** @inline */
|
|
2079
|
-
type ChunkModulesOrder = "exec-order" | "module-id";
|
|
2080
|
-
/** @inline */
|
|
2081
|
-
type OnLogFunction = (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
|
|
2082
|
-
/** @inline */
|
|
2083
|
-
type OnwarnFunction = (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
|
|
2084
|
-
interface InputOptions {
|
|
2085
|
-
/**
|
|
2086
|
-
* Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the {@linkcode cwd} option.
|
|
2087
|
-
* {@include ./docs/input.md}
|
|
2088
|
-
*/
|
|
2089
|
-
input?: InputOption;
|
|
2090
|
-
/**
|
|
2091
|
-
* The list of plugins to use.
|
|
2092
|
-
*
|
|
2093
|
-
* Falsy plugins will be ignored, which can be used to easily activate or deactivate plugins. Nested plugins will be flattened. Async plugins will be awaited and resolved.
|
|
2094
|
-
*/
|
|
2095
|
-
plugins?: RolldownPluginOption;
|
|
2096
|
-
/**
|
|
2097
|
-
* Specifies which modules should be treated as external and not bundled. External modules will be left as import statements in the output.
|
|
2098
|
-
* {@include ./docs/external.md}
|
|
2099
|
-
*/
|
|
2100
|
-
external?: ExternalOption;
|
|
2101
|
-
/**
|
|
2102
|
-
* Options for built-in module resolution feature.
|
|
2103
|
-
*/
|
|
2104
|
-
resolve?: {
|
|
2105
|
-
/**
|
|
2106
|
-
* Substitute one package for another.
|
|
2107
|
-
*
|
|
2108
|
-
* One use case for this feature is replacing a node-only package with a browser-friendly package in third-party code that you don't control.
|
|
2109
|
-
*
|
|
2110
|
-
* @example
|
|
2111
|
-
* ```js
|
|
2112
|
-
* resolve: {
|
|
2113
|
-
* alias: {
|
|
2114
|
-
* '@': '/src',
|
|
2115
|
-
* 'utils': './src/utils',
|
|
2116
|
-
* }
|
|
2117
|
-
* }
|
|
2118
|
-
* ```
|
|
2119
|
-
* > [!WARNING]
|
|
2120
|
-
* > `resolve.alias` will not call `resolveId` hooks of other plugin.
|
|
2121
|
-
* > If you want to call `resolveId` hooks of other plugin, use `viteAliasPlugin` from `rolldown/experimental` instead.
|
|
2122
|
-
* > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
|
|
2123
|
-
*/
|
|
2124
|
-
alias?: Record<string, string[] | string | false>;
|
|
2125
|
-
/**
|
|
2126
|
-
* Fields in package.json to check for aliased paths.
|
|
2127
|
-
*
|
|
2128
|
-
* This option is expected to be used for `browser` field support.
|
|
2129
|
-
*
|
|
2130
|
-
* @default
|
|
2131
|
-
* - `[['browser']]` for `browser` platform
|
|
2132
|
-
* - `[]` for other platforms
|
|
2133
|
-
*/
|
|
2134
|
-
aliasFields?: string[][];
|
|
2135
|
-
/**
|
|
2136
|
-
* Condition names to use when resolving exports in package.json.
|
|
2137
|
-
*
|
|
2138
|
-
* @default
|
|
2139
|
-
* Defaults based on platform and import kind:
|
|
2140
|
-
* - `browser` platform
|
|
2141
|
-
* - `["import", "browser", "default"]` for import statements
|
|
2142
|
-
* - `["require", "browser", "default"]` for require() calls
|
|
2143
|
-
* - `node` platform
|
|
2144
|
-
* - `["import", "node", "default"]` for import statements
|
|
2145
|
-
* - `["require", "node", "default"]` for require() calls
|
|
2146
|
-
* - `neutral` platform
|
|
2147
|
-
* - `["import", "default"]` for import statements
|
|
2148
|
-
* - `["require", "default"]` for require() calls
|
|
2149
|
-
*/
|
|
2150
|
-
conditionNames?: string[];
|
|
2151
|
-
/**
|
|
2152
|
-
* Map of extensions to alternative extensions.
|
|
2153
|
-
*
|
|
2154
|
-
* With writing `import './foo.js'` in a file, you want to resolve it to `foo.ts` instead of `foo.js`.
|
|
2155
|
-
* You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
|
|
2156
|
-
*/
|
|
2157
|
-
extensionAlias?: Record<string, string[]>;
|
|
2158
|
-
/**
|
|
2159
|
-
* Fields in package.json to check for exports.
|
|
2160
|
-
*
|
|
2161
|
-
* @default `[['exports']]`
|
|
2162
|
-
*/
|
|
2163
|
-
exportsFields?: string[][];
|
|
2164
|
-
/**
|
|
2165
|
-
* Extensions to try when resolving files. These are tried in order from first to last.
|
|
2166
|
-
*
|
|
2167
|
-
* @default `['.tsx', '.ts', '.jsx', '.js', '.json']`
|
|
2168
|
-
*/
|
|
2169
|
-
extensions?: string[];
|
|
2170
|
-
/**
|
|
2171
|
-
* Fields in package.json to check for entry points.
|
|
2172
|
-
*
|
|
2173
|
-
* @default
|
|
2174
|
-
* Defaults based on platform:
|
|
2175
|
-
* - `node` platform: `['main', 'module']`
|
|
2176
|
-
* - `browser` platform: `['browser', 'module', 'main']`
|
|
2177
|
-
* - `neutral` platform: `[]`
|
|
2178
|
-
*/
|
|
2179
|
-
mainFields?: string[];
|
|
2180
|
-
/**
|
|
2181
|
-
* Filenames to try when resolving directories.
|
|
2182
|
-
* @default ['index']
|
|
2183
|
-
*/
|
|
2184
|
-
mainFiles?: string[];
|
|
2185
|
-
/**
|
|
2186
|
-
* Directories to search for modules.
|
|
2187
|
-
* @default ['node_modules']
|
|
2188
|
-
*/
|
|
2189
|
-
modules?: string[];
|
|
2190
|
-
/**
|
|
2191
|
-
* Whether to follow symlinks when resolving modules.
|
|
2192
|
-
* @default true
|
|
2193
|
-
*/
|
|
2194
|
-
symlinks?: boolean;
|
|
2195
|
-
/**
|
|
2196
|
-
* @deprecated Use the top-level {@linkcode tsconfig} option instead.
|
|
2197
|
-
*/
|
|
2198
|
-
tsconfigFilename?: string;
|
|
2199
|
-
};
|
|
2200
|
-
/**
|
|
2201
|
-
* The working directory to use when resolving relative paths in the configuration.
|
|
2202
|
-
* @default process.cwd()
|
|
2203
|
-
*/
|
|
2204
|
-
cwd?: string;
|
|
2205
|
-
/**
|
|
2206
|
-
* Expected platform where the code run.
|
|
2207
|
-
*
|
|
2208
|
-
* When the platform is set to neutral:
|
|
2209
|
-
* - When bundling is enabled the default output format is set to esm, which uses the export syntax introduced with ECMAScript 2015 (i.e. ES6). You can change the output format if this default is not appropriate.
|
|
2210
|
-
* - The main fields setting is empty by default. If you want to use npm-style packages, you will likely have to configure this to be something else such as main for the standard main field used by node.
|
|
2211
|
-
* - The conditions setting does not automatically include any platform-specific values.
|
|
2212
|
-
*
|
|
2213
|
-
* @default
|
|
2214
|
-
* - `'node'` if the format is `'cjs'`
|
|
2215
|
-
* - `'browser'` for other formats
|
|
2216
|
-
* {@include ./docs/platform.md}
|
|
2217
|
-
*/
|
|
2218
|
-
platform?: "node" | "browser" | "neutral";
|
|
2219
|
-
/**
|
|
2220
|
-
* When `true`, creates shim variables for missing exports instead of throwing an error.
|
|
2221
|
-
* @default false
|
|
2222
|
-
* {@include ./docs/shim-missing-exports.md}
|
|
2223
|
-
*/
|
|
2224
|
-
shimMissingExports?: boolean;
|
|
2225
|
-
/**
|
|
2226
|
-
* Controls tree-shaking (dead code elimination).
|
|
2227
|
-
*
|
|
2228
|
-
* When `false`, tree-shaking will be disabled.
|
|
2229
|
-
* When `true`, it is equivalent to setting each options to the default value.
|
|
2230
|
-
*
|
|
2231
|
-
* @default true
|
|
2232
|
-
*/
|
|
2233
|
-
treeshake?: boolean | TreeshakingOptions;
|
|
2234
|
-
/**
|
|
2235
|
-
* Controls the verbosity of console logging during the build.
|
|
2236
|
-
*
|
|
2237
|
-
* {@include ./docs/log-level.md}
|
|
2238
|
-
*
|
|
2239
|
-
* @default 'info'
|
|
2240
|
-
*/
|
|
2241
|
-
logLevel?: LogLevelOption;
|
|
2242
|
-
/**
|
|
2243
|
-
* A function that intercepts log messages. If not supplied, logs are printed to the console.
|
|
2244
|
-
*
|
|
2245
|
-
* {@include ./docs/on-log.md}
|
|
2246
|
-
*
|
|
2247
|
-
* @example
|
|
2248
|
-
* ```js
|
|
2249
|
-
* export default defineConfig({
|
|
2250
|
-
* onLog(level, log, defaultHandler) {
|
|
2251
|
-
* if (log.code === 'CIRCULAR_DEPENDENCY') {
|
|
2252
|
-
* return; // Ignore circular dependency warnings
|
|
2253
|
-
* }
|
|
2254
|
-
* if (level === 'warn') {
|
|
2255
|
-
* defaultHandler('error', log); // turn other warnings into errors
|
|
2256
|
-
* } else {
|
|
2257
|
-
* defaultHandler(level, log); // otherwise, just print the log
|
|
2258
|
-
* }
|
|
2259
|
-
* }
|
|
2260
|
-
* })
|
|
2261
|
-
* ```
|
|
2262
|
-
*/
|
|
2263
|
-
onLog?: OnLogFunction;
|
|
2264
|
-
/**
|
|
2265
|
-
* A function that will intercept warning messages.
|
|
2266
|
-
*
|
|
2267
|
-
* {@include ./docs/on-warn.md}
|
|
2268
|
-
*
|
|
2269
|
-
* @deprecated
|
|
2270
|
-
* This is a legacy API. Consider using {@linkcode onLog} instead for better control over all log types.
|
|
2271
|
-
*
|
|
2272
|
-
* {@include ./docs/on-warn-deprecation.md}
|
|
2273
|
-
*/
|
|
2274
|
-
onwarn?: OnwarnFunction;
|
|
2275
|
-
/**
|
|
2276
|
-
* Maps file patterns to module types, controlling how files are processed.
|
|
2277
|
-
*
|
|
2278
|
-
* This is conceptually similar to esbuild's loader option, allowing you to specify how different file extensions should be handled.
|
|
2279
|
-
*/
|
|
2280
|
-
moduleTypes?: ModuleTypes;
|
|
2281
|
-
/**
|
|
2282
|
-
* Experimental features that may change in future releases and can introduce behavior change without a major version bump.
|
|
2283
|
-
* @experimental
|
|
2284
|
-
*/
|
|
2285
|
-
experimental?: {
|
|
2286
|
-
/**
|
|
2287
|
-
* Lets modules be executed in the order they are declared.
|
|
2288
|
-
*
|
|
2289
|
-
* This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
|
|
2290
|
-
*
|
|
2291
|
-
* > [!WARNING]
|
|
2292
|
-
* > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
|
|
2293
|
-
* @default false
|
|
2294
|
-
*/
|
|
2295
|
-
strictExecutionOrder?: boolean;
|
|
2296
|
-
/**
|
|
2297
|
-
* Enable Vite compatible mode.
|
|
2298
|
-
* @default false
|
|
2299
|
-
* @hidden This option is only meant to be used by Vite. It is not recommended to use this option directly.
|
|
2300
|
-
*/
|
|
2301
|
-
viteMode?: boolean;
|
|
2302
|
-
/**
|
|
2303
|
-
* When enabled, `new URL()` calls will be transformed to a stable asset URL which includes the updated name and content hash.
|
|
2304
|
-
* It is necessary to pass `import.meta.url` as the second argument to the
|
|
2305
|
-
* `new URL` constructor, otherwise no transform will be applied.
|
|
2306
|
-
* :::warning
|
|
2307
|
-
* JavaScript and TypeScript files referenced via `new URL('./file.js', import.meta.url)` or `new URL('./file.ts', import.meta.url)` will **not** be transformed or bundled. The file will be copied as-is, meaning TypeScript files remain untransformed and dependencies are not resolved.
|
|
2308
|
-
*
|
|
2309
|
-
* The expected behavior for JS/TS files is still being discussed and may
|
|
2310
|
-
* change in future releases. See [#7258](https://github.com/rolldown/rolldown/issues/7258) for more context.
|
|
2311
|
-
* :::
|
|
2312
|
-
* @example
|
|
2313
|
-
* ```js
|
|
2314
|
-
* // main.js
|
|
2315
|
-
* const url = new URL('./styles.css', import.meta.url);
|
|
2316
|
-
* console.log(url);
|
|
2317
|
-
*
|
|
2318
|
-
* // Example output after bundling WITHOUT the option (default)
|
|
2319
|
-
* const url = new URL('./styles.css', import.meta.url);
|
|
2320
|
-
* console.log(url);
|
|
2321
|
-
*
|
|
2322
|
-
* // Example output after bundling WITH `experimental.resolveNewUrlToAsset` set to `true`
|
|
2323
|
-
* const url = new URL('assets/styles-CjdrdY7X.css', import.meta.url);
|
|
2324
|
-
* console.log(url);
|
|
2325
|
-
* ```
|
|
2326
|
-
* @default false
|
|
2327
|
-
*/
|
|
2328
|
-
resolveNewUrlToAsset?: boolean;
|
|
2329
|
-
/**
|
|
2330
|
-
* Dev mode related options.
|
|
2331
|
-
* @hidden not ready for public usage yet
|
|
2332
|
-
*/
|
|
2333
|
-
devMode?: DevModeOptions;
|
|
2334
|
-
/**
|
|
2335
|
-
* Control which order should be used when rendering modules in a chunk.
|
|
2336
|
-
*
|
|
2337
|
-
* Available options:
|
|
2338
|
-
* - `exec-order`: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
|
|
2339
|
-
* - `module-id`: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
|
|
2340
|
-
*
|
|
2341
|
-
* > [!NOTE]
|
|
2342
|
-
* > Try to sort the modules by their module id if possible (Since rolldown scope hoist all modules in the chunk, we only try to sort those modules by module id if we could ensure runtime behavior is correct after sorting).
|
|
2343
|
-
*
|
|
2344
|
-
* @default 'exec-order'
|
|
2345
|
-
*/
|
|
2346
|
-
chunkModulesOrder?: ChunkModulesOrder;
|
|
2347
|
-
/**
|
|
2348
|
-
* Attach debug information to the output bundle.
|
|
2349
|
-
*
|
|
2350
|
-
* Available modes:
|
|
2351
|
-
* - `none`: No debug information is attached.
|
|
2352
|
-
* - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
|
|
2353
|
-
* - `full`: Attach detailed debug information to the output bundle. These comments are using legal comment syntax, so they won't be removed by the minifier.
|
|
2354
|
-
*
|
|
2355
|
-
* @default 'simple'
|
|
2356
|
-
*/
|
|
2357
|
-
attachDebugInfo?: AttachDebugOptions;
|
|
2358
|
-
/**
|
|
2359
|
-
* Enables automatic generation of a chunk import map asset during build.
|
|
2360
|
-
*
|
|
2361
|
-
* This map only includes chunks with hashed filenames, where keys are derived from the facade module
|
|
2362
|
-
* name or primary chunk name. It produces stable and unique hash-based filenames, effectively preventing
|
|
2363
|
-
* cascading cache invalidation caused by content hashes and maximizing browser cache reuse.
|
|
2364
|
-
*
|
|
2365
|
-
* The output defaults to `importmap.json` unless overridden via `fileName`. A base URL prefix
|
|
2366
|
-
* (default `"/"`) can be applied to all paths. The resulting JSON is a valid import map and can be
|
|
2367
|
-
* directly injected into HTML via `<script type="importmap">`.
|
|
2368
|
-
*
|
|
2369
|
-
* @example
|
|
2370
|
-
* ```js
|
|
2371
|
-
* {
|
|
2372
|
-
* experimental: {
|
|
2373
|
-
* chunkImportMap: {
|
|
2374
|
-
* baseUrl: '/',
|
|
2375
|
-
* fileName: 'importmap.json'
|
|
2376
|
-
* }
|
|
2377
|
-
* },
|
|
2378
|
-
* plugins: [
|
|
2379
|
-
* {
|
|
2380
|
-
* name: 'inject-import-map',
|
|
2381
|
-
* generateBundle(_, bundle) {
|
|
2382
|
-
* const chunkImportMap = bundle['importmap.json'];
|
|
2383
|
-
* if (chunkImportMap?.type === 'asset') {
|
|
2384
|
-
* const htmlPath = path.resolve('index.html');
|
|
2385
|
-
* let html = fs.readFileSync(htmlPath, 'utf-8');
|
|
2386
|
-
*
|
|
2387
|
-
* html = html.replace(
|
|
2388
|
-
* /<script\s+type="importmap"[^>]*>[\s\S]*?<\/script>/i,
|
|
2389
|
-
* `<script type="importmap">${chunkImportMap.source}<\/script>`
|
|
2390
|
-
* );
|
|
2391
|
-
*
|
|
2392
|
-
* fs.writeFileSync(htmlPath, html);
|
|
2393
|
-
* delete bundle['importmap.json'];
|
|
2394
|
-
* }
|
|
2395
|
-
* }
|
|
2396
|
-
* }
|
|
2397
|
-
* ]
|
|
2398
|
-
* }
|
|
2399
|
-
* ```
|
|
2400
|
-
*
|
|
2401
|
-
* > [!TIP]
|
|
2402
|
-
* > If you want to learn more, you can check out the example here: [examples/chunk-import-map](https://github.com/rolldown/rolldown/tree/main/examples/chunk-import-map)
|
|
2403
|
-
*
|
|
2404
|
-
* @default false
|
|
2405
|
-
*/
|
|
2406
|
-
chunkImportMap?: boolean | {
|
|
2407
|
-
baseUrl?: string;
|
|
2408
|
-
fileName?: string;
|
|
2409
|
-
};
|
|
2410
|
-
/**
|
|
2411
|
-
* Enable on-demand wrapping of modules.
|
|
2412
|
-
* @default false
|
|
2413
|
-
* @hidden not ready for public usage yet
|
|
2414
|
-
*/
|
|
2415
|
-
onDemandWrapping?: boolean;
|
|
2416
|
-
/**
|
|
2417
|
-
* Enable incremental build support. Required to be used with `watch` mode.
|
|
2418
|
-
* @default false
|
|
2419
|
-
*/
|
|
2420
|
-
incrementalBuild?: boolean;
|
|
2421
|
-
/**
|
|
2422
|
-
* Enable high-resolution source maps for transform operations.
|
|
2423
|
-
* @default false
|
|
2424
|
-
*/
|
|
2425
|
-
transformHiresSourcemap?: boolean | "boundary";
|
|
2426
|
-
/**
|
|
2427
|
-
* Use native Rust implementation of MagicString for source map generation.
|
|
2428
|
-
*
|
|
2429
|
-
* [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
|
|
2430
|
-
* for string manipulation and source map generation. When enabled, rolldown will use a native Rust
|
|
2431
|
-
* implementation of MagicString instead of the JavaScript version, providing significantly better performance
|
|
2432
|
-
* during source map generation and code transformation.
|
|
2433
|
-
*
|
|
2434
|
-
* **Benefits**
|
|
2435
|
-
*
|
|
2436
|
-
* - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
|
|
2437
|
-
* especially for large codebases with extensive source maps.
|
|
2438
|
-
* - **Background Processing**: Source map generation is performed asynchronously in a background thread,
|
|
2439
|
-
* allowing the main bundling process to continue without blocking. This parallel processing can significantly
|
|
2440
|
-
* reduce overall build times when working with JavaScript transform hooks.
|
|
2441
|
-
* - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
|
|
2442
|
-
*
|
|
2443
|
-
* @example
|
|
2444
|
-
* ```js
|
|
2445
|
-
* export default {
|
|
2446
|
-
* experimental: {
|
|
2447
|
-
* nativeMagicString: true
|
|
2448
|
-
* },
|
|
2449
|
-
* output: {
|
|
2450
|
-
* sourcemap: true
|
|
2451
|
-
* }
|
|
2452
|
-
* }
|
|
2453
|
-
* ```
|
|
2454
|
-
*
|
|
2455
|
-
* > [!NOTE]
|
|
2456
|
-
* > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
|
|
2457
|
-
* > implementation, there may be edge cases. Please report any discrepancies you encounter.
|
|
2458
|
-
* > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
|
|
2459
|
-
* @default false
|
|
2460
|
-
*/
|
|
2461
|
-
nativeMagicString?: boolean;
|
|
2462
|
-
/**
|
|
2463
|
-
* Control whether to optimize chunks by allowing entry chunks to have different exports than the underlying entry module.
|
|
2464
|
-
* This optimization can reduce the number of generated chunks.
|
|
2465
|
-
*
|
|
2466
|
-
* When enabled, rolldown will try to insert common modules directly into existing chunks rather than creating
|
|
2467
|
-
* separate chunks for them, which can result in fewer output files and better performance.
|
|
2468
|
-
*
|
|
2469
|
-
* This optimization is automatically disabled when any module uses top-level await (TLA) or contains TLA dependencies,
|
|
2470
|
-
* as it could affect execution order guarantees.
|
|
2471
|
-
*
|
|
2472
|
-
* @default true
|
|
2473
|
-
*/
|
|
2474
|
-
chunkOptimization?: boolean;
|
|
2475
|
-
};
|
|
2476
|
-
/**
|
|
2477
|
-
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
2478
|
-
*
|
|
2479
|
-
* @example
|
|
2480
|
-
* **Enable legacy decorators**
|
|
2481
|
-
* ```js
|
|
2482
|
-
* export default defineConfig({
|
|
2483
|
-
* transform: {
|
|
2484
|
-
* decorator: {
|
|
2485
|
-
* legacy: true,
|
|
2486
|
-
* },
|
|
2487
|
-
* },
|
|
2488
|
-
* })
|
|
2489
|
-
* ```
|
|
2490
|
-
* Note that if you have correct `tsconfig.json` file, Rolldown will automatically detect and enable legacy decorators support.
|
|
2491
|
-
*
|
|
2492
|
-
* {@include ./docs/transform.md}
|
|
2493
|
-
*/
|
|
2494
|
-
transform?: TransformOptions;
|
|
2495
|
-
/**
|
|
2496
|
-
* Watch mode related options.
|
|
2497
|
-
*
|
|
2498
|
-
* These options only take effect when running with the `--watch` flag, or using `rolldown.watch()` API.
|
|
2499
|
-
*/
|
|
2500
|
-
watch?: WatcherOptions | false;
|
|
2501
|
-
/**
|
|
2502
|
-
* Controls which warnings are emitted during the build process. Each option can be set to `true` (emit warning) or `false` (suppress warning).
|
|
2503
|
-
*/
|
|
2504
|
-
checks?: ChecksOptions;
|
|
2505
|
-
/**
|
|
2506
|
-
* Determines if absolute external paths should be converted to relative paths in the output.
|
|
2507
|
-
*
|
|
2508
|
-
* This does not only apply to paths that are absolute in the source but also to paths that are resolved to an absolute path by either a plugin or Rolldown core.
|
|
2509
|
-
*
|
|
2510
|
-
* {@include ./docs/make-absolute-externals-relative.md}
|
|
2511
|
-
*/
|
|
2512
|
-
makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
|
|
2513
|
-
/**
|
|
2514
|
-
* Devtools integration options.
|
|
2515
|
-
* @experimental
|
|
2516
|
-
*/
|
|
2517
|
-
devtools?: {
|
|
2518
|
-
sessionId?: string;
|
|
2519
|
-
};
|
|
2520
|
-
/**
|
|
2521
|
-
* Controls how entry chunk exports are preserved.
|
|
2522
|
-
*
|
|
2523
|
-
* This determines whether Rolldown needs to create facade chunks (additional wrapper chunks) to maintain the exact export signatures of entry modules, or whether it can combine entry modules with other chunks for optimization.
|
|
2524
|
-
*
|
|
2525
|
-
* @default `'exports-only'`
|
|
2526
|
-
* {@include ./docs/preserve-entry-signatures.md}
|
|
2527
|
-
*/
|
|
2528
|
-
preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
|
|
2529
|
-
/**
|
|
2530
|
-
* Configure optimization features for the bundler.
|
|
2531
|
-
*/
|
|
2532
|
-
optimization?: OptimizationOptions;
|
|
2533
|
-
/**
|
|
2534
|
-
* The value of `this` at the top level of each module. **Normally, you don't need to set this option.**
|
|
2535
|
-
* @default undefined
|
|
2536
|
-
* @example
|
|
2537
|
-
* **Set custom context**
|
|
2538
|
-
* ```js
|
|
2539
|
-
* export default {
|
|
2540
|
-
* context: 'globalThis',
|
|
2541
|
-
* output: {
|
|
2542
|
-
* format: 'iife',
|
|
2543
|
-
* },
|
|
2544
|
-
* };
|
|
2545
|
-
* ```
|
|
2546
|
-
* {@include ./docs/context.md}
|
|
2547
|
-
*/
|
|
2548
|
-
context?: string;
|
|
2549
|
-
/**
|
|
2550
|
-
* Configures TypeScript configuration file resolution and usage.
|
|
2551
|
-
* {@include ./docs/tsconfig.md}
|
|
2552
|
-
* @default true
|
|
2553
|
-
*/
|
|
2554
|
-
tsconfig?: boolean | string;
|
|
2555
|
-
}
|
|
2556
|
-
//#endregion
|
|
2557
|
-
//#region src/types/rolldown-options.d.ts
|
|
2558
|
-
interface RolldownOptions extends InputOptions {
|
|
2559
|
-
output?: OutputOptions | OutputOptions[];
|
|
2560
|
-
}
|
|
2561
|
-
//#endregion
|
|
2562
|
-
//#region src/utils/define-config.d.ts
|
|
2563
|
-
/**
|
|
2564
|
-
* Type for `default export` of `rolldown.config.js` file.
|
|
2565
|
-
*/
|
|
2566
|
-
type ConfigExport = RolldownOptions | RolldownOptions[] | RolldownOptionsFunction;
|
|
2567
|
-
type RolldownOptionsFunction = (commandLineArguments: Record<string, any>) => MaybePromise<RolldownOptions | RolldownOptions[]>;
|
|
2568
|
-
declare function defineConfig(config: RolldownOptions): RolldownOptions;
|
|
2569
|
-
declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
2570
|
-
declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
|
|
2571
|
-
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
2572
|
-
//#endregion
|
|
2573
|
-
export { RolldownFileStats as $, TransformResult as A, StringOrRegExp as At, EmittedFile as B, Plugin as C, GlobalsFunction as Ct, RolldownPlugin as D, PreRenderedAsset as Dt, ResolvedId as E, OutputOptions as Et, SourceMapInput as F, RolldownOutput as Ft, defineParallelPlugin as G, GetModuleInfo as H, OutputBundle as I, SourceMap as It, GeneralHookFilter as J, MinimalPluginContext as K, TreeshakingOptions as L, freeExternalMemory as Lt, BuiltinPlugin as M, OutputChunk as Mt, VERSION as N, RenderedChunk as Nt, RolldownPluginOption as O, MaybePromise as Ot, ExistingRawSourceMap as P, RenderedModule as Pt, RolldownDirectoryEntry as Q, TransformPluginContext as R, ModuleInfo as Rt, PartialResolvedId as S, GeneratedCodePreset as St, ResolveIdResult as T, ModuleFormat as Tt, PluginContext as U, EmittedPrebuiltChunk as V, DefineParallelPluginResult as W, ModuleTypeFilter as X, HookFilter as Y, BufferEncoding as Z, LoadResult as _, AdvancedChunksGroup as _t, ExternalOption as a, ChecksOptions as at, ObjectHook as b, CodeSplittingGroup as bt, InputOptions as c, watch as ct, WatcherOptions as d, WatchOptions as dt, RolldownFsModule as et, AsyncPluginHooks as f, rolldown as ft, ImportKind as g, AddonFunction as gt, HookFilterExtension as h, build as ht, RolldownOptions as i, TransformOptions as it, withFilter as j, OutputAsset as jt, SourceDescription as k, PartialNull as kt, ModuleTypes as l, RolldownWatcher as lt, FunctionPluginHooks as m, BuildOptions as mt, RolldownOptionsFunction as n, NormalizedOutputOptions as nt, ExternalOptionFunction as o, LoggingFunction as ot, CustomPluginOptions as p, RolldownBuild as pt, PluginContextMeta as q, defineConfig as r, NormalizedInputOptions as rt, InputOption as s, WarningHandlerWithDefault as st, ConfigExport as t, InternalModuleFormat as tt, OptimizationOptions as u, RolldownWatcherEvent as ut, ModuleOptions as v, ChunkFileNamesFunction as vt, ResolveIdExtraOptions as w, MinifyOptions as wt, ParallelPluginHooks as x, GeneratedCodeOptions as xt, ModuleType as y, ChunkingContext as yt, EmittedAsset as z, SourcemapIgnoreListOption as zt };
|