@rolldown/browser 1.0.0-beta.58 → 1.0.0-beta.60
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.mjs +32 -32
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +7 -7
- package/dist/{constructors-BuqTjXTF.js → constructors-CPMzz58l.js} +2 -8
- package/dist/experimental-index.browser.mjs +18 -37
- package/dist/experimental-index.d.mts +17 -63
- package/dist/experimental-index.mjs +20 -39
- package/dist/experimental-runtime-types.d.ts +6 -2
- package/dist/filter-index.d.mts +1 -1
- package/dist/filter-index.mjs +1 -2
- package/dist/get-log-filter.d.mts +1 -1
- package/dist/index.browser.mjs +6 -6
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +11 -11
- package/dist/normalize-string-or-regex-DcX5TPjK.js +247 -0
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/plugins-index.browser.mjs +2 -2
- package/dist/plugins-index.d.mts +3 -3
- package/dist/plugins-index.mjs +2 -2
- package/dist/rolldown-binding.wasi-browser.js +0 -1
- package/dist/rolldown-binding.wasi.cjs +0 -1
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/{rolldown-build-CRqas5jO.js → rolldown-build-Zb6e1FlF.js} +661 -80
- package/dist/shared/{binding-MAEzB4KA.d.mts → binding-CAB1xlCZ.d.mts} +58 -134
- package/dist/shared/{bindingify-input-options--qcSYuhh.mjs → bindingify-input-options-C4xVxTKf.mjs} +602 -51
- package/dist/shared/{composable-filters-C5qA4jo-.mjs → composable-filters-DmVadxLf.mjs} +41 -20
- package/dist/shared/{constructors-CQP6o3cR.d.mts → constructors-D_KDVVwY.d.mts} +3 -5
- package/dist/shared/{constructors-kOch67Sb.mjs → constructors-KqJrL3Ok.mjs} +2 -8
- package/dist/shared/{define-config-yInAJbA1.d.mts → define-config-CUEbSpq4.d.mts} +967 -408
- package/dist/shared/{load-config-BZhApFJg.mjs → load-config-DN8SQL2o.mjs} +1 -1
- package/dist/shared/{logging-B4x9qar8.d.mts → logging-DGAQcdLz.d.mts} +4 -0
- package/dist/shared/{logs-DEfpOy5A.mjs → logs-cXucB9vK.mjs} +8 -8
- package/dist/shared/normalize-string-or-regex-Bn5eoSii.mjs +60 -0
- package/dist/shared/{parse-ast-index-CgzK6cxG.mjs → parse-ast-index-B54CTqgh.mjs} +2 -2
- package/dist/shared/{prompt-CNt8OM9C.mjs → prompt-D80rO-gq.mjs} +220 -220
- package/dist/shared/{rolldown-Vl5SnJ_J.mjs → rolldown-BhEWsQWt.mjs} +1 -1
- package/dist/shared/{rolldown-build-7kWB1jqY.mjs → rolldown-build-PEQvqPGC.mjs} +48 -36
- package/dist/shared/{utils-BGxZdOXA.d.mts → utils-0UHbNgk4.d.mts} +2 -11
- package/dist/shared/{watch-CGYro6go.mjs → watch-avpeg13R.mjs} +11 -12
- package/package.json +1 -1
- package/dist/normalize-string-or-regex-3ql5-z8-.js +0 -872
- package/dist/shared/misc-BubmxcE3.mjs +0 -22
- package/dist/shared/normalize-string-or-regex-CIiT1lMg.mjs +0 -669
- /package/dist/shared/{define-config-BF4P-Pum.mjs → define-config-DrUTwApf.mjs} +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
1
|
+
import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-DGAQcdLz.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, w as BindingWatcherEvent } from "./binding-CAB1xlCZ.mjs";
|
|
3
|
+
import { a as NullValue, i as MaybePromise, n as MakeAsync, o as PartialNull, r as MaybeArray, s as StringOrRegExp, t as BuiltinPlugin } from "./utils-0UHbNgk4.mjs";
|
|
4
4
|
import { Program } from "@oxc-project/types";
|
|
5
5
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
6
6
|
|
|
7
7
|
//#region src/types/misc.d.ts
|
|
8
|
+
/** @inline */
|
|
8
9
|
type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
|
|
10
|
+
/** @inline */
|
|
9
11
|
type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
|
|
10
12
|
//#endregion
|
|
11
13
|
//#region src/types/module-info.d.ts
|
|
@@ -111,7 +113,14 @@ interface RenderedModule {
|
|
|
111
113
|
renderedLength: number;
|
|
112
114
|
renderedExports: string[];
|
|
113
115
|
}
|
|
114
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* The information about the chunk being rendered.
|
|
118
|
+
*
|
|
119
|
+
* Unlike {@link OutputChunk}, `code` and `map` are not set as the chunk has not been rendered yet.
|
|
120
|
+
* All referenced chunk file names in each property that would contain hashes will contain hash placeholders instead.
|
|
121
|
+
*
|
|
122
|
+
* @category Plugin APIs
|
|
123
|
+
*/
|
|
115
124
|
interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
|
|
116
125
|
type: "chunk";
|
|
117
126
|
modules: {
|
|
@@ -173,6 +182,8 @@ interface GeneratedCodeOptions {
|
|
|
173
182
|
* }
|
|
174
183
|
* };
|
|
175
184
|
* ```
|
|
185
|
+
*
|
|
186
|
+
* @default 'es2015'
|
|
176
187
|
*/
|
|
177
188
|
preset?: GeneratedCodePreset;
|
|
178
189
|
/**
|
|
@@ -181,15 +192,19 @@ interface GeneratedCodeOptions {
|
|
|
181
192
|
* When enabled, generated code will use descriptive variable names that correspond
|
|
182
193
|
* to the original module names, making it easier to profile and debug the bundled code.
|
|
183
194
|
*
|
|
184
|
-
* Note: Enabling this option makes the output more difficult to minify effectively.
|
|
185
|
-
*
|
|
186
195
|
* @default false
|
|
196
|
+
*
|
|
197
|
+
* {@include ./docs/output-generated-code-profiler-names.md}
|
|
187
198
|
*/
|
|
188
199
|
profilerNames?: boolean;
|
|
189
200
|
}
|
|
201
|
+
/** @inline */
|
|
190
202
|
type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
|
|
203
|
+
/** @inline */
|
|
191
204
|
type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
205
|
+
/** @inline */
|
|
192
206
|
type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
|
|
207
|
+
/** @inline */
|
|
193
208
|
type SanitizeFileNameFunction = (name: string) => string;
|
|
194
209
|
/** @category Plugin APIs */
|
|
195
210
|
interface PreRenderedAsset {
|
|
@@ -200,25 +215,60 @@ interface PreRenderedAsset {
|
|
|
200
215
|
originalFileNames: string[];
|
|
201
216
|
source: string | Uint8Array;
|
|
202
217
|
}
|
|
218
|
+
/** @inline */
|
|
203
219
|
type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
|
|
220
|
+
/** @inline */
|
|
204
221
|
type PathsFunction$1 = (id: string) => string;
|
|
222
|
+
/** @inline */
|
|
205
223
|
type ManualChunksFunction = (moduleId: string, meta: {
|
|
206
224
|
getModuleInfo: (moduleId: string) => ModuleInfo | null;
|
|
207
225
|
}) => string | NullValue;
|
|
226
|
+
/** @inline */
|
|
208
227
|
type GlobalsFunction = (name: string) => string;
|
|
228
|
+
/** @inline */
|
|
209
229
|
type AdvancedChunksNameFunction = (moduleId: string, ctx: ChunkingContext) => string | NullValue;
|
|
230
|
+
/** @inline */
|
|
210
231
|
type AdvancedChunksTestFunction = (id: string) => boolean | undefined | void;
|
|
211
232
|
type MinifyOptions = Omit<MinifyOptions$1, "module" | "sourcemap">;
|
|
212
233
|
interface ChunkingContext {
|
|
213
234
|
getModuleInfo(moduleId: string): ModuleInfo | null;
|
|
214
235
|
}
|
|
215
236
|
interface OutputOptions {
|
|
237
|
+
/**
|
|
238
|
+
* The directory in which all generated chunks are placed.
|
|
239
|
+
*
|
|
240
|
+
* The {@linkcode file | output.file} option should be used instead if only a single chunk is generated.
|
|
241
|
+
*
|
|
242
|
+
* @default 'dist'
|
|
243
|
+
*/
|
|
216
244
|
dir?: string;
|
|
245
|
+
/**
|
|
246
|
+
* The file path for the single generated chunk.
|
|
247
|
+
*
|
|
248
|
+
* The {@linkcode dir | output.dir} option should be used instead if multiple chunks are generated.
|
|
249
|
+
*/
|
|
217
250
|
file?: string;
|
|
251
|
+
/**
|
|
252
|
+
* Which exports mode to use.
|
|
253
|
+
*
|
|
254
|
+
* {@include ./docs/output-exports.md}
|
|
255
|
+
*
|
|
256
|
+
* @default 'auto'
|
|
257
|
+
*/
|
|
218
258
|
exports?: "auto" | "named" | "default" | "none";
|
|
259
|
+
/**
|
|
260
|
+
* Specify the character set that Rolldown is allowed to use in file hashes.
|
|
261
|
+
*
|
|
262
|
+
* - `'base64'`: Uses url-safe base64 characters (0-9, a-z, A-Z, -, _). This will produce the shortest hashes.
|
|
263
|
+
* - `'base36'`: Uses alphanumeric characters (0-9, a-z)
|
|
264
|
+
* - `'hex'`: Uses hexadecimal characters (0-9, a-f)
|
|
265
|
+
*
|
|
266
|
+
* @default 'base64'
|
|
267
|
+
*/
|
|
219
268
|
hashCharacters?: "base64" | "base36" | "hex";
|
|
220
269
|
/**
|
|
221
270
|
* Expected format of generated code.
|
|
271
|
+
*
|
|
222
272
|
* - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
|
|
223
273
|
* - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
|
|
224
274
|
* - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
|
|
@@ -227,25 +277,48 @@ interface OutputOptions {
|
|
|
227
277
|
* @default 'esm'
|
|
228
278
|
*/
|
|
229
279
|
format?: ModuleFormat;
|
|
280
|
+
/**
|
|
281
|
+
* Whether to generate sourcemaps.
|
|
282
|
+
*
|
|
283
|
+
* - `false`: No sourcemap will be generated.
|
|
284
|
+
* - `true`: A separate sourcemap file will be generated.
|
|
285
|
+
* - `'inline'`: The sourcemap will be appended to the output file as a data URL.
|
|
286
|
+
* - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (`//# sourceMappingURL` comment) will not be included in the output file.
|
|
287
|
+
*
|
|
288
|
+
* @default false
|
|
289
|
+
*/
|
|
230
290
|
sourcemap?: boolean | "inline" | "hidden";
|
|
291
|
+
/**
|
|
292
|
+
* The base URL for the links to the sourcemap file in the output file.
|
|
293
|
+
*
|
|
294
|
+
* 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.
|
|
295
|
+
*/
|
|
231
296
|
sourcemapBaseUrl?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
|
|
299
|
+
*
|
|
300
|
+
* When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
|
|
301
|
+
*
|
|
302
|
+
* @default false
|
|
303
|
+
*/
|
|
232
304
|
sourcemapDebugIds?: boolean;
|
|
233
305
|
/**
|
|
234
306
|
* Control which source files are included in the sourcemap ignore list.
|
|
307
|
+
*
|
|
235
308
|
* Files in the ignore list are excluded from debugger stepping and error stack traces.
|
|
236
309
|
*
|
|
237
|
-
* - `false`: Include
|
|
238
|
-
* - `true`: Include
|
|
310
|
+
* - `false`: Include no source files in the ignore list
|
|
311
|
+
* - `true`: Include all source files in the ignore list
|
|
239
312
|
* - `string`: Files containing this string in their path will be included in the ignore list
|
|
240
313
|
* - `RegExp`: Files matching this regular expression will be included in the ignore list
|
|
241
|
-
* - `function`: Custom function
|
|
314
|
+
* - `function`: Custom function to determine if a source should be ignored
|
|
242
315
|
*
|
|
243
316
|
* :::tip Performance
|
|
244
317
|
* Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
|
|
245
318
|
* Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
|
|
246
319
|
* :::
|
|
247
320
|
*
|
|
248
|
-
*
|
|
321
|
+
* @example
|
|
249
322
|
* ```js
|
|
250
323
|
* // ✅ Preferred: Use RegExp for better performance
|
|
251
324
|
* sourcemapIgnoreList: /node_modules/
|
|
@@ -259,29 +332,152 @@ interface OutputOptions {
|
|
|
259
332
|
* }
|
|
260
333
|
* ```
|
|
261
334
|
*
|
|
262
|
-
*
|
|
335
|
+
* @default /node_modules/
|
|
263
336
|
*/
|
|
264
337
|
sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption | StringOrRegExp;
|
|
338
|
+
/**
|
|
339
|
+
* A transformation to apply to each path in a sourcemap.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```js
|
|
343
|
+
* export default defineConfig({
|
|
344
|
+
* output: {
|
|
345
|
+
* sourcemap: true,
|
|
346
|
+
* sourcemapPathTransform: (source, sourcemapPath) => {
|
|
347
|
+
* // Remove 'src/' prefix from all source paths
|
|
348
|
+
* return source.replace(/^src\//, '');
|
|
349
|
+
* },
|
|
350
|
+
* },
|
|
351
|
+
* });
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
265
354
|
sourcemapPathTransform?: SourcemapPathTransformOption;
|
|
355
|
+
/**
|
|
356
|
+
* A string to prepend to the bundle before `renderChunk` hook.
|
|
357
|
+
*
|
|
358
|
+
* See {@linkcode intro | output.intro}, {@linkcode postBanner | output.postBanner} as well.
|
|
359
|
+
*
|
|
360
|
+
* {@include ./docs/output-banner.md}
|
|
361
|
+
*/
|
|
266
362
|
banner?: string | AddonFunction;
|
|
363
|
+
/**
|
|
364
|
+
* A string to append to the bundle before `renderChunk` hook.
|
|
365
|
+
*
|
|
366
|
+
* See {@linkcode outro | output.outro}, {@linkcode postFooter | output.postFooter} as well.
|
|
367
|
+
*
|
|
368
|
+
* {@include ./docs/output-footer.md}
|
|
369
|
+
*/
|
|
267
370
|
footer?: string | AddonFunction;
|
|
268
371
|
/**
|
|
269
|
-
*
|
|
372
|
+
* A string to prepend to the bundle after `renderChunk` hook and minification.
|
|
373
|
+
*
|
|
374
|
+
* See {@linkcode banner | output.banner}, {@linkcode intro | output.intro} as well.
|
|
270
375
|
*/
|
|
271
376
|
postBanner?: string | AddonFunction;
|
|
272
377
|
/**
|
|
273
|
-
*
|
|
378
|
+
* A string to append to the bundle after `renderChunk` hook and minification.
|
|
379
|
+
*
|
|
380
|
+
* See {@linkcode footer | output.footer}, {@linkcode outro | output.outro} as well.
|
|
274
381
|
*/
|
|
275
382
|
postFooter?: string | AddonFunction;
|
|
383
|
+
/**
|
|
384
|
+
* A string to prepend inside any format-specific wrapper.
|
|
385
|
+
*
|
|
386
|
+
* See {@linkcode banner | output.banner}, {@linkcode postBanner | output.postBanner} as well.
|
|
387
|
+
*/
|
|
276
388
|
intro?: string | AddonFunction;
|
|
389
|
+
/**
|
|
390
|
+
* A string to append inside any format-specific wrapper.
|
|
391
|
+
*
|
|
392
|
+
* See {@linkcode footer | output.footer}, {@linkcode postFooter | output.postFooter} as well.
|
|
393
|
+
*/
|
|
277
394
|
outro?: string | AddonFunction;
|
|
395
|
+
/**
|
|
396
|
+
* Whether to extend the global variable defined by the {@linkcode OutputOptions.name | name} option in `umd` or `iife` formats.
|
|
397
|
+
*
|
|
398
|
+
* When `true`, the global variable will be defined as `global.name = global.name || {}`.
|
|
399
|
+
* When `false`, the global defined by name will be overwritten like `global.name = {}`.
|
|
400
|
+
*
|
|
401
|
+
* @default false
|
|
402
|
+
*/
|
|
278
403
|
extend?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Whether to add a `__esModule: true` property when generating exports for non-ES formats.
|
|
406
|
+
*
|
|
407
|
+
* 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.
|
|
408
|
+
*
|
|
409
|
+
* - `true`: Always add the property when using named exports mode, which is similar to what other tools do.
|
|
410
|
+
* - `"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`.
|
|
411
|
+
* - `false`: Never add the property even if the default export would become a property `.default`.
|
|
412
|
+
*
|
|
413
|
+
* @default 'if-default-prop'
|
|
414
|
+
*/
|
|
279
415
|
esModule?: boolean | "if-default-prop";
|
|
416
|
+
/**
|
|
417
|
+
* 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.
|
|
418
|
+
*
|
|
419
|
+
* Patterns support the following placeholders:
|
|
420
|
+
* - `[extname]`: The file extension of the asset including a leading dot, e.g. `.css`.
|
|
421
|
+
* - `[ext]`: The file extension without a leading dot, e.g. css.
|
|
422
|
+
* - `[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}.
|
|
423
|
+
* - `[name]`: The file name of the asset excluding any extension.
|
|
424
|
+
*
|
|
425
|
+
* Forward slashes (`/`) can be used to place files in sub-directories.
|
|
426
|
+
*
|
|
427
|
+
* See also {@linkcode chunkFileNames | output.chunkFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
|
|
428
|
+
*
|
|
429
|
+
* @default 'assets/[name]-[hash][extname]'
|
|
430
|
+
*/
|
|
280
431
|
assetFileNames?: string | AssetFileNamesFunction;
|
|
432
|
+
/**
|
|
433
|
+
* The pattern to use for chunks created from entry points, or a function that is called per entry chunk to return such a pattern.
|
|
434
|
+
*
|
|
435
|
+
* Patterns support the following placeholders:
|
|
436
|
+
* - `[format]`: The rendering format defined in the output options, e.g. `es` or `cjs`.
|
|
437
|
+
* - `[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}.
|
|
438
|
+
* - `[name]`: The file name (without extension) of the entry point, unless the object form of input was used to define a different name.
|
|
439
|
+
*
|
|
440
|
+
* 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.
|
|
441
|
+
*
|
|
442
|
+
* See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode chunkFileNames | output.chunkFileNames}.
|
|
443
|
+
*
|
|
444
|
+
* @default '[name].js'
|
|
445
|
+
*/
|
|
281
446
|
entryFileNames?: string | ChunkFileNamesFunction;
|
|
447
|
+
/**
|
|
448
|
+
* 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.
|
|
449
|
+
*
|
|
450
|
+
* Patterns support the following placeholders:
|
|
451
|
+
* - `[format]`: The rendering format defined in the output options, e.g. `es` or `cjs`.
|
|
452
|
+
* - `[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}.
|
|
453
|
+
* - `[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.
|
|
454
|
+
*
|
|
455
|
+
* Forward slashes (`/`) can be used to place files in sub-directories.
|
|
456
|
+
*
|
|
457
|
+
* See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode entryFileNames | output.entryFileNames}.
|
|
458
|
+
*
|
|
459
|
+
* @default '[name]-[hash].js'
|
|
460
|
+
*/
|
|
282
461
|
chunkFileNames?: string | ChunkFileNamesFunction;
|
|
462
|
+
/**
|
|
463
|
+
* @default '[name].css'
|
|
464
|
+
* @experimental
|
|
465
|
+
* @hidden not ready for public usage yet
|
|
466
|
+
*/
|
|
283
467
|
cssEntryFileNames?: string | ChunkFileNamesFunction;
|
|
468
|
+
/**
|
|
469
|
+
* @default '[name]-[hash].css'
|
|
470
|
+
* @experimental
|
|
471
|
+
* @hidden not ready for public usage yet
|
|
472
|
+
*/
|
|
284
473
|
cssChunkFileNames?: string | ChunkFileNamesFunction;
|
|
474
|
+
/**
|
|
475
|
+
* Whether to enable chunk name sanitization (removal of non-URL-safe characters like `\0`, `?` and `*`).
|
|
476
|
+
*
|
|
477
|
+
* Set `false` to disable the sanitization. You can also provide a custom sanitization function.
|
|
478
|
+
*
|
|
479
|
+
* @default true
|
|
480
|
+
*/
|
|
285
481
|
sanitizeFileName?: boolean | SanitizeFileNameFunction;
|
|
286
482
|
/**
|
|
287
483
|
* Control code minification.
|
|
@@ -294,7 +490,55 @@ interface OutputOptions {
|
|
|
294
490
|
* @default false
|
|
295
491
|
*/
|
|
296
492
|
minify?: boolean | "dce-only" | MinifyOptions;
|
|
493
|
+
/**
|
|
494
|
+
* Specifies the global variable name that contains the exports of `umd` / `iife` bundles.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```js
|
|
498
|
+
* export default defineConfig({
|
|
499
|
+
* output: {
|
|
500
|
+
* format: 'iife',
|
|
501
|
+
* name: 'MyBundle',
|
|
502
|
+
* }
|
|
503
|
+
* });
|
|
504
|
+
* ```
|
|
505
|
+
* ```js
|
|
506
|
+
* // output
|
|
507
|
+
* var MyBundle = (function () {
|
|
508
|
+
* // ...
|
|
509
|
+
* })();
|
|
510
|
+
* ```
|
|
511
|
+
*
|
|
512
|
+
* {@include ./docs/output-name.md}
|
|
513
|
+
*/
|
|
297
514
|
name?: string;
|
|
515
|
+
/**
|
|
516
|
+
* Specifies `id: variableName` pairs necessary for external imports in `umd` / `iife` bundles.
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```js
|
|
520
|
+
* export default defineConfig({
|
|
521
|
+
* external: ['jquery'],
|
|
522
|
+
* output: {
|
|
523
|
+
* format: 'iife',
|
|
524
|
+
* name: 'MyBundle',
|
|
525
|
+
* globals: {
|
|
526
|
+
* jquery: '$',
|
|
527
|
+
* }
|
|
528
|
+
* }
|
|
529
|
+
* });
|
|
530
|
+
* ```
|
|
531
|
+
* ```js
|
|
532
|
+
* // input
|
|
533
|
+
* import $ from 'jquery';
|
|
534
|
+
* ```
|
|
535
|
+
* ```js
|
|
536
|
+
* // output
|
|
537
|
+
* var MyBundle = (function ($) {
|
|
538
|
+
* // ...
|
|
539
|
+
* })($);
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
298
542
|
globals?: Record<string, string> | GlobalsFunction;
|
|
299
543
|
/**
|
|
300
544
|
* Maps external module IDs to paths.
|
|
@@ -327,18 +571,43 @@ interface OutputOptions {
|
|
|
327
571
|
* ```
|
|
328
572
|
*/
|
|
329
573
|
paths?: Record<string, string> | PathsFunction$1;
|
|
574
|
+
/**
|
|
575
|
+
* Which language features Rolldown can safely use in generated code.
|
|
576
|
+
*
|
|
577
|
+
* This will not transpile any user code but only change the code Rolldown uses in wrappers and helpers.
|
|
578
|
+
*/
|
|
330
579
|
generatedCode?: Partial<GeneratedCodeOptions>;
|
|
580
|
+
/**
|
|
581
|
+
* Whether to generate code to support live bindings for external imports.
|
|
582
|
+
*
|
|
583
|
+
* With the default value of `true`, Rolldown will generate code to support live bindings for external imports.
|
|
584
|
+
*
|
|
585
|
+
* 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.
|
|
586
|
+
*
|
|
587
|
+
* @default true
|
|
588
|
+
*
|
|
589
|
+
* {@include ./docs/output-external-live-bindings.md}
|
|
590
|
+
*/
|
|
331
591
|
externalLiveBindings?: boolean;
|
|
592
|
+
/**
|
|
593
|
+
* Whether to inline dynamic imports instead of creating new chunks to create a single bundle.
|
|
594
|
+
*
|
|
595
|
+
* This option can be used only when a single input is provided.
|
|
596
|
+
*
|
|
597
|
+
* @default false
|
|
598
|
+
*/
|
|
332
599
|
inlineDynamicImports?: boolean;
|
|
333
|
-
dynamicImportInCjs?: boolean;
|
|
334
600
|
/**
|
|
335
|
-
*
|
|
336
|
-
* - Object form is not supported.
|
|
601
|
+
* Whether to keep external dynamic imports as `import(...)` expressions in CommonJS output.
|
|
337
602
|
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
603
|
+
* If set to `false`, external dynamic imports will be rewritten to use `require(...)` calls.
|
|
604
|
+
* This may be necessary to support environments that do not support dynamic `import()` in CommonJS modules like old Node.js versions.
|
|
605
|
+
*
|
|
606
|
+
* @default true
|
|
607
|
+
*/
|
|
608
|
+
dynamicImportInCjs?: boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Allows you to do manual chunking. Provided for Rollup compatibility.
|
|
342
611
|
*
|
|
343
612
|
* You could use this option for migration purpose. Under the hood,
|
|
344
613
|
*
|
|
@@ -357,7 +626,7 @@ interface OutputOptions {
|
|
|
357
626
|
*
|
|
358
627
|
* ```js
|
|
359
628
|
* {
|
|
360
|
-
*
|
|
629
|
+
* codeSplitting: {
|
|
361
630
|
* groups: [
|
|
362
631
|
* {
|
|
363
632
|
* name(moduleId) {
|
|
@@ -373,199 +642,93 @@ interface OutputOptions {
|
|
|
373
642
|
*
|
|
374
643
|
* ```
|
|
375
644
|
*
|
|
376
|
-
*
|
|
645
|
+
* Note that unlike Rollup, object form is not supported.
|
|
646
|
+
*
|
|
647
|
+
* @deprecated
|
|
648
|
+
* Please use {@linkcode codeSplitting | output.codeSplitting} instead.
|
|
649
|
+
*
|
|
650
|
+
* :::warning
|
|
651
|
+
* If `manualChunks` and `codeSplitting` are both specified, `manualChunks` option will be ignored.
|
|
652
|
+
* :::
|
|
377
653
|
*/
|
|
378
654
|
manualChunks?: ManualChunksFunction;
|
|
379
655
|
/**
|
|
380
656
|
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/advanced-chunks).
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* **Basic vendor chunk**
|
|
660
|
+
* ```js
|
|
661
|
+
* export default defineConfig({
|
|
662
|
+
* output: {
|
|
663
|
+
* codeSplitting: {
|
|
664
|
+
* minSize: 20000,
|
|
665
|
+
* groups: [
|
|
666
|
+
* {
|
|
667
|
+
* name: 'vendor',
|
|
668
|
+
* test: /node_modules/,
|
|
669
|
+
* },
|
|
670
|
+
* ],
|
|
671
|
+
* },
|
|
672
|
+
* },
|
|
673
|
+
* });
|
|
674
|
+
* ```
|
|
675
|
+
* {@include ./docs/output-advanced-chunks.md}
|
|
381
676
|
*/
|
|
382
|
-
|
|
677
|
+
codeSplitting?: {
|
|
383
678
|
/**
|
|
384
|
-
* - Type: `boolean`
|
|
385
|
-
* - Default: `true`
|
|
386
|
-
*
|
|
387
679
|
* By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
|
|
388
680
|
*
|
|
389
681
|
* If you want to disable this behavior, it's recommended to both set
|
|
390
|
-
* -
|
|
391
|
-
* - `strictExecutionOrder
|
|
682
|
+
* - {@linkcode InputOptions.preserveEntrySignatures | preserveEntrySignatures}: `false | 'allow-extension'`
|
|
683
|
+
* - `experimental.strictExecutionOrder`: `true`
|
|
392
684
|
*
|
|
393
685
|
* to avoid generating invalid chunks.
|
|
686
|
+
*
|
|
687
|
+
* @default true
|
|
394
688
|
*/
|
|
395
689
|
includeDependenciesRecursively?: boolean;
|
|
396
690
|
/**
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
* Global fallback of [`{group}.minSize`](#advancedchunks-groups-minsize), if it's not specified in the group.
|
|
691
|
+
* Global fallback of {@linkcode CodeSplittingGroup.minSize | group.minSize}, if it's not specified in the group.
|
|
400
692
|
*/
|
|
401
693
|
minSize?: number;
|
|
402
694
|
/**
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* Global fallback of [`{group}.maxSize`](#advancedchunks-groups-maxsize), if it's not specified in the group.
|
|
695
|
+
* Global fallback of {@linkcode CodeSplittingGroup.maxSize | group.maxSize}, if it's not specified in the group.
|
|
406
696
|
*/
|
|
407
697
|
maxSize?: number;
|
|
408
698
|
/**
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
* Global fallback of [`{group}.maxModuleSize`](#advancedchunks-groups-maxmodulesize), if it's not specified in the group.
|
|
699
|
+
* Global fallback of {@linkcode CodeSplittingGroup.maxModuleSize | group.maxModuleSize}, if it's not specified in the group.
|
|
412
700
|
*/
|
|
413
701
|
maxModuleSize?: number;
|
|
414
702
|
/**
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* Global fallback of [`{group}.minModuleSize`](#advancedchunks-groups-minmodulesize), if it's not specified in the group.
|
|
703
|
+
* Global fallback of {@linkcode CodeSplittingGroup.minModuleSize | group.minModuleSize}, if it's not specified in the group.
|
|
418
704
|
*/
|
|
419
705
|
minModuleSize?: number;
|
|
420
706
|
/**
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
* Global fallback of [`{group}.minShareCount`](#advancedchunks-groups-minsharecount), if it's not specified in the group.
|
|
707
|
+
* Global fallback of {@linkcode CodeSplittingGroup.minShareCount | group.minShareCount}, if it's not specified in the group.
|
|
424
708
|
*/
|
|
425
709
|
minShareCount?: number;
|
|
426
710
|
/**
|
|
427
|
-
* Groups to be used for
|
|
711
|
+
* Groups to be used for code splitting.
|
|
428
712
|
*/
|
|
429
|
-
groups?:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
* },
|
|
449
|
-
* });
|
|
450
|
-
* ```
|
|
451
|
-
* will create a chunk named `libs-[hash].js` in the end.
|
|
452
|
-
*
|
|
453
|
-
* It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
|
|
454
|
-
*
|
|
455
|
-
* # Dynamic `name()`
|
|
456
|
-
*
|
|
457
|
-
* 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.
|
|
458
|
-
*
|
|
459
|
-
* Notice, each returned new name will be treated as a separate group.
|
|
460
|
-
*
|
|
461
|
-
* For example,
|
|
462
|
-
*
|
|
463
|
-
* ```js
|
|
464
|
-
* import { defineConfig } from 'rolldown';
|
|
465
|
-
*
|
|
466
|
-
* export default defineConfig({
|
|
467
|
-
* advancedChunks: {
|
|
468
|
-
* groups: [
|
|
469
|
-
* {
|
|
470
|
-
* name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
|
|
471
|
-
* minSize: 100 * 1024,
|
|
472
|
-
* },
|
|
473
|
-
* ],
|
|
474
|
-
* },
|
|
475
|
-
* });
|
|
476
|
-
* ```
|
|
477
|
-
*
|
|
478
|
-
* :::warning
|
|
479
|
-
* Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
|
|
480
|
-
* :::
|
|
481
|
-
*/
|
|
482
|
-
name: string | AdvancedChunksNameFunction;
|
|
483
|
-
/**
|
|
484
|
-
* - Type: `string | RegExp | ((id: string) => boolean | undefined | void);`
|
|
485
|
-
*
|
|
486
|
-
* Controls which modules are captured in this group.
|
|
487
|
-
*
|
|
488
|
-
* - If `test` is a string, the module whose id contains the string will be captured.
|
|
489
|
-
* - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
490
|
-
* - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
491
|
-
* - If `test` is empty, any module will be considered as matched.
|
|
492
|
-
*
|
|
493
|
-
* :::warning
|
|
494
|
-
* When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
|
|
495
|
-
* - ✅ Recommended: `/node_modules[\\/]react/`
|
|
496
|
-
* - ❌ Not recommended: `/node_modules/react/`
|
|
497
|
-
* :::
|
|
498
|
-
*/
|
|
499
|
-
test?: StringOrRegExp | AdvancedChunksTestFunction;
|
|
500
|
-
/**
|
|
501
|
-
* - Type: `number`
|
|
502
|
-
* - Default: `0`
|
|
503
|
-
*
|
|
504
|
-
* 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.
|
|
505
|
-
*
|
|
506
|
-
* If two groups have the same priority, the group whose index is smaller will be chosen.
|
|
507
|
-
*
|
|
508
|
-
* For example,
|
|
509
|
-
*
|
|
510
|
-
* ```js
|
|
511
|
-
* import { defineConfig } from 'rolldown';
|
|
512
|
-
*
|
|
513
|
-
* export default defineConfig({
|
|
514
|
-
* advancedChunks: {
|
|
515
|
-
* groups: [
|
|
516
|
-
* {
|
|
517
|
-
* name: 'react',
|
|
518
|
-
* test: /node_modules[\\/]react/,
|
|
519
|
-
* priority: 1,
|
|
520
|
-
* },
|
|
521
|
-
* {
|
|
522
|
-
* name: 'other-libs',
|
|
523
|
-
* test: /node_modules/,
|
|
524
|
-
* priority: 2,
|
|
525
|
-
* },
|
|
526
|
-
* ],
|
|
527
|
-
* });
|
|
528
|
-
* ```
|
|
529
|
-
*
|
|
530
|
-
* This is a clearly __incorrect__ example. Though `react` group is defined before `other-libs`, it has a lower priority, so the modules in `react` group will be captured in `other-libs` group.
|
|
531
|
-
*/
|
|
532
|
-
priority?: number;
|
|
533
|
-
/**
|
|
534
|
-
* - Type: `number`
|
|
535
|
-
* - Default: `0`
|
|
536
|
-
*
|
|
537
|
-
* 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.
|
|
538
|
-
*/
|
|
539
|
-
minSize?: number;
|
|
540
|
-
/**
|
|
541
|
-
* - Type: `number`
|
|
542
|
-
* - Default: `1`
|
|
543
|
-
*
|
|
544
|
-
* Controls if a module should be captured based on how many entry chunks reference it.
|
|
545
|
-
*/
|
|
546
|
-
minShareCount?: number;
|
|
547
|
-
/**
|
|
548
|
-
* - Type: `number`
|
|
549
|
-
* - Default: `Infinity`
|
|
550
|
-
*
|
|
551
|
-
* 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.
|
|
552
|
-
*/
|
|
553
|
-
maxSize?: number;
|
|
554
|
-
/**
|
|
555
|
-
* - Type: `number`
|
|
556
|
-
* - Default: `Infinity`
|
|
557
|
-
*
|
|
558
|
-
* Controls a module could only be captured if its size in bytes is smaller or equal than this value.
|
|
559
|
-
*/
|
|
560
|
-
maxModuleSize?: number;
|
|
561
|
-
/**
|
|
562
|
-
* - Type: `number`
|
|
563
|
-
* - Default: `0`
|
|
564
|
-
*
|
|
565
|
-
* Controls a module could only be captured if its size in bytes is larger or equal than this value.
|
|
566
|
-
*/
|
|
567
|
-
minModuleSize?: number;
|
|
568
|
-
}[];
|
|
713
|
+
groups?: CodeSplittingGroup[];
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* @deprecated Please use {@linkcode codeSplitting | output.codeSplitting} instead.
|
|
717
|
+
*
|
|
718
|
+
* Allows you to do manual chunking.
|
|
719
|
+
*
|
|
720
|
+
* :::warning
|
|
721
|
+
* If `advancedChunks` and `codeSplitting` are both specified, `advancedChunks` option will be ignored.
|
|
722
|
+
* :::
|
|
723
|
+
*/
|
|
724
|
+
advancedChunks?: {
|
|
725
|
+
includeDependenciesRecursively?: boolean;
|
|
726
|
+
minSize?: number;
|
|
727
|
+
maxSize?: number;
|
|
728
|
+
maxModuleSize?: number;
|
|
729
|
+
minModuleSize?: number;
|
|
730
|
+
minShareCount?: number;
|
|
731
|
+
groups?: CodeSplittingGroup[];
|
|
569
732
|
};
|
|
570
733
|
/**
|
|
571
734
|
* Control comments in the output.
|
|
@@ -574,36 +737,212 @@ interface OutputOptions {
|
|
|
574
737
|
* - `inline`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
|
|
575
738
|
*/
|
|
576
739
|
legalComments?: "none" | "inline";
|
|
740
|
+
/**
|
|
741
|
+
* The list of plugins to use only for this output.
|
|
742
|
+
*/
|
|
577
743
|
plugins?: RolldownOutputPluginOption;
|
|
744
|
+
/**
|
|
745
|
+
* Whether to add a polyfill for `require()` function in non-CommonJS formats.
|
|
746
|
+
*
|
|
747
|
+
* This option is useful when you want to inject your own `require` implementation.
|
|
748
|
+
*
|
|
749
|
+
* @default true
|
|
750
|
+
*/
|
|
578
751
|
polyfillRequire?: boolean;
|
|
752
|
+
/**
|
|
753
|
+
* This option is not implemented yet.
|
|
754
|
+
* @hidden
|
|
755
|
+
*/
|
|
579
756
|
hoistTransitiveImports?: false;
|
|
757
|
+
/**
|
|
758
|
+
* Whether to use preserve modules mode.
|
|
759
|
+
*
|
|
760
|
+
* {@include ./docs/output-preserve-modules.md}
|
|
761
|
+
*
|
|
762
|
+
* @default false
|
|
763
|
+
*/
|
|
580
764
|
preserveModules?: boolean;
|
|
765
|
+
/**
|
|
766
|
+
* Specifies the directory name for "virtual" files that might be emitted by plugins when using preserve modules mode.
|
|
767
|
+
*
|
|
768
|
+
* @default '_virtual'
|
|
769
|
+
*/
|
|
581
770
|
virtualDirname?: string;
|
|
771
|
+
/**
|
|
772
|
+
* A directory path to input modules that should be stripped away from {@linkcode dir | output.dir} when using preserve modules mode.
|
|
773
|
+
*
|
|
774
|
+
* {@include ./docs/output-preserve-modules-root.md}
|
|
775
|
+
*/
|
|
582
776
|
preserveModulesRoot?: string;
|
|
777
|
+
/**
|
|
778
|
+
* Whether to use `var` declarations at the top level scope instead of function / class / let / const expressions.
|
|
779
|
+
*
|
|
780
|
+
* Enabling this option can improve runtime performance of the generated code in certain environments.
|
|
781
|
+
*
|
|
782
|
+
* @default false
|
|
783
|
+
*
|
|
784
|
+
* {@include ./docs/output-top-level-var.md}
|
|
785
|
+
*/
|
|
583
786
|
topLevelVar?: boolean;
|
|
584
787
|
/**
|
|
585
|
-
*
|
|
586
|
-
*
|
|
788
|
+
* Whether to minify internal exports as single letter variables to allow for better minification.
|
|
789
|
+
*
|
|
790
|
+
* @default
|
|
791
|
+
* `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
|
|
587
792
|
*
|
|
588
|
-
*
|
|
793
|
+
* {@include ./docs/output-minify-internal-exports.md}
|
|
589
794
|
*/
|
|
590
795
|
minifyInternalExports?: boolean;
|
|
591
796
|
/**
|
|
592
|
-
*
|
|
593
|
-
* - Default: `false`
|
|
797
|
+
* Clean output directory ({@linkcode dir | output.dir}) before emitting output.
|
|
594
798
|
*
|
|
595
|
-
*
|
|
799
|
+
* @default false
|
|
800
|
+
*
|
|
801
|
+
* {@include ./docs/output-clean-dir.md}
|
|
596
802
|
*/
|
|
597
803
|
cleanDir?: boolean;
|
|
598
|
-
/**
|
|
804
|
+
/**
|
|
805
|
+
* Keep `name` property of functions and classes after bundling.
|
|
599
806
|
*
|
|
600
|
-
* When enabled, the bundler will preserve the original
|
|
601
|
-
* in the output
|
|
807
|
+
* When enabled, the bundler will preserve the original `name` property value of functions and
|
|
808
|
+
* classes in the output. This is useful for debugging and some frameworks that rely on it for
|
|
809
|
+
* registration and binding purposes.
|
|
602
810
|
*
|
|
603
811
|
* @default false
|
|
604
812
|
*/
|
|
605
813
|
keepNames?: boolean;
|
|
606
814
|
}
|
|
815
|
+
type CodeSplittingGroup = {
|
|
816
|
+
/**
|
|
817
|
+
* 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.
|
|
818
|
+
*
|
|
819
|
+
* For example,
|
|
820
|
+
*
|
|
821
|
+
* ```js
|
|
822
|
+
* import { defineConfig } from 'rolldown';
|
|
823
|
+
*
|
|
824
|
+
* export default defineConfig({
|
|
825
|
+
* advancedChunks: {
|
|
826
|
+
* groups: [
|
|
827
|
+
* {
|
|
828
|
+
* name: 'libs',
|
|
829
|
+
* test: /node_modules/,
|
|
830
|
+
* },
|
|
831
|
+
* ],
|
|
832
|
+
* },
|
|
833
|
+
* });
|
|
834
|
+
* ```
|
|
835
|
+
* will create a chunk named `libs-[hash].js` in the end.
|
|
836
|
+
*
|
|
837
|
+
* It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
|
|
838
|
+
*
|
|
839
|
+
* #### Dynamic `name()`
|
|
840
|
+
*
|
|
841
|
+
* 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.
|
|
842
|
+
*
|
|
843
|
+
* Notice, each returned new name will be treated as a separate group.
|
|
844
|
+
*
|
|
845
|
+
* For example,
|
|
846
|
+
*
|
|
847
|
+
* ```js
|
|
848
|
+
* import { defineConfig } from 'rolldown';
|
|
849
|
+
*
|
|
850
|
+
* export default defineConfig({
|
|
851
|
+
* advancedChunks: {
|
|
852
|
+
* groups: [
|
|
853
|
+
* {
|
|
854
|
+
* name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
|
|
855
|
+
* minSize: 100 * 1024,
|
|
856
|
+
* },
|
|
857
|
+
* ],
|
|
858
|
+
* },
|
|
859
|
+
* });
|
|
860
|
+
* ```
|
|
861
|
+
*
|
|
862
|
+
* :::warning
|
|
863
|
+
* Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
|
|
864
|
+
* :::
|
|
865
|
+
*/
|
|
866
|
+
name: string | AdvancedChunksNameFunction;
|
|
867
|
+
/**
|
|
868
|
+
* Controls which modules are captured in this group.
|
|
869
|
+
*
|
|
870
|
+
* - If `test` is a string, the module whose id contains the string will be captured.
|
|
871
|
+
* - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
872
|
+
* - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
873
|
+
* - If `test` is empty, any module will be considered as matched.
|
|
874
|
+
*
|
|
875
|
+
* :::warning
|
|
876
|
+
* When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
|
|
877
|
+
* - ✅ Recommended: `/node_modules[\\/]react/`
|
|
878
|
+
* - ❌ Not recommended: `/node_modules/react/`
|
|
879
|
+
* :::
|
|
880
|
+
*/
|
|
881
|
+
test?: StringOrRegExp | AdvancedChunksTestFunction;
|
|
882
|
+
/**
|
|
883
|
+
* 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.
|
|
884
|
+
*
|
|
885
|
+
* If two groups have the same priority, the group whose index is smaller will be chosen.
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* ```js
|
|
889
|
+
* import { defineConfig } from 'rolldown';
|
|
890
|
+
*
|
|
891
|
+
* export default defineConfig({
|
|
892
|
+
* advancedChunks: {
|
|
893
|
+
* groups: [
|
|
894
|
+
* {
|
|
895
|
+
* name: 'react',
|
|
896
|
+
* test: /node_modules[\\/]react/,
|
|
897
|
+
* priority: 2,
|
|
898
|
+
* },
|
|
899
|
+
* {
|
|
900
|
+
* name: 'other-libs',
|
|
901
|
+
* test: /node_modules/,
|
|
902
|
+
* priority: 1,
|
|
903
|
+
* },
|
|
904
|
+
* ],
|
|
905
|
+
* });
|
|
906
|
+
* ```
|
|
907
|
+
*
|
|
908
|
+
* @default 0
|
|
909
|
+
*/
|
|
910
|
+
priority?: number;
|
|
911
|
+
/**
|
|
912
|
+
* 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.
|
|
913
|
+
*
|
|
914
|
+
* @default 0
|
|
915
|
+
*/
|
|
916
|
+
minSize?: number;
|
|
917
|
+
/**
|
|
918
|
+
* Controls if a module should be captured based on how many entry chunks reference it.
|
|
919
|
+
*
|
|
920
|
+
* @default 1
|
|
921
|
+
*/
|
|
922
|
+
minShareCount?: number;
|
|
923
|
+
/**
|
|
924
|
+
* 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.
|
|
925
|
+
*
|
|
926
|
+
* @default Infinity
|
|
927
|
+
*/
|
|
928
|
+
maxSize?: number;
|
|
929
|
+
/**
|
|
930
|
+
* Controls whether a module can only be captured if its size in bytes is smaller than or equal to this value.
|
|
931
|
+
*
|
|
932
|
+
* @default Infinity
|
|
933
|
+
*/
|
|
934
|
+
maxModuleSize?: number;
|
|
935
|
+
/**
|
|
936
|
+
* Controls whether a module can only be captured if its size in bytes is larger than or equal to this value.
|
|
937
|
+
*
|
|
938
|
+
* @default 0
|
|
939
|
+
*/
|
|
940
|
+
minModuleSize?: number;
|
|
941
|
+
};
|
|
942
|
+
/**
|
|
943
|
+
* Alias for {@linkcode CodeSplittingGroup}. Use this type for the `codeSplitting.groups` option.
|
|
944
|
+
*/
|
|
945
|
+
type AdvancedChunksGroup = CodeSplittingGroup;
|
|
607
946
|
//#endregion
|
|
608
947
|
//#region src/api/build.d.ts
|
|
609
948
|
interface BuildOptions extends InputOptions {
|
|
@@ -691,88 +1030,234 @@ type RolldownWatcher = WatcherEmitter;
|
|
|
691
1030
|
/** @category Programmatic APIs */
|
|
692
1031
|
declare const watch: (input: WatchOptions | WatchOptions[]) => RolldownWatcher;
|
|
693
1032
|
//#endregion
|
|
1033
|
+
//#region src/log/log-handler.d.ts
|
|
1034
|
+
type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
|
|
1035
|
+
type LoggingFunctionWithPosition = (log: RollupLog | string | (() => RollupLog | string), pos?: number | {
|
|
1036
|
+
column: number;
|
|
1037
|
+
line: number;
|
|
1038
|
+
}) => void;
|
|
1039
|
+
type WarningHandlerWithDefault = (warning: RollupLog, defaultHandler: LoggingFunction) => void;
|
|
1040
|
+
//#endregion
|
|
694
1041
|
//#region src/options/generated/checks-options.d.ts
|
|
695
1042
|
interface ChecksOptions {
|
|
696
1043
|
/**
|
|
697
|
-
* Whether to emit
|
|
1044
|
+
* Whether to emit warnings when detecting circular dependency
|
|
1045
|
+
*
|
|
1046
|
+
* Circular dependencies lead to a bigger bundle size and sometimes cause execution order issues and are better to avoid.
|
|
698
1047
|
* @default false
|
|
699
1048
|
* */
|
|
700
1049
|
circularDependency?: boolean;
|
|
701
1050
|
/**
|
|
702
|
-
* Whether to emit
|
|
1051
|
+
* Whether to emit warnings when detecting uses of direct `eval`s
|
|
1052
|
+
*
|
|
1053
|
+
* See [Avoiding Direct `eval` in Troubleshooting page](https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval) for more details.
|
|
703
1054
|
* @default true
|
|
704
1055
|
* */
|
|
705
1056
|
eval?: boolean;
|
|
706
1057
|
/**
|
|
707
|
-
* Whether to emit
|
|
1058
|
+
* Whether to emit warnings when the `output.globals` option is missing when needed
|
|
1059
|
+
*
|
|
1060
|
+
* See [`output.globals`](https://rolldown.rs/reference/OutputOptions.globals).
|
|
708
1061
|
* @default true
|
|
709
1062
|
* */
|
|
710
1063
|
missingGlobalName?: boolean;
|
|
711
1064
|
/**
|
|
712
|
-
* Whether to emit
|
|
1065
|
+
* Whether to emit warnings when the `output.name` option is missing when needed
|
|
1066
|
+
*
|
|
1067
|
+
* See [`output.name`](https://rolldown.rs/reference/OutputOptions.name).
|
|
713
1068
|
* @default true
|
|
714
1069
|
* */
|
|
715
1070
|
missingNameOptionForIifeExport?: boolean;
|
|
716
1071
|
/**
|
|
717
|
-
* Whether to emit
|
|
1072
|
+
* Whether to emit warnings when the way to export values is ambiguous
|
|
1073
|
+
*
|
|
1074
|
+
* See [`output.exports`](https://rolldown.rs/reference/OutputOptions.exports).
|
|
718
1075
|
* @default true
|
|
719
1076
|
* */
|
|
720
1077
|
mixedExports?: boolean;
|
|
721
1078
|
/**
|
|
722
|
-
* Whether to emit
|
|
1079
|
+
* Whether to emit warnings when an entrypoint cannot be resolved
|
|
723
1080
|
* @default true
|
|
724
1081
|
* */
|
|
725
1082
|
unresolvedEntry?: boolean;
|
|
726
1083
|
/**
|
|
727
|
-
* Whether to emit
|
|
1084
|
+
* Whether to emit warnings when an import cannot be resolved
|
|
728
1085
|
* @default true
|
|
729
1086
|
* */
|
|
730
1087
|
unresolvedImport?: boolean;
|
|
731
1088
|
/**
|
|
732
|
-
* Whether to emit
|
|
1089
|
+
* Whether to emit warnings when files generated have the same name with different contents
|
|
733
1090
|
* @default true
|
|
734
1091
|
* */
|
|
735
1092
|
filenameConflict?: boolean;
|
|
736
1093
|
/**
|
|
737
|
-
* Whether to emit
|
|
1094
|
+
* Whether to emit warnings when a CommonJS variable is used in an ES module
|
|
1095
|
+
*
|
|
1096
|
+
* CommonJS variables like `module` and `exports` are treated as global variables in ES modules and may not work as expected.
|
|
738
1097
|
* @default true
|
|
739
1098
|
* */
|
|
740
1099
|
commonJsVariableInEsm?: boolean;
|
|
741
1100
|
/**
|
|
742
|
-
* Whether to emit
|
|
1101
|
+
* Whether to emit warnings when an imported variable is not exported
|
|
1102
|
+
*
|
|
1103
|
+
* 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.
|
|
743
1104
|
* @default true
|
|
744
1105
|
* */
|
|
745
1106
|
importIsUndefined?: boolean;
|
|
746
1107
|
/**
|
|
747
|
-
* Whether to emit
|
|
1108
|
+
* Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`)
|
|
1109
|
+
*
|
|
1110
|
+
* See [`import.meta` in Non-ESM Output Formats page](https://rolldown.rs/in-depth/non-esm-output-formats#import-meta) for more details.
|
|
748
1111
|
* @default true
|
|
749
1112
|
* */
|
|
750
1113
|
emptyImportMeta?: boolean;
|
|
751
1114
|
/**
|
|
752
|
-
* Whether to emit
|
|
1115
|
+
* Whether to emit warnings when detecting tolerated transform
|
|
1116
|
+
* @default true
|
|
1117
|
+
* */
|
|
1118
|
+
toleratedTransform?: boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* Whether to emit warnings when a namespace is called as a function
|
|
1121
|
+
*
|
|
1122
|
+
* A module namespace object is an object and not a function. Calling it as a function will cause a runtime error.
|
|
753
1123
|
* @default true
|
|
754
1124
|
* */
|
|
755
1125
|
cannotCallNamespace?: boolean;
|
|
756
1126
|
/**
|
|
757
|
-
* Whether to emit
|
|
1127
|
+
* Whether to emit warnings when a config value is overridden by another config value with a higher priority
|
|
758
1128
|
* @default true
|
|
759
1129
|
* */
|
|
760
1130
|
configurationFieldConflict?: boolean;
|
|
761
1131
|
/**
|
|
762
|
-
* Whether to emit
|
|
1132
|
+
* Whether to emit warnings when a plugin that is covered by a built-in feature is used
|
|
1133
|
+
*
|
|
1134
|
+
* Using built-in features is generally more performant than using plugins.
|
|
763
1135
|
* @default true
|
|
764
1136
|
* */
|
|
765
1137
|
preferBuiltinFeature?: boolean;
|
|
766
1138
|
/**
|
|
767
|
-
* Whether to emit
|
|
1139
|
+
* Whether to emit warnings when Rolldown could not clean the output directory
|
|
1140
|
+
*
|
|
1141
|
+
* See [`output.cleanDir`](https://rolldown.rs/reference/OutputOptions.cleanDir).
|
|
768
1142
|
* @default true
|
|
769
1143
|
* */
|
|
770
1144
|
couldNotCleanDirectory?: boolean;
|
|
771
1145
|
/**
|
|
772
|
-
* Whether to emit
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
|
|
1146
|
+
* Whether to emit warnings when plugins take significant time during the build process
|
|
1147
|
+
*
|
|
1148
|
+
* {@include ../docs/checks-plugin-timings.md}
|
|
1149
|
+
* @default true
|
|
1150
|
+
* */
|
|
1151
|
+
pluginTimings?: boolean;
|
|
1152
|
+
}
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region src/options/transform-options.d.ts
|
|
1155
|
+
interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
|
|
1156
|
+
/**
|
|
1157
|
+
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* **Replace the global variable `IS_PROD` with `true`**
|
|
1161
|
+
* ```js rolldown.config.js
|
|
1162
|
+
* export default defineConfig({
|
|
1163
|
+
* transform: { define: { IS_PROD: 'true' } }
|
|
1164
|
+
* })
|
|
1165
|
+
* ```
|
|
1166
|
+
* Result:
|
|
1167
|
+
* ```js
|
|
1168
|
+
* // Input
|
|
1169
|
+
* if (IS_PROD) {
|
|
1170
|
+
* console.log('Production mode')
|
|
1171
|
+
* }
|
|
1172
|
+
*
|
|
1173
|
+
* // After bundling
|
|
1174
|
+
* if (true) {
|
|
1175
|
+
* console.log('Production mode')
|
|
1176
|
+
* }
|
|
1177
|
+
* ```
|
|
1178
|
+
*
|
|
1179
|
+
* **Replace the property accessor `process.env.NODE_ENV` with `'production'`**
|
|
1180
|
+
* ```js rolldown.config.js
|
|
1181
|
+
* export default defineConfig({
|
|
1182
|
+
* transform: { define: { 'process.env.NODE_ENV': "'production'" } }
|
|
1183
|
+
* })
|
|
1184
|
+
* ```
|
|
1185
|
+
* Result:
|
|
1186
|
+
* ```js
|
|
1187
|
+
* // Input
|
|
1188
|
+
* if (process.env.NODE_ENV === 'production') {
|
|
1189
|
+
* console.log('Production mode')
|
|
1190
|
+
* }
|
|
1191
|
+
*
|
|
1192
|
+
* // After bundling
|
|
1193
|
+
* if ('production' === 'production') {
|
|
1194
|
+
* console.log('Production mode')
|
|
1195
|
+
* }
|
|
1196
|
+
* ```
|
|
1197
|
+
*/
|
|
1198
|
+
define?: Record<string, string>;
|
|
1199
|
+
/**
|
|
1200
|
+
* Inject import statements on demand.
|
|
1201
|
+
*
|
|
1202
|
+
* The API is aligned with `@rollup/plugin-inject`.
|
|
1203
|
+
*
|
|
1204
|
+
* #### Supported patterns
|
|
1205
|
+
* ```js
|
|
1206
|
+
* {
|
|
1207
|
+
* // import { Promise } from 'es6-promise'
|
|
1208
|
+
* Promise: ['es6-promise', 'Promise'],
|
|
1209
|
+
*
|
|
1210
|
+
* // import { Promise as P } from 'es6-promise'
|
|
1211
|
+
* P: ['es6-promise', 'Promise'],
|
|
1212
|
+
*
|
|
1213
|
+
* // import $ from 'jquery'
|
|
1214
|
+
* $: 'jquery',
|
|
1215
|
+
*
|
|
1216
|
+
* // import * as fs from 'node:fs'
|
|
1217
|
+
* fs: ['node:fs', '*'],
|
|
1218
|
+
*
|
|
1219
|
+
* // Inject shims for property access pattern
|
|
1220
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1221
|
+
* }
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
inject?: Record<string, string | [string, string]>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Remove labeled statements with these label names.
|
|
1227
|
+
*
|
|
1228
|
+
* Labeled statements are JavaScript statements prefixed with a label identifier.
|
|
1229
|
+
* This option allows you to strip specific labeled statements from the output,
|
|
1230
|
+
* which is useful for removing debug-only code in production builds.
|
|
1231
|
+
*
|
|
1232
|
+
* @example
|
|
1233
|
+
* ```js rolldown.config.js
|
|
1234
|
+
* export default defineConfig({
|
|
1235
|
+
* transform: { dropLabels: ['DEBUG', 'DEV'] }
|
|
1236
|
+
* })
|
|
1237
|
+
* ```
|
|
1238
|
+
* Result:
|
|
1239
|
+
* ```js
|
|
1240
|
+
* // Input
|
|
1241
|
+
* DEBUG: console.log('Debug info');
|
|
1242
|
+
* DEV: {
|
|
1243
|
+
* console.log('Development mode');
|
|
1244
|
+
* }
|
|
1245
|
+
* console.log('Production code');
|
|
1246
|
+
*
|
|
1247
|
+
* // After bundling
|
|
1248
|
+
* console.log('Production code');
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
dropLabels?: string[];
|
|
1252
|
+
/**
|
|
1253
|
+
* Controls how JSX syntax is transformed.
|
|
1254
|
+
*
|
|
1255
|
+
* - If set to `false`, an error will be thrown if JSX syntax is encountered.
|
|
1256
|
+
* - If set to `'react'`, JSX syntax will be transformed to classic runtime React code.
|
|
1257
|
+
* - If set to `'react-jsx'`, JSX syntax will be transformed to automatic runtime React code.
|
|
1258
|
+
* - If set to `'preserve'`, JSX syntax will be preserved as-is.
|
|
1259
|
+
*/
|
|
1260
|
+
jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
|
|
776
1261
|
}
|
|
777
1262
|
//#endregion
|
|
778
1263
|
//#region src/options/normalized-input-options.d.ts
|
|
@@ -1113,16 +1598,22 @@ type TreeshakingOptions = {
|
|
|
1113
1598
|
* - **Polyfills**: Add specific polyfill modules to the array
|
|
1114
1599
|
* - **Plugins**: Modules that register themselves globally on import
|
|
1115
1600
|
* - **Library development**: Set to `false` for libraries where unused exports should be removed
|
|
1601
|
+
*
|
|
1116
1602
|
* @default true
|
|
1117
1603
|
*/
|
|
1118
1604
|
moduleSideEffects?: ModuleSideEffectsOption;
|
|
1119
1605
|
/**
|
|
1120
1606
|
* Whether to respect `/*@__PURE__*\/` annotations and other tree-shaking hints in the code.
|
|
1607
|
+
*
|
|
1608
|
+
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#pure-annotations) for more details.
|
|
1609
|
+
*
|
|
1121
1610
|
* @default true
|
|
1122
1611
|
*/
|
|
1123
1612
|
annotations?: boolean;
|
|
1124
1613
|
/**
|
|
1125
|
-
* Array of function names that should be considered pure (no side effects) even if they can't be automatically detected as pure
|
|
1614
|
+
* Array of function names that should be considered pure (no side effects) even if they can't be automatically detected as pure.
|
|
1615
|
+
*
|
|
1616
|
+
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#define-pure-functions) for more details.
|
|
1126
1617
|
*
|
|
1127
1618
|
* @example
|
|
1128
1619
|
* ```js
|
|
@@ -1135,6 +1626,9 @@ type TreeshakingOptions = {
|
|
|
1135
1626
|
manualPureFunctions?: readonly string[];
|
|
1136
1627
|
/**
|
|
1137
1628
|
* Whether to assume that accessing unknown global properties might have side effects.
|
|
1629
|
+
*
|
|
1630
|
+
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-global-variable-access-side-effects) for more details.
|
|
1631
|
+
*
|
|
1138
1632
|
* @default true
|
|
1139
1633
|
*/
|
|
1140
1634
|
unknownGlobalSideEffects?: boolean;
|
|
@@ -1158,12 +1652,20 @@ type TreeshakingOptions = {
|
|
|
1158
1652
|
*/
|
|
1159
1653
|
commonjs?: boolean;
|
|
1160
1654
|
/**
|
|
1161
|
-
* Controls whether reading properties from objects is considered to have side effects.
|
|
1162
|
-
*
|
|
1655
|
+
* Controls whether reading properties from objects is considered to have side effects.
|
|
1656
|
+
*
|
|
1657
|
+
* Set to `false` for more aggressive tree-shaking behavior.
|
|
1658
|
+
*
|
|
1659
|
+
* See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-property-read-side-effects) for more details.
|
|
1660
|
+
*
|
|
1661
|
+
* @default 'always'
|
|
1163
1662
|
*/
|
|
1164
1663
|
propertyReadSideEffects?: false | "always";
|
|
1165
1664
|
/**
|
|
1166
|
-
* Controls whether writing properties to objects is considered to have side effects.
|
|
1665
|
+
* Controls whether writing properties to objects is considered to have side effects.
|
|
1666
|
+
*
|
|
1667
|
+
* Set to `false` for more aggressive behavior.
|
|
1668
|
+
*
|
|
1167
1669
|
* @default 'always'
|
|
1168
1670
|
*/
|
|
1169
1671
|
propertyWriteSideEffects?: false | "always";
|
|
@@ -1175,9 +1677,6 @@ interface OutputBundle {
|
|
|
1175
1677
|
[fileName: string]: OutputAsset | OutputChunk;
|
|
1176
1678
|
}
|
|
1177
1679
|
//#endregion
|
|
1178
|
-
//#region src/types/rolldown-options-function.d.ts
|
|
1179
|
-
type RolldownOptionsFunction = (commandLineArguments: Record<string, any>) => MaybePromise<RolldownOptions | RolldownOptions[]>;
|
|
1180
|
-
//#endregion
|
|
1181
1680
|
//#region src/types/sourcemap.d.ts
|
|
1182
1681
|
/** @category Plugin APIs */
|
|
1183
1682
|
interface ExistingRawSourceMap {
|
|
@@ -1311,7 +1810,7 @@ interface FunctionPluginHooks {
|
|
|
1311
1810
|
[DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
|
|
1312
1811
|
[DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
|
|
1313
1812
|
[DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
|
|
1314
|
-
[DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
|
|
1813
|
+
[DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext, error?: Error) => void;
|
|
1315
1814
|
[DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
|
|
1316
1815
|
event: ChangeEvent;
|
|
1317
1816
|
}) => void;
|
|
@@ -1336,15 +1835,15 @@ type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle"
|
|
|
1336
1835
|
/** @internal */
|
|
1337
1836
|
type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
1338
1837
|
/** @category Plugin APIs */
|
|
1339
|
-
type HookFilterExtension<K
|
|
1838
|
+
type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
|
|
1340
1839
|
filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
|
|
1341
|
-
} : K
|
|
1840
|
+
} : K extends "load" ? {
|
|
1342
1841
|
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
|
|
1343
|
-
} : K
|
|
1842
|
+
} : K extends "resolveId" ? {
|
|
1344
1843
|
filter?: TUnionWithTopLevelFilterExpressionArray<{
|
|
1345
1844
|
id?: GeneralHookFilter<RegExp>;
|
|
1346
1845
|
}>;
|
|
1347
|
-
} : K
|
|
1846
|
+
} : K extends "renderChunk" ? {
|
|
1348
1847
|
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
|
|
1349
1848
|
} : {};
|
|
1350
1849
|
type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
|
|
@@ -1373,129 +1872,122 @@ type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> |
|
|
|
1373
1872
|
name: string;
|
|
1374
1873
|
} | false | RolldownOutputPluginOption[]>;
|
|
1375
1874
|
//#endregion
|
|
1376
|
-
//#region src/options/
|
|
1377
|
-
|
|
1875
|
+
//#region src/options/input-options.d.ts
|
|
1876
|
+
/**
|
|
1877
|
+
* @inline
|
|
1878
|
+
*/
|
|
1879
|
+
type InputOption = string | string[] | Record<string, string>;
|
|
1880
|
+
/**
|
|
1881
|
+
* @param id The id of the module being checked.
|
|
1882
|
+
* @param parentId The id of the module importing the id being checked.
|
|
1883
|
+
* @param isResolved Whether the id has been resolved.
|
|
1884
|
+
* @returns Whether the module should be treated as external.
|
|
1885
|
+
*/
|
|
1886
|
+
type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
|
|
1887
|
+
/** @inline */
|
|
1888
|
+
type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
|
|
1889
|
+
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
1890
|
+
interface WatcherOptions {
|
|
1378
1891
|
/**
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
* export default defineConfig({ transform: { define: { IS_PROD: 'true' } } })
|
|
1387
|
-
* ```
|
|
1388
|
-
*
|
|
1389
|
-
* Result:
|
|
1390
|
-
*
|
|
1391
|
-
* ```js
|
|
1392
|
-
* // Input
|
|
1393
|
-
* if (IS_PROD) {
|
|
1394
|
-
* console.log('Production mode')
|
|
1395
|
-
* }
|
|
1396
|
-
*
|
|
1397
|
-
* // After bundling
|
|
1398
|
-
* if (true) {
|
|
1399
|
-
* console.log('Production mode')
|
|
1400
|
-
* }
|
|
1401
|
-
* ```
|
|
1892
|
+
* Whether to skip the `bundle.write()` step when a rebuild is triggered.
|
|
1893
|
+
* @default false
|
|
1894
|
+
*/
|
|
1895
|
+
skipWrite?: boolean;
|
|
1896
|
+
/**
|
|
1897
|
+
* Configures how long Rolldown will wait for further changes until it triggers
|
|
1898
|
+
* a rebuild in milliseconds.
|
|
1402
1899
|
*
|
|
1403
|
-
*
|
|
1900
|
+
* Even if this value is set to 0, there's a small debounce timeout configured
|
|
1901
|
+
* in the file system watcher. Setting this to a value greater than 0 will mean
|
|
1902
|
+
* that Rolldown will only trigger a rebuild if there was no change for the
|
|
1903
|
+
* configured number of milliseconds. If several configurations are watched,
|
|
1904
|
+
* Rolldown will use the largest configured build delay.
|
|
1404
1905
|
*
|
|
1405
|
-
*
|
|
1406
|
-
|
|
1407
|
-
|
|
1906
|
+
* @default 0
|
|
1907
|
+
*/
|
|
1908
|
+
buildDelay?: number;
|
|
1909
|
+
/**
|
|
1910
|
+
* An optional object of options that will be passed to the [notify](https://github.com/rolldown/notify) file watcher.
|
|
1911
|
+
*/
|
|
1912
|
+
notify?: {
|
|
1913
|
+
/**
|
|
1914
|
+
* Interval between each re-scan attempt in milliseconds.
|
|
1915
|
+
*
|
|
1916
|
+
* This option is only used when polling backend is used.
|
|
1917
|
+
*
|
|
1918
|
+
* @default 30_000
|
|
1919
|
+
*/
|
|
1920
|
+
pollInterval?: number;
|
|
1921
|
+
/**
|
|
1922
|
+
* Whether to compare file contents when checking for changes.
|
|
1923
|
+
*
|
|
1924
|
+
* This is especially important for pseudo filesystems like those on Linux
|
|
1925
|
+
* under `/sys` and `/proc` which are not obligated to respect any other
|
|
1926
|
+
* filesystem norms such as modification timestamps, file sizes, etc. By
|
|
1927
|
+
* enabling this feature, performance will be significantly impacted as
|
|
1928
|
+
* all files will need to be read and hashed at each interval.
|
|
1929
|
+
*
|
|
1930
|
+
* This option is only used when polling backend is used.
|
|
1931
|
+
*
|
|
1932
|
+
* @default false
|
|
1933
|
+
*/
|
|
1934
|
+
compareContents?: boolean;
|
|
1935
|
+
};
|
|
1936
|
+
/**
|
|
1937
|
+
* Filter to limit the file-watching to certain files.
|
|
1408
1938
|
*
|
|
1409
|
-
*
|
|
1939
|
+
* Strings are treated as glob patterns.
|
|
1940
|
+
* Note that this only filters the module graph but does not allow adding
|
|
1941
|
+
* additional watch files.
|
|
1410
1942
|
*
|
|
1943
|
+
* @example
|
|
1411
1944
|
* ```js
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
* // After bundling
|
|
1418
|
-
* if ('production' === 'production') {
|
|
1419
|
-
* console.log('Production mode')
|
|
1420
|
-
* }
|
|
1421
|
-
*
|
|
1945
|
+
* export default defineConfig({
|
|
1946
|
+
* watch: {
|
|
1947
|
+
* include: 'src/**',
|
|
1948
|
+
* },
|
|
1949
|
+
* })
|
|
1422
1950
|
* ```
|
|
1951
|
+
* @default []
|
|
1423
1952
|
*/
|
|
1424
|
-
|
|
1953
|
+
include?: StringOrRegExp | StringOrRegExp[];
|
|
1425
1954
|
/**
|
|
1426
|
-
*
|
|
1955
|
+
* Filter to prevent files from being watched.
|
|
1427
1956
|
*
|
|
1428
|
-
*
|
|
1957
|
+
* Strings are treated as glob patterns.
|
|
1429
1958
|
*
|
|
1430
|
-
*
|
|
1959
|
+
* @example
|
|
1431
1960
|
* ```js
|
|
1432
|
-
* {
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1437
|
-
* P: ['es6-promise', 'Promise'],
|
|
1438
|
-
*
|
|
1439
|
-
* // import $ from 'jquery'
|
|
1440
|
-
* $: 'jquery',
|
|
1441
|
-
*
|
|
1442
|
-
* // import * as fs from 'node:fs'
|
|
1443
|
-
* fs: ['node:fs', '*'],
|
|
1444
|
-
*
|
|
1445
|
-
* // Inject shims for property access pattern
|
|
1446
|
-
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1447
|
-
* }
|
|
1961
|
+
* export default defineConfig({
|
|
1962
|
+
* watch: {
|
|
1963
|
+
* exclude: 'node_modules/**',
|
|
1964
|
+
* },
|
|
1965
|
+
* })
|
|
1448
1966
|
* ```
|
|
1967
|
+
* @default []
|
|
1449
1968
|
*/
|
|
1450
|
-
|
|
1969
|
+
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
1451
1970
|
/**
|
|
1452
|
-
*
|
|
1453
|
-
*
|
|
1454
|
-
* Labeled statements are JavaScript statements prefixed with a label identifier.
|
|
1455
|
-
* This option allows you to strip specific labeled statements from the output,
|
|
1456
|
-
* which is useful for removing debug-only code in production builds.
|
|
1457
|
-
*
|
|
1458
|
-
* ## Example
|
|
1459
|
-
*
|
|
1460
|
-
* ```js rolldown.config.js
|
|
1461
|
-
* export default defineConfig({ transform: { dropLabels: ['DEBUG', 'DEV'] } })
|
|
1462
|
-
* ```
|
|
1463
|
-
*
|
|
1464
|
-
* Result:
|
|
1971
|
+
* An optional function that will be called immediately every time
|
|
1972
|
+
* a module changes that is part of the build.
|
|
1465
1973
|
*
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
* console.log('Production code');
|
|
1974
|
+
* This is different from the `watchChange` plugin hook, which is
|
|
1975
|
+
* only called once the running build has finished. This may for
|
|
1976
|
+
* instance be used to prevent additional steps from being performed
|
|
1977
|
+
* if we know another build will be started anyway once the current
|
|
1978
|
+
* build finished. This callback may be called multiple times per
|
|
1979
|
+
* build as it tracks every change.
|
|
1473
1980
|
*
|
|
1474
|
-
*
|
|
1475
|
-
* console.log('Production code');
|
|
1476
|
-
* ```
|
|
1981
|
+
* @param id The id of the changed module.
|
|
1477
1982
|
*/
|
|
1478
|
-
dropLabels?: string[];
|
|
1479
|
-
jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
|
|
1480
|
-
}
|
|
1481
|
-
//#endregion
|
|
1482
|
-
//#region src/options/input-options.d.ts
|
|
1483
|
-
type InputOption = string | string[] | Record<string, string>;
|
|
1484
|
-
type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
|
|
1485
|
-
type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
|
|
1486
|
-
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
1487
|
-
interface WatcherOptions {
|
|
1488
|
-
skipWrite?: boolean;
|
|
1489
|
-
buildDelay?: number;
|
|
1490
|
-
notify?: {
|
|
1491
|
-
pollInterval?: number;
|
|
1492
|
-
compareContents?: boolean;
|
|
1493
|
-
};
|
|
1494
|
-
include?: StringOrRegExp | StringOrRegExp[];
|
|
1495
|
-
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
1496
1983
|
onInvalidate?: (id: string) => void;
|
|
1984
|
+
/**
|
|
1985
|
+
* Whether to clear the screen when a rebuild is triggered.
|
|
1986
|
+
* @default true
|
|
1987
|
+
*/
|
|
1497
1988
|
clearScreen?: boolean;
|
|
1498
1989
|
}
|
|
1990
|
+
/** @inline */
|
|
1499
1991
|
type MakeAbsoluteExternalsRelative = boolean | "ifRelativeSource";
|
|
1500
1992
|
type DevModeOptions = boolean | {
|
|
1501
1993
|
host?: string;
|
|
@@ -1549,28 +2041,50 @@ type OptimizationOptions = {
|
|
|
1549
2041
|
pass?: number;
|
|
1550
2042
|
};
|
|
1551
2043
|
/**
|
|
1552
|
-
* Use PIFE pattern for module wrappers
|
|
2044
|
+
* Use PIFE pattern for module wrappers.
|
|
2045
|
+
*
|
|
2046
|
+
* Enabling this option improves the start up performance of the generated bundle with the cost of a slight increase in bundle size.
|
|
2047
|
+
*
|
|
2048
|
+
* {@include ./docs/optimization-pife-for-module-wrappers.md}
|
|
2049
|
+
*
|
|
2050
|
+
* @default true
|
|
1553
2051
|
*/
|
|
1554
2052
|
pifeForModuleWrappers?: boolean;
|
|
1555
2053
|
};
|
|
2054
|
+
/** @inline */
|
|
1556
2055
|
type AttachDebugOptions = "none" | "simple" | "full";
|
|
2056
|
+
/** @inline */
|
|
1557
2057
|
type ChunkModulesOrder = "exec-order" | "module-id";
|
|
2058
|
+
/** @inline */
|
|
1558
2059
|
type OnLogFunction = (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
|
|
2060
|
+
/** @inline */
|
|
1559
2061
|
type OnwarnFunction = (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
|
|
1560
2062
|
interface InputOptions {
|
|
1561
2063
|
/**
|
|
1562
|
-
* Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the
|
|
2064
|
+
* Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the {@linkcode cwd} option.
|
|
1563
2065
|
* {@include ./docs/input.md}
|
|
1564
2066
|
*/
|
|
1565
2067
|
input?: InputOption;
|
|
2068
|
+
/**
|
|
2069
|
+
* The list of plugins to use.
|
|
2070
|
+
*
|
|
2071
|
+
* 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.
|
|
2072
|
+
*/
|
|
1566
2073
|
plugins?: RolldownPluginOption;
|
|
1567
2074
|
/**
|
|
1568
2075
|
* Specifies which modules should be treated as external and not bundled. External modules will be left as import statements in the output.
|
|
1569
2076
|
* {@include ./docs/external.md}
|
|
1570
2077
|
*/
|
|
1571
2078
|
external?: ExternalOption;
|
|
2079
|
+
/**
|
|
2080
|
+
* Options for built-in module resolution feature.
|
|
2081
|
+
*/
|
|
1572
2082
|
resolve?: {
|
|
1573
2083
|
/**
|
|
2084
|
+
* Substitute one package for another.
|
|
2085
|
+
*
|
|
2086
|
+
* 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.
|
|
2087
|
+
*
|
|
1574
2088
|
* @example
|
|
1575
2089
|
* ```js
|
|
1576
2090
|
* resolve: {
|
|
@@ -1588,13 +2102,28 @@ interface InputOptions {
|
|
|
1588
2102
|
alias?: Record<string, string[] | string | false>;
|
|
1589
2103
|
/**
|
|
1590
2104
|
* Fields in package.json to check for aliased paths.
|
|
2105
|
+
*
|
|
2106
|
+
* This option is expected to be used for `browser` field support.
|
|
2107
|
+
*
|
|
2108
|
+
* @default
|
|
2109
|
+
* - `[['browser']]` for `browser` platform
|
|
2110
|
+
* - `[]` for other platforms
|
|
1591
2111
|
*/
|
|
1592
2112
|
aliasFields?: string[][];
|
|
1593
2113
|
/**
|
|
1594
|
-
* Condition names to use when resolving exports in package.json.
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
2114
|
+
* Condition names to use when resolving exports in package.json.
|
|
2115
|
+
*
|
|
2116
|
+
* @default
|
|
2117
|
+
* Defaults based on platform and import kind:
|
|
2118
|
+
* - `browser` platform
|
|
2119
|
+
* - `["import", "browser", "default"]` for import statements
|
|
2120
|
+
* - `["require", "browser", "default"]` for require() calls
|
|
2121
|
+
* - `node` platform
|
|
2122
|
+
* - `["import", "node", "default"]` for import statements
|
|
2123
|
+
* - `["require", "node", "default"]` for require() calls
|
|
2124
|
+
* - `neutral` platform
|
|
2125
|
+
* - `["import", "default"]` for import statements
|
|
2126
|
+
* - `["require", "default"]` for require() calls
|
|
1598
2127
|
*/
|
|
1599
2128
|
conditionNames?: string[];
|
|
1600
2129
|
/**
|
|
@@ -1606,18 +2135,24 @@ interface InputOptions {
|
|
|
1606
2135
|
extensionAlias?: Record<string, string[]>;
|
|
1607
2136
|
/**
|
|
1608
2137
|
* Fields in package.json to check for exports.
|
|
2138
|
+
*
|
|
2139
|
+
* @default `[['exports']]`
|
|
1609
2140
|
*/
|
|
1610
2141
|
exportsFields?: string[][];
|
|
1611
2142
|
/**
|
|
1612
2143
|
* Extensions to try when resolving files. These are tried in order from first to last.
|
|
1613
|
-
*
|
|
2144
|
+
*
|
|
2145
|
+
* @default `['.tsx', '.ts', '.jsx', '.js', '.json']`
|
|
1614
2146
|
*/
|
|
1615
2147
|
extensions?: string[];
|
|
1616
2148
|
/**
|
|
1617
|
-
* Fields in package.json to check for entry points.
|
|
1618
|
-
*
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
2149
|
+
* Fields in package.json to check for entry points.
|
|
2150
|
+
*
|
|
2151
|
+
* @default
|
|
2152
|
+
* Defaults based on platform:
|
|
2153
|
+
* - `node` platform: `['main', 'module']`
|
|
2154
|
+
* - `browser` platform: `['browser', 'module', 'main']`
|
|
2155
|
+
* - `neutral` platform: `[]`
|
|
1621
2156
|
*/
|
|
1622
2157
|
mainFields?: string[];
|
|
1623
2158
|
/**
|
|
@@ -1636,7 +2171,7 @@ interface InputOptions {
|
|
|
1636
2171
|
*/
|
|
1637
2172
|
symlinks?: boolean;
|
|
1638
2173
|
/**
|
|
1639
|
-
* @deprecated Use the top-level
|
|
2174
|
+
* @deprecated Use the top-level {@linkcode tsconfig} option instead.
|
|
1640
2175
|
*/
|
|
1641
2176
|
tsconfigFilename?: string;
|
|
1642
2177
|
};
|
|
@@ -1654,8 +2189,8 @@ interface InputOptions {
|
|
|
1654
2189
|
* - The conditions setting does not automatically include any platform-specific values.
|
|
1655
2190
|
*
|
|
1656
2191
|
* @default
|
|
1657
|
-
* - 'node' if the format is 'cjs'
|
|
1658
|
-
* - 'browser' for other formats
|
|
2192
|
+
* - `'node'` if the format is `'cjs'`
|
|
2193
|
+
* - `'browser'` for other formats
|
|
1659
2194
|
* {@include ./docs/platform.md}
|
|
1660
2195
|
*/
|
|
1661
2196
|
platform?: "node" | "browser" | "neutral";
|
|
@@ -1666,65 +2201,64 @@ interface InputOptions {
|
|
|
1666
2201
|
*/
|
|
1667
2202
|
shimMissingExports?: boolean;
|
|
1668
2203
|
/**
|
|
1669
|
-
* Controls tree-shaking (dead code elimination).
|
|
2204
|
+
* Controls tree-shaking (dead code elimination).
|
|
2205
|
+
*
|
|
2206
|
+
* When `false`, tree-shaking will be disabled.
|
|
2207
|
+
* When `true`, it is equivalent to setting each options to the default value.
|
|
2208
|
+
*
|
|
1670
2209
|
* @default true
|
|
1671
2210
|
*/
|
|
1672
2211
|
treeshake?: boolean | TreeshakingOptions;
|
|
1673
2212
|
/**
|
|
1674
2213
|
* Controls the verbosity of console logging during the build.
|
|
2214
|
+
*
|
|
2215
|
+
* {@include ./docs/log-level.md}
|
|
2216
|
+
*
|
|
1675
2217
|
* @default 'info'
|
|
1676
2218
|
*/
|
|
1677
2219
|
logLevel?: LogLevelOption;
|
|
1678
2220
|
/**
|
|
1679
|
-
*
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
*
|
|
1684
|
-
* @deprecated
|
|
1685
|
-
* :::: warning Deprecated
|
|
1686
|
-
* This is a legacy API. Consider using `onLog` instead for better control over all log types.
|
|
1687
|
-
* ::: details Migration to `onLog`
|
|
1688
|
-
* To migrate from `onwarn` to `onLog`, check the `level` parameter to filter for
|
|
1689
|
-
* warnings:
|
|
1690
|
-
* ```js
|
|
1691
|
-
* // Before: Using `onwarn`
|
|
1692
|
-
* export default {
|
|
1693
|
-
* onwarn(warning, defaultHandler) {
|
|
1694
|
-
* // Suppress certain warnings
|
|
1695
|
-
* if (warning.code === 'CIRCULAR_DEPENDENCY') return;
|
|
1696
|
-
* // Handle other warnings with default behavior
|
|
1697
|
-
* defaultHandler(warning);
|
|
1698
|
-
* },
|
|
1699
|
-
* };
|
|
1700
|
-
* ```
|
|
2221
|
+
* A function that intercepts log messages. If not supplied, logs are printed to the console.
|
|
2222
|
+
*
|
|
2223
|
+
* {@include ./docs/on-log.md}
|
|
2224
|
+
*
|
|
2225
|
+
* @example
|
|
1701
2226
|
* ```js
|
|
1702
|
-
*
|
|
1703
|
-
* export default {
|
|
2227
|
+
* export default defineConfig({
|
|
1704
2228
|
* onLog(level, log, defaultHandler) {
|
|
1705
|
-
*
|
|
2229
|
+
* if (log.code === 'CIRCULAR_DEPENDENCY') {
|
|
2230
|
+
* return; // Ignore circular dependency warnings
|
|
2231
|
+
* }
|
|
1706
2232
|
* if (level === 'warn') {
|
|
1707
|
-
* //
|
|
1708
|
-
* if (log.code === 'CIRCULAR_DEPENDENCY') return;
|
|
1709
|
-
* // Handle other warnings with default behavior
|
|
1710
|
-
* defaultHandler(level, log);
|
|
2233
|
+
* defaultHandler('error', log); // turn other warnings into errors
|
|
1711
2234
|
* } else {
|
|
1712
|
-
* //
|
|
1713
|
-
* defaultHandler(level, log);
|
|
2235
|
+
* defaultHandler(level, log); // otherwise, just print the log
|
|
1714
2236
|
* }
|
|
1715
|
-
* }
|
|
1716
|
-
* }
|
|
2237
|
+
* }
|
|
2238
|
+
* })
|
|
1717
2239
|
* ```
|
|
1718
|
-
|
|
1719
|
-
|
|
2240
|
+
*/
|
|
2241
|
+
onLog?: OnLogFunction;
|
|
2242
|
+
/**
|
|
2243
|
+
* A function that will intercept warning messages.
|
|
2244
|
+
*
|
|
2245
|
+
* {@include ./docs/on-warn.md}
|
|
2246
|
+
*
|
|
2247
|
+
* @deprecated
|
|
2248
|
+
* This is a legacy API. Consider using {@linkcode onLog} instead for better control over all log types.
|
|
2249
|
+
*
|
|
2250
|
+
* {@include ./docs/on-warn-deprecation.md}
|
|
1720
2251
|
*/
|
|
1721
2252
|
onwarn?: OnwarnFunction;
|
|
1722
2253
|
/**
|
|
1723
|
-
* Maps file patterns to module types, controlling how files are processed.
|
|
2254
|
+
* Maps file patterns to module types, controlling how files are processed.
|
|
2255
|
+
*
|
|
2256
|
+
* This is conceptually similar to esbuild's loader option, allowing you to specify how different file extensions should be handled.
|
|
1724
2257
|
*/
|
|
1725
2258
|
moduleTypes?: ModuleTypes;
|
|
1726
2259
|
/**
|
|
1727
2260
|
* Experimental features that may change in future releases and can introduce behavior change without a major version bump.
|
|
2261
|
+
* @experimental
|
|
1728
2262
|
*/
|
|
1729
2263
|
experimental?: {
|
|
1730
2264
|
/**
|
|
@@ -1738,13 +2272,9 @@ interface InputOptions {
|
|
|
1738
2272
|
*/
|
|
1739
2273
|
strictExecutionOrder?: boolean;
|
|
1740
2274
|
/**
|
|
1741
|
-
* Disable live bindings for exported variables.
|
|
1742
|
-
* @default false
|
|
1743
|
-
*/
|
|
1744
|
-
disableLiveBindings?: boolean;
|
|
1745
|
-
/**
|
|
1746
2275
|
* Enable Vite compatible mode.
|
|
1747
2276
|
* @default false
|
|
2277
|
+
* @hidden This option is only meant to be used by Vite. It is not recommended to use this option directly.
|
|
1748
2278
|
*/
|
|
1749
2279
|
viteMode?: boolean;
|
|
1750
2280
|
/**
|
|
@@ -1774,15 +2304,21 @@ interface InputOptions {
|
|
|
1774
2304
|
* @default false
|
|
1775
2305
|
*/
|
|
1776
2306
|
resolveNewUrlToAsset?: boolean;
|
|
2307
|
+
/**
|
|
2308
|
+
* Dev mode related options.
|
|
2309
|
+
* @hidden not ready for public usage yet
|
|
2310
|
+
*/
|
|
1777
2311
|
devMode?: DevModeOptions;
|
|
1778
2312
|
/**
|
|
1779
|
-
* Control which order should
|
|
2313
|
+
* Control which order should be used when rendering modules in a chunk.
|
|
1780
2314
|
*
|
|
1781
2315
|
* Available options:
|
|
1782
2316
|
* - `exec-order`: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
|
|
1783
2317
|
* - `module-id`: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
|
|
2318
|
+
*
|
|
1784
2319
|
* > [!NOTE]
|
|
1785
|
-
* > 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).
|
|
2320
|
+
* > 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).
|
|
2321
|
+
*
|
|
1786
2322
|
* @default 'exec-order'
|
|
1787
2323
|
*/
|
|
1788
2324
|
chunkModulesOrder?: ChunkModulesOrder;
|
|
@@ -1794,8 +2330,6 @@ interface InputOptions {
|
|
|
1794
2330
|
* - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
|
|
1795
2331
|
* - `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.
|
|
1796
2332
|
*
|
|
1797
|
-
* > [!WARNING]
|
|
1798
|
-
* > You shouldn't use `full` in the production build.
|
|
1799
2333
|
* @default 'simple'
|
|
1800
2334
|
*/
|
|
1801
2335
|
attachDebugInfo?: AttachDebugOptions;
|
|
@@ -1844,6 +2378,7 @@ interface InputOptions {
|
|
|
1844
2378
|
*
|
|
1845
2379
|
* > [!TIP]
|
|
1846
2380
|
* > 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)
|
|
2381
|
+
*
|
|
1847
2382
|
* @default false
|
|
1848
2383
|
*/
|
|
1849
2384
|
chunkImportMap?: boolean | {
|
|
@@ -1853,6 +2388,7 @@ interface InputOptions {
|
|
|
1853
2388
|
/**
|
|
1854
2389
|
* Enable on-demand wrapping of modules.
|
|
1855
2390
|
* @default false
|
|
2391
|
+
* @hidden not ready for public usage yet
|
|
1856
2392
|
*/
|
|
1857
2393
|
onDemandWrapping?: boolean;
|
|
1858
2394
|
/**
|
|
@@ -1901,12 +2437,25 @@ interface InputOptions {
|
|
|
1901
2437
|
* @default false
|
|
1902
2438
|
*/
|
|
1903
2439
|
nativeMagicString?: boolean;
|
|
2440
|
+
/**
|
|
2441
|
+
* Control whether to optimize chunks by allowing entry chunks to have different exports than the underlying entry module.
|
|
2442
|
+
* This optimization can reduce the number of generated chunks.
|
|
2443
|
+
*
|
|
2444
|
+
* When enabled, rolldown will try to insert common modules directly into existing chunks rather than creating
|
|
2445
|
+
* separate chunks for them, which can result in fewer output files and better performance.
|
|
2446
|
+
*
|
|
2447
|
+
* This optimization is automatically disabled when any module uses top-level await (TLA) or contains TLA dependencies,
|
|
2448
|
+
* as it could affect execution order guarantees.
|
|
2449
|
+
*
|
|
2450
|
+
* @default true
|
|
2451
|
+
*/
|
|
2452
|
+
chunkOptimization?: boolean;
|
|
1904
2453
|
};
|
|
1905
2454
|
/**
|
|
1906
2455
|
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
1907
2456
|
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
2457
|
+
* @example
|
|
2458
|
+
* **Enable legacy decorators**
|
|
1910
2459
|
* ```js
|
|
1911
2460
|
* export default defineConfig({
|
|
1912
2461
|
* transform: {
|
|
@@ -1916,22 +2465,42 @@ interface InputOptions {
|
|
|
1916
2465
|
* },
|
|
1917
2466
|
* })
|
|
1918
2467
|
* ```
|
|
2468
|
+
* Note that if you have correct `tsconfig.json` file, Rolldown will automatically detect and enable legacy decorators support.
|
|
1919
2469
|
*
|
|
1920
|
-
*
|
|
2470
|
+
* {@include ./docs/transform.md}
|
|
1921
2471
|
*/
|
|
1922
2472
|
transform?: TransformOptions;
|
|
2473
|
+
/**
|
|
2474
|
+
* Watch mode related options.
|
|
2475
|
+
*
|
|
2476
|
+
* These options only take effect when running with the `--watch` flag, or using `rolldown.watch()` API.
|
|
2477
|
+
*/
|
|
1923
2478
|
watch?: WatcherOptions | false;
|
|
1924
2479
|
/**
|
|
1925
2480
|
* Controls which warnings are emitted during the build process. Each option can be set to `true` (emit warning) or `false` (suppress warning).
|
|
1926
2481
|
*/
|
|
1927
2482
|
checks?: ChecksOptions;
|
|
2483
|
+
/**
|
|
2484
|
+
* Determines if absolute external paths should be converted to relative paths in the output.
|
|
2485
|
+
*
|
|
2486
|
+
* 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.
|
|
2487
|
+
*
|
|
2488
|
+
* {@include ./docs/make-absolute-externals-relative.md}
|
|
2489
|
+
*/
|
|
1928
2490
|
makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
|
|
2491
|
+
/**
|
|
2492
|
+
* Devtools integration options.
|
|
2493
|
+
* @experimental
|
|
2494
|
+
*/
|
|
1929
2495
|
devtools?: {
|
|
1930
2496
|
sessionId?: string;
|
|
1931
2497
|
};
|
|
1932
2498
|
/**
|
|
1933
|
-
* Controls how entry chunk exports are preserved.
|
|
1934
|
-
*
|
|
2499
|
+
* Controls how entry chunk exports are preserved.
|
|
2500
|
+
*
|
|
2501
|
+
* 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.
|
|
2502
|
+
*
|
|
2503
|
+
* @default `'exports-only'`
|
|
1935
2504
|
* {@include ./docs/preserve-entry-signatures.md}
|
|
1936
2505
|
*/
|
|
1937
2506
|
preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
|
|
@@ -1940,7 +2509,8 @@ interface InputOptions {
|
|
|
1940
2509
|
*/
|
|
1941
2510
|
optimization?: OptimizationOptions;
|
|
1942
2511
|
/**
|
|
1943
|
-
* The value of `this` at the top level of each
|
|
2512
|
+
* The value of `this` at the top level of each module. **Normally, you don't need to set this option.**
|
|
2513
|
+
* @default undefined
|
|
1944
2514
|
* @example
|
|
1945
2515
|
* **Set custom context**
|
|
1946
2516
|
* ```js
|
|
@@ -1951,25 +2521,15 @@ interface InputOptions {
|
|
|
1951
2521
|
* },
|
|
1952
2522
|
* };
|
|
1953
2523
|
* ```
|
|
1954
|
-
* **Use window for browser builds**
|
|
1955
|
-
* ```js
|
|
1956
|
-
* export default {
|
|
1957
|
-
* context: 'window',
|
|
1958
|
-
* platform: 'browser',
|
|
1959
|
-
* output: {
|
|
1960
|
-
* format: 'iife',
|
|
1961
|
-
* },
|
|
1962
|
-
* };
|
|
1963
|
-
* ```
|
|
1964
2524
|
* {@include ./docs/context.md}
|
|
1965
2525
|
*/
|
|
1966
2526
|
context?: string;
|
|
1967
2527
|
/**
|
|
1968
2528
|
* Configures TypeScript configuration file resolution and usage.
|
|
1969
2529
|
* {@include ./docs/tsconfig.md}
|
|
1970
|
-
* @default
|
|
2530
|
+
* @default true
|
|
1971
2531
|
*/
|
|
1972
|
-
tsconfig?:
|
|
2532
|
+
tsconfig?: boolean | string;
|
|
1973
2533
|
}
|
|
1974
2534
|
//#endregion
|
|
1975
2535
|
//#region src/types/rolldown-options.d.ts
|
|
@@ -1977,16 +2537,15 @@ interface RolldownOptions extends InputOptions {
|
|
|
1977
2537
|
output?: OutputOptions | OutputOptions[];
|
|
1978
2538
|
}
|
|
1979
2539
|
//#endregion
|
|
1980
|
-
//#region src/
|
|
2540
|
+
//#region src/utils/define-config.d.ts
|
|
1981
2541
|
/**
|
|
1982
2542
|
* Type for `default export` of `rolldown.config.js` file.
|
|
1983
2543
|
*/
|
|
1984
2544
|
type ConfigExport = RolldownOptions | RolldownOptions[] | RolldownOptionsFunction;
|
|
1985
|
-
|
|
1986
|
-
//#region src/utils/define-config.d.ts
|
|
2545
|
+
type RolldownOptionsFunction = (commandLineArguments: Record<string, any>) => MaybePromise<RolldownOptions | RolldownOptions[]>;
|
|
1987
2546
|
declare function defineConfig(config: RolldownOptions): RolldownOptions;
|
|
1988
2547
|
declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
1989
2548
|
declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
|
|
1990
2549
|
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
1991
2550
|
//#endregion
|
|
1992
|
-
export {
|
|
2551
|
+
export { RolldownFsModule as $, TransformResult as A, RenderedModule as At, EmittedPrebuiltChunk as B, Plugin as C, MinifyOptions as Ct, RolldownPlugin as D, OutputAsset as Dt, ResolvedId as E, PreRenderedAsset as Et, OutputBundle as F, SourcemapIgnoreListOption as Ft, MinimalPluginContext as G, PluginContext as H, TreeshakingOptions as I, HookFilter as J, PluginContextMeta as K, TransformPluginContext as L, VERSION as M, SourceMap as Mt, ExistingRawSourceMap as N, freeExternalMemory as Nt, RolldownPluginOption as O, OutputChunk as Ot, SourceMapInput as P, ModuleInfo as Pt, RolldownFileStats as Q, EmittedAsset as R, PartialResolvedId as S, GlobalsFunction as St, ResolveIdResult as T, OutputOptions as Tt, DefineParallelPluginResult as U, GetModuleInfo as V, defineParallelPlugin as W, BufferEncoding as X, ModuleTypeFilter as Y, RolldownDirectoryEntry as Z, LoadResult as _, ChunkFileNamesFunction as _t, ExternalOption as a, LoggingFunction as at, ObjectHook as b, GeneratedCodeOptions as bt, InputOptions as c, RolldownWatcher as ct, WatcherOptions as d, rolldown as dt, InternalModuleFormat as et, AsyncPluginHooks as f, RolldownBuild as ft, ImportKind as g, AdvancedChunksGroup as gt, HookFilterExtension as h, AddonFunction as ht, RolldownOptions as i, ChecksOptions as it, withFilter as j, RolldownOutput as jt, SourceDescription as k, RenderedChunk as kt, ModuleTypes as l, RolldownWatcherEvent as lt, FunctionPluginHooks as m, build as mt, RolldownOptionsFunction as n, NormalizedInputOptions as nt, ExternalOptionFunction as o, WarningHandlerWithDefault as ot, CustomPluginOptions as p, BuildOptions as pt, GeneralHookFilter as q, defineConfig as r, TransformOptions as rt, InputOption as s, watch as st, ConfigExport as t, NormalizedOutputOptions as tt, OptimizationOptions as u, WatchOptions as ut, ModuleOptions as v, ChunkingContext as vt, ResolveIdExtraOptions as w, ModuleFormat as wt, ParallelPluginHooks as x, GeneratedCodePreset as xt, ModuleType as y, CodeSplittingGroup as yt, EmittedFile as z };
|