@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.
Files changed (39) hide show
  1. package/dist/cli-setup.mjs +1 -1
  2. package/dist/cli.mjs +121 -114
  3. package/dist/config.d.mts +2 -2
  4. package/dist/config.mjs +8 -8
  5. package/dist/experimental-index.d.mts +43 -43
  6. package/dist/experimental-index.mjs +6 -6
  7. package/dist/filter-index.d.mts +197 -4
  8. package/dist/filter-index.mjs +1 -1
  9. package/dist/get-log-filter.d.mts +3 -3
  10. package/dist/index.d.mts +4 -4
  11. package/dist/index.mjs +27 -8
  12. package/dist/parallel-plugin-worker.mjs +4 -4
  13. package/dist/parallel-plugin.d.mts +4 -4
  14. package/dist/parse-ast-index.d.mts +1 -1
  15. package/dist/parse-ast-index.mjs +2 -2
  16. package/dist/plugins-index.d.mts +3 -4
  17. package/dist/plugins-index.mjs +3 -3
  18. package/dist/shared/binding-B92Lq__Q.d.mts +1687 -0
  19. package/dist/shared/{binding-uOeDeDzp.mjs → binding-tNJoEqAa.mjs} +28 -26
  20. package/dist/shared/{bindingify-input-options-CuBDHglZ.mjs → bindingify-input-options-CfhrNd_y.mjs} +117 -58
  21. package/dist/shared/{constructors-D9F4Aj4h.d.mts → constructors--k1uxZrh.d.mts} +2 -2
  22. package/dist/shared/{constructors-DmSv3tnW.mjs → constructors-414MPkgB.mjs} +1 -1
  23. package/dist/shared/define-config-D8xP5iyL.d.mts +3463 -0
  24. package/dist/shared/{load-config-Bo3y98vw.mjs → load-config-Qtd9pHJ5.mjs} +1 -1
  25. package/dist/shared/logging-wIy4zY9I.d.mts +50 -0
  26. package/dist/shared/{normalize-string-or-regex-0f6WITto.mjs → normalize-string-or-regex-DeB7vQ75.mjs} +2 -2
  27. package/dist/shared/{parse-ast-index-B0iVLbj6.mjs → parse-ast-index-BcP4Ts_P.mjs} +3 -3
  28. package/dist/shared/{prompt-BZ-QjPVS.mjs → prompt-tlfjalEt.mjs} +1 -1
  29. package/dist/shared/rolldown-BMzJcmQ7.mjs +42 -0
  30. package/dist/shared/{rolldown-build-BqHWBpp7.mjs → rolldown-build-DWeKtJOy.mjs} +123 -47
  31. package/dist/shared/{watch-Ce8bKBAn.mjs → watch-HmN4U4B9.mjs} +34 -6
  32. package/package.json +18 -16
  33. package/dist/shared/binding-C9YdqoUG.d.mts +0 -1657
  34. package/dist/shared/define-config-glNgjHCc.d.mts +0 -2573
  35. package/dist/shared/logging-DsnCZi19.d.mts +0 -42
  36. package/dist/shared/rolldown-mAJGca5O.mjs +0 -11
  37. /package/dist/shared/{define-config-BF4P-Pum.mjs → define-config-BVG4QvnP.mjs} +0 -0
  38. /package/dist/shared/{logs-N5Akftom.mjs → logs-NH298mHo.mjs} +0 -0
  39. /package/dist/shared/{misc-0HsaOsAX.mjs → misc-CCZIsXVO.mjs} +0 -0
@@ -0,0 +1,1687 @@
1
+ import * as _oxc_project_types0 from "@oxc-project/types";
2
+
3
+ //#region src/binding.d.cts
4
+ type MaybePromise<T> = T | Promise<T>;
5
+ type VoidNullable<T = void> = T | null | undefined | void;
6
+ type BindingStringOrRegex = string | RegExp;
7
+ interface CodegenOptions {
8
+ /**
9
+ * Remove whitespace.
10
+ *
11
+ * @default true
12
+ */
13
+ removeWhitespace?: boolean;
14
+ }
15
+ interface CompressOptions {
16
+ /**
17
+ * Set desired EcmaScript standard version for output.
18
+ *
19
+ * Set `esnext` to enable all target highering.
20
+ *
21
+ * Example:
22
+ *
23
+ * * `'es2015'`
24
+ * * `['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']`
25
+ *
26
+ * @default 'esnext'
27
+ *
28
+ * @see [esbuild#target](https://esbuild.github.io/api/#target)
29
+ */
30
+ target?: string | Array<string>;
31
+ /**
32
+ * Pass true to discard calls to `console.*`.
33
+ *
34
+ * @default false
35
+ */
36
+ dropConsole?: boolean;
37
+ /**
38
+ * Remove `debugger;` statements.
39
+ *
40
+ * @default true
41
+ */
42
+ dropDebugger?: boolean;
43
+ /**
44
+ * Pass `true` to drop unreferenced functions and variables.
45
+ *
46
+ * Simple direct variable assignments do not count as references unless set to `keep_assign`.
47
+ * @default true
48
+ */
49
+ unused?: boolean | 'keep_assign';
50
+ /** Keep function / class names. */
51
+ keepNames?: CompressOptionsKeepNames;
52
+ /**
53
+ * Join consecutive var, let and const statements.
54
+ *
55
+ * @default true
56
+ */
57
+ joinVars?: boolean;
58
+ /**
59
+ * Join consecutive simple statements using the comma operator.
60
+ *
61
+ * `a; b` -> `a, b`
62
+ *
63
+ * @default true
64
+ */
65
+ sequences?: boolean;
66
+ /**
67
+ * Set of label names to drop from the code.
68
+ *
69
+ * Labeled statements matching these names will be removed during minification.
70
+ *
71
+ * @default []
72
+ */
73
+ dropLabels?: Array<string>;
74
+ /** Limit the maximum number of iterations for debugging purpose. */
75
+ maxIterations?: number;
76
+ /** Treeshake options. */
77
+ treeshake?: TreeShakeOptions;
78
+ }
79
+ interface CompressOptionsKeepNames {
80
+ /**
81
+ * Keep function names so that `Function.prototype.name` is preserved.
82
+ *
83
+ * This does not guarantee that the `undefined` name is preserved.
84
+ *
85
+ * @default false
86
+ */
87
+ function: boolean;
88
+ /**
89
+ * Keep class names so that `Class.prototype.name` is preserved.
90
+ *
91
+ * This does not guarantee that the `undefined` name is preserved.
92
+ *
93
+ * @default false
94
+ */
95
+ class: boolean;
96
+ }
97
+ interface MangleOptions {
98
+ /**
99
+ * Pass `true` to mangle names declared in the top level scope.
100
+ *
101
+ * @default false
102
+ */
103
+ toplevel?: boolean;
104
+ /**
105
+ * Preserve `name` property for functions and classes.
106
+ *
107
+ * @default false
108
+ */
109
+ keepNames?: boolean | MangleOptionsKeepNames;
110
+ /** Debug mangled names. */
111
+ debug?: boolean;
112
+ }
113
+ interface MangleOptionsKeepNames {
114
+ /**
115
+ * Preserve `name` property for functions.
116
+ *
117
+ * @default false
118
+ */
119
+ function: boolean;
120
+ /**
121
+ * Preserve `name` property for classes.
122
+ *
123
+ * @default false
124
+ */
125
+ class: boolean;
126
+ }
127
+ /**
128
+ * Minify asynchronously.
129
+ *
130
+ * Note: This function can be slower than `minifySync` due to the overhead of spawning a thread.
131
+ */
132
+ declare function minify(filename: string, sourceText: string, options?: MinifyOptions | undefined | null): Promise<MinifyResult>;
133
+ interface MinifyOptions {
134
+ /** Use when minifying an ES module. */
135
+ module?: boolean;
136
+ compress?: boolean | CompressOptions;
137
+ mangle?: boolean | MangleOptions;
138
+ codegen?: boolean | CodegenOptions;
139
+ sourcemap?: boolean;
140
+ }
141
+ interface MinifyResult {
142
+ code: string;
143
+ map?: SourceMap;
144
+ errors: Array<OxcError>;
145
+ }
146
+ /** Minify synchronously. */
147
+ declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | undefined | null): MinifyResult;
148
+ interface TreeShakeOptions {
149
+ /**
150
+ * Whether to respect the pure annotations.
151
+ *
152
+ * Pure annotations are comments that mark an expression as pure.
153
+ * For example: @__PURE__ or #__NO_SIDE_EFFECTS__.
154
+ *
155
+ * @default true
156
+ */
157
+ annotations?: boolean;
158
+ /**
159
+ * Whether to treat this function call as pure.
160
+ *
161
+ * This function is called for normal function calls, new calls, and
162
+ * tagged template calls.
163
+ */
164
+ manualPureFunctions?: Array<string>;
165
+ /**
166
+ * Whether property read accesses have side effects.
167
+ *
168
+ * @default 'always'
169
+ */
170
+ propertyReadSideEffects?: boolean | 'always';
171
+ /**
172
+ * Whether accessing a global variable has side effects.
173
+ *
174
+ * Accessing a non-existing global variable will throw an error.
175
+ * Global variable may be a getter that has side effects.
176
+ *
177
+ * @default true
178
+ */
179
+ unknownGlobalSideEffects?: boolean;
180
+ /**
181
+ * Whether invalid import statements have side effects.
182
+ *
183
+ * Accessing a non-existing import name will throw an error.
184
+ * Also import statements that cannot be resolved will throw an error.
185
+ *
186
+ * @default true
187
+ */
188
+ invalidImportSideEffects?: boolean;
189
+ }
190
+ interface Comment {
191
+ type: 'Line' | 'Block';
192
+ value: string;
193
+ start: number;
194
+ end: number;
195
+ }
196
+ interface ErrorLabel {
197
+ message: string | null;
198
+ start: number;
199
+ end: number;
200
+ }
201
+ interface OxcError {
202
+ severity: Severity;
203
+ message: string;
204
+ labels: Array<ErrorLabel>;
205
+ helpMessage: string | null;
206
+ codeframe: string | null;
207
+ }
208
+ type Severity = 'Error' | 'Warning' | 'Advice';
209
+ declare class ParseResult {
210
+ get program(): _oxc_project_types0.Program;
211
+ get module(): EcmaScriptModule;
212
+ get comments(): Array<Comment>;
213
+ get errors(): Array<OxcError>;
214
+ }
215
+ interface DynamicImport {
216
+ start: number;
217
+ end: number;
218
+ moduleRequest: Span;
219
+ }
220
+ interface EcmaScriptModule {
221
+ /**
222
+ * Has ESM syntax.
223
+ *
224
+ * i.e. `import` and `export` statements, and `import.meta`.
225
+ *
226
+ * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
227
+ */
228
+ hasModuleSyntax: boolean;
229
+ /** Import statements. */
230
+ staticImports: Array<StaticImport>;
231
+ /** Export statements. */
232
+ staticExports: Array<StaticExport>;
233
+ /** Dynamic import expressions. */
234
+ dynamicImports: Array<DynamicImport>;
235
+ /** Span positions` of `import.meta` */
236
+ importMetas: Array<Span>;
237
+ }
238
+ interface ExportExportName {
239
+ kind: ExportExportNameKind;
240
+ name: string | null;
241
+ start: number | null;
242
+ end: number | null;
243
+ }
244
+ type ExportExportNameKind = /** `export { name } */'Name' | /** `export default expression` */'Default' | /** `export * from "mod" */'None';
245
+ interface ExportImportName {
246
+ kind: ExportImportNameKind;
247
+ name: string | null;
248
+ start: number | null;
249
+ end: number | null;
250
+ }
251
+ type ExportImportNameKind = /** `export { name } */'Name' | /** `export * as ns from "mod"` */'All' | /** `export * from "mod"` */'AllButDefault' | /** Does not have a specifier. */'None';
252
+ interface ExportLocalName {
253
+ kind: ExportLocalNameKind;
254
+ name: string | null;
255
+ start: number | null;
256
+ end: number | null;
257
+ }
258
+ type ExportLocalNameKind = /** `export { name } */'Name' | /** `export default expression` */'Default' |
259
+ /**
260
+ * If the exported value is not locally accessible from within the module.
261
+ * `export default function () {}`
262
+ */
263
+ 'None';
264
+ interface ImportName {
265
+ kind: ImportNameKind;
266
+ name: string | null;
267
+ start: number | null;
268
+ end: number | null;
269
+ }
270
+ type ImportNameKind = /** `import { x } from "mod"` */'Name' | /** `import * as ns from "mod"` */'NamespaceObject' | /** `import defaultExport from "mod"` */'Default';
271
+ interface ParserOptions {
272
+ /** Treat the source text as `js`, `jsx`, `ts`, `tsx` or `dts`. */
273
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx' | 'dts';
274
+ /** Treat the source text as `script` or `module` code. */
275
+ sourceType?: 'script' | 'module' | 'commonjs' | 'unambiguous' | undefined;
276
+ /**
277
+ * Return an AST which includes TypeScript-related properties, or excludes them.
278
+ *
279
+ * `'js'` is default for JS / JSX files.
280
+ * `'ts'` is default for TS / TSX files.
281
+ * The type of the file is determined from `lang` option, or extension of provided `filename`.
282
+ */
283
+ astType?: 'js' | 'ts';
284
+ /**
285
+ * Controls whether the `range` property is included on AST nodes.
286
+ * The `range` property is a `[number, number]` which indicates the start/end offsets
287
+ * of the node in the file contents.
288
+ *
289
+ * @default false
290
+ */
291
+ range?: boolean;
292
+ /**
293
+ * Emit `ParenthesizedExpression` and `TSParenthesizedType` in AST.
294
+ *
295
+ * If this option is true, parenthesized expressions are represented by
296
+ * (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` nodes that
297
+ * have a single `expression` property containing the expression inside parentheses.
298
+ *
299
+ * @default true
300
+ */
301
+ preserveParens?: boolean;
302
+ /**
303
+ * Produce semantic errors with an additional AST pass.
304
+ * Semantic errors depend on symbols and scopes, where the parser does not construct.
305
+ * This adds a small performance overhead.
306
+ *
307
+ * @default false
308
+ */
309
+ showSemanticErrors?: boolean;
310
+ }
311
+ interface Span {
312
+ start: number;
313
+ end: number;
314
+ }
315
+ interface StaticExport {
316
+ start: number;
317
+ end: number;
318
+ entries: Array<StaticExportEntry>;
319
+ }
320
+ interface StaticExportEntry {
321
+ start: number;
322
+ end: number;
323
+ moduleRequest: ValueSpan | null;
324
+ /** The name under which the desired binding is exported by the module`. */
325
+ importName: ExportImportName;
326
+ /** The name used to export this binding by this module. */
327
+ exportName: ExportExportName;
328
+ /** The name that is used to locally access the exported value from within the importing module. */
329
+ localName: ExportLocalName;
330
+ /**
331
+ * Whether the export is a TypeScript `export type`.
332
+ *
333
+ * Examples:
334
+ *
335
+ * ```ts
336
+ * export type * from 'mod';
337
+ * export type * as ns from 'mod';
338
+ * export type { foo };
339
+ * export { type foo }:
340
+ * export type { foo } from 'mod';
341
+ * ```
342
+ */
343
+ isType: boolean;
344
+ }
345
+ interface StaticImport {
346
+ /** Start of import statement. */
347
+ start: number;
348
+ /** End of import statement. */
349
+ end: number;
350
+ /**
351
+ * Import source.
352
+ *
353
+ * ```js
354
+ * import { foo } from "mod";
355
+ * // ^^^
356
+ * ```
357
+ */
358
+ moduleRequest: ValueSpan;
359
+ /**
360
+ * Import specifiers.
361
+ *
362
+ * Empty for `import "mod"`.
363
+ */
364
+ entries: Array<StaticImportEntry>;
365
+ }
366
+ interface StaticImportEntry {
367
+ /**
368
+ * The name under which the desired binding is exported by the module.
369
+ *
370
+ * ```js
371
+ * import { foo } from "mod";
372
+ * // ^^^
373
+ * import { foo as bar } from "mod";
374
+ * // ^^^
375
+ * ```
376
+ */
377
+ importName: ImportName;
378
+ /**
379
+ * The name that is used to locally access the imported value from within the importing module.
380
+ * ```js
381
+ * import { foo } from "mod";
382
+ * // ^^^
383
+ * import { foo as bar } from "mod";
384
+ * // ^^^
385
+ * ```
386
+ */
387
+ localName: ValueSpan;
388
+ /**
389
+ * Whether this binding is for a TypeScript type-only import.
390
+ *
391
+ * `true` for the following imports:
392
+ * ```ts
393
+ * import type { foo } from "mod";
394
+ * import { type foo } from "mod";
395
+ * ```
396
+ */
397
+ isType: boolean;
398
+ }
399
+ interface ValueSpan {
400
+ value: string;
401
+ start: number;
402
+ end: number;
403
+ }
404
+ declare class ResolverFactory {
405
+ constructor(options?: NapiResolveOptions | undefined | null);
406
+ static default(): ResolverFactory;
407
+ /** Clone the resolver using the same underlying cache. */
408
+ cloneWithOptions(options: NapiResolveOptions): ResolverFactory;
409
+ /**
410
+ * Clear the underlying cache.
411
+ *
412
+ * Warning: The caller must ensure that there're no ongoing resolution operations when calling this method. Otherwise, it may cause those operations to return an incorrect result.
413
+ */
414
+ clearCache(): void;
415
+ /** Synchronously resolve `specifier` at an absolute path to a `directory`. */
416
+ sync(directory: string, request: string): ResolveResult;
417
+ /** Asynchronously resolve `specifier` at an absolute path to a `directory`. */
418
+ async(directory: string, request: string): Promise<ResolveResult>;
419
+ /**
420
+ * Synchronously resolve `specifier` at an absolute path to a `file`.
421
+ *
422
+ * This method automatically discovers tsconfig.json by traversing parent directories.
423
+ */
424
+ resolveFileSync(file: string, request: string): ResolveResult;
425
+ /**
426
+ * Asynchronously resolve `specifier` at an absolute path to a `file`.
427
+ *
428
+ * This method automatically discovers tsconfig.json by traversing parent directories.
429
+ */
430
+ resolveFileAsync(file: string, request: string): Promise<ResolveResult>;
431
+ }
432
+ /** Node.js builtin module when `Options::builtin_modules` is enabled. */
433
+ interface Builtin {
434
+ /**
435
+ * Resolved module.
436
+ *
437
+ * Always prefixed with "node:" in compliance with the ESM specification.
438
+ */
439
+ resolved: string;
440
+ /**
441
+ * Whether the request was prefixed with `node:` or not.
442
+ * `fs` -> `false`.
443
+ * `node:fs` returns `true`.
444
+ */
445
+ isRuntimeModule: boolean;
446
+ }
447
+ declare enum EnforceExtension {
448
+ Auto = 0,
449
+ Enabled = 1,
450
+ Disabled = 2,
451
+ }
452
+ type ModuleType = 'module' | 'commonjs' | 'json' | 'wasm' | 'addon';
453
+ /**
454
+ * Module Resolution Options
455
+ *
456
+ * Options are directly ported from [enhanced-resolve](https://github.com/webpack/enhanced-resolve#resolver-options).
457
+ *
458
+ * See [webpack resolve](https://webpack.js.org/configuration/resolve/) for information and examples
459
+ */
460
+ interface NapiResolveOptions {
461
+ /**
462
+ * Discover tsconfig automatically or use the specified tsconfig.json path.
463
+ *
464
+ * Default `None`
465
+ */
466
+ tsconfig?: 'auto' | TsconfigOptions;
467
+ /**
468
+ * Alias for [ResolveOptions::alias] and [ResolveOptions::fallback].
469
+ *
470
+ * For the second value of the tuple, `None -> AliasValue::Ignore`, Some(String) ->
471
+ * AliasValue::Path(String)`
472
+ * Create aliases to import or require certain modules more easily.
473
+ * A trailing $ can also be added to the given object's keys to signify an exact match.
474
+ * Default `{}`
475
+ */
476
+ alias?: Record<string, Array<string | undefined | null>>;
477
+ /**
478
+ * A list of alias fields in description files.
479
+ * Specify a field, such as `browser`, to be parsed according to [this specification](https://github.com/defunctzombie/package-browser-field-spec).
480
+ * Can be a path to json object such as `["path", "to", "exports"]`.
481
+ *
482
+ * Default `[]`
483
+ */
484
+ aliasFields?: (string | string[])[];
485
+ /**
486
+ * Condition names for exports field which defines entry points of a package.
487
+ * The key order in the exports field is significant. During condition matching, earlier entries have higher priority and take precedence over later entries.
488
+ *
489
+ * Default `[]`
490
+ */
491
+ conditionNames?: Array<string>;
492
+ /**
493
+ * If true, it will not allow extension-less files.
494
+ * So by default `require('./foo')` works if `./foo` has a `.js` extension,
495
+ * but with this enabled only `require('./foo.js')` will work.
496
+ *
497
+ * Default to `true` when [ResolveOptions::extensions] contains an empty string.
498
+ * Use `Some(false)` to disable the behavior.
499
+ * See <https://github.com/webpack/enhanced-resolve/pull/285>
500
+ *
501
+ * Default None, which is the same as `Some(false)` when the above empty rule is not applied.
502
+ */
503
+ enforceExtension?: EnforceExtension;
504
+ /**
505
+ * A list of exports fields in description files.
506
+ * Can be a path to json object such as `["path", "to", "exports"]`.
507
+ *
508
+ * Default `[["exports"]]`.
509
+ */
510
+ exportsFields?: (string | string[])[];
511
+ /**
512
+ * Fields from `package.json` which are used to provide the internal requests of a package
513
+ * (requests starting with # are considered internal).
514
+ *
515
+ * Can be a path to a JSON object such as `["path", "to", "imports"]`.
516
+ *
517
+ * Default `[["imports"]]`.
518
+ */
519
+ importsFields?: (string | string[])[];
520
+ /**
521
+ * An object which maps extension to extension aliases.
522
+ *
523
+ * Default `{}`
524
+ */
525
+ extensionAlias?: Record<string, Array<string>>;
526
+ /**
527
+ * Attempt to resolve these extensions in order.
528
+ * If multiple files share the same name but have different extensions,
529
+ * will resolve the one with the extension listed first in the array and skip the rest.
530
+ *
531
+ * Default `[".js", ".json", ".node"]`
532
+ */
533
+ extensions?: Array<string>;
534
+ /**
535
+ * Redirect module requests when normal resolving fails.
536
+ *
537
+ * Default `{}`
538
+ */
539
+ fallback?: Record<string, Array<string | undefined | null>>;
540
+ /**
541
+ * Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests).
542
+ *
543
+ * See also webpack configuration [resolve.fullySpecified](https://webpack.js.org/configuration/module/#resolvefullyspecified)
544
+ *
545
+ * Default `false`
546
+ */
547
+ fullySpecified?: boolean;
548
+ /**
549
+ * A list of main fields in description files
550
+ *
551
+ * Default `["main"]`.
552
+ */
553
+ mainFields?: string | string[];
554
+ /**
555
+ * The filename to be used while resolving directories.
556
+ *
557
+ * Default `["index"]`
558
+ */
559
+ mainFiles?: Array<string>;
560
+ /**
561
+ * A list of directories to resolve modules from, can be absolute path or folder name.
562
+ *
563
+ * Default `["node_modules"]`
564
+ */
565
+ modules?: string | string[];
566
+ /**
567
+ * Resolve to a context instead of a file.
568
+ *
569
+ * Default `false`
570
+ */
571
+ resolveToContext?: boolean;
572
+ /**
573
+ * Prefer to resolve module requests as relative requests instead of using modules from node_modules directories.
574
+ *
575
+ * Default `false`
576
+ */
577
+ preferRelative?: boolean;
578
+ /**
579
+ * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in ResolveOptions::roots.
580
+ *
581
+ * Default `false`
582
+ */
583
+ preferAbsolute?: boolean;
584
+ /**
585
+ * A list of resolve restrictions to restrict the paths that a request can be resolved on.
586
+ *
587
+ * Default `[]`
588
+ */
589
+ restrictions?: Array<Restriction>;
590
+ /**
591
+ * A list of directories where requests of server-relative URLs (starting with '/') are resolved.
592
+ * On non-Windows systems these requests are resolved as an absolute path first.
593
+ *
594
+ * Default `[]`
595
+ */
596
+ roots?: Array<string>;
597
+ /**
598
+ * Whether to resolve symlinks to their symlinked location.
599
+ * When enabled, symlinked resources are resolved to their real path, not their symlinked location.
600
+ * Note that this may cause module resolution to fail when using tools that symlink packages (like npm link).
601
+ *
602
+ * Default `true`
603
+ */
604
+ symlinks?: boolean;
605
+ /**
606
+ * Whether to parse [module.builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules) or not.
607
+ * For example, "zlib" will throw [crate::ResolveError::Builtin] when set to true.
608
+ *
609
+ * Default `false`
610
+ */
611
+ builtinModules?: boolean;
612
+ /**
613
+ * Resolve [ResolveResult::moduleType].
614
+ *
615
+ * Default `false`
616
+ */
617
+ moduleType?: boolean;
618
+ /**
619
+ * Allow `exports` field in `require('../directory')`.
620
+ *
621
+ * This is not part of the spec but some vite projects rely on this behavior.
622
+ * See
623
+ * * <https://github.com/vitejs/vite/pull/20252>
624
+ * * <https://github.com/nodejs/node/issues/58827>
625
+ *
626
+ * Default: `false`
627
+ */
628
+ allowPackageExportsInDirectoryResolve?: boolean;
629
+ }
630
+ interface ResolveResult {
631
+ path?: string;
632
+ error?: string;
633
+ builtin?: Builtin;
634
+ /**
635
+ * Module type for this path.
636
+ *
637
+ * Enable with `ResolveOptions#moduleType`.
638
+ *
639
+ * The module type is computed `ESM_FILE_FORMAT` from the [ESM resolution algorithm specification](https://nodejs.org/docs/latest/api/esm.html#resolution-algorithm-specification).
640
+ *
641
+ * The algorithm uses the file extension or finds the closest `package.json` with the `type` field.
642
+ */
643
+ moduleType?: ModuleType;
644
+ /** `package.json` path for the given module. */
645
+ packageJsonPath?: string;
646
+ }
647
+ /**
648
+ * Alias Value for [ResolveOptions::alias] and [ResolveOptions::fallback].
649
+ * Use struct because napi don't support structured union now
650
+ */
651
+ interface Restriction {
652
+ path?: string;
653
+ regex?: string;
654
+ }
655
+ /**
656
+ * Tsconfig Options
657
+ *
658
+ * Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options)
659
+ */
660
+ interface TsconfigOptions {
661
+ /**
662
+ * Allows you to specify where to find the TypeScript configuration file.
663
+ * You may provide
664
+ * * a relative path to the configuration file. It will be resolved relative to cwd.
665
+ * * an absolute path to the configuration file.
666
+ */
667
+ configFile: string;
668
+ /**
669
+ * Support for Typescript Project References.
670
+ *
671
+ * * `'auto'`: use the `references` field from tsconfig of `config_file`.
672
+ */
673
+ references?: 'auto';
674
+ }
675
+ interface SourceMap {
676
+ file?: string;
677
+ mappings: string;
678
+ names: Array<string>;
679
+ sourceRoot?: string;
680
+ sources: Array<string>;
681
+ sourcesContent?: Array<string>;
682
+ version: number;
683
+ x_google_ignoreList?: Array<number>;
684
+ }
685
+ interface CompilerAssumptions {
686
+ ignoreFunctionLength?: boolean;
687
+ noDocumentAll?: boolean;
688
+ objectRestNoSymbols?: boolean;
689
+ pureGetters?: boolean;
690
+ /**
691
+ * When using public class fields, assume that they don't shadow any getter in the current class,
692
+ * in its subclasses or in its superclass. Thus, it's safe to assign them rather than using
693
+ * `Object.defineProperty`.
694
+ *
695
+ * For example:
696
+ *
697
+ * Input:
698
+ * ```js
699
+ * class Test {
700
+ * field = 2;
701
+ *
702
+ * static staticField = 3;
703
+ * }
704
+ * ```
705
+ *
706
+ * When `set_public_class_fields` is `true`, the output will be:
707
+ * ```js
708
+ * class Test {
709
+ * constructor() {
710
+ * this.field = 2;
711
+ * }
712
+ * }
713
+ * Test.staticField = 3;
714
+ * ```
715
+ *
716
+ * Otherwise, the output will be:
717
+ * ```js
718
+ * import _defineProperty from "@oxc-project/runtime/helpers/defineProperty";
719
+ * class Test {
720
+ * constructor() {
721
+ * _defineProperty(this, "field", 2);
722
+ * }
723
+ * }
724
+ * _defineProperty(Test, "staticField", 3);
725
+ * ```
726
+ *
727
+ * NOTE: For TypeScript, if you wanted behavior is equivalent to `useDefineForClassFields: false`, you should
728
+ * set both `set_public_class_fields` and [`crate::TypeScriptOptions::remove_class_fields_without_initializer`]
729
+ * to `true`.
730
+ */
731
+ setPublicClassFields?: boolean;
732
+ }
733
+ interface DecoratorOptions {
734
+ /**
735
+ * Enables experimental support for decorators, which is a version of decorators that predates the TC39 standardization process.
736
+ *
737
+ * Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification.
738
+ * This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
739
+ *
740
+ * @see https://www.typescriptlang.org/tsconfig/#experimentalDecorators
741
+ * @default false
742
+ */
743
+ legacy?: boolean;
744
+ /**
745
+ * Enables emitting decorator metadata.
746
+ *
747
+ * This option the same as [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
748
+ * in TypeScript, and it only works when `legacy` is true.
749
+ *
750
+ * @see https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata
751
+ * @default false
752
+ */
753
+ emitDecoratorMetadata?: boolean;
754
+ }
755
+ type HelperMode =
756
+ /**
757
+ * Runtime mode (default): Helper functions are imported from a runtime package.
758
+ *
759
+ * Example:
760
+ *
761
+ * ```js
762
+ * import helperName from "@oxc-project/runtime/helpers/helperName";
763
+ * helperName(...arguments);
764
+ * ```
765
+ */
766
+ 'Runtime' |
767
+ /**
768
+ * External mode: Helper functions are accessed from a global `babelHelpers` object.
769
+ *
770
+ * Example:
771
+ *
772
+ * ```js
773
+ * babelHelpers.helperName(...arguments);
774
+ * ```
775
+ */
776
+ 'External';
777
+ interface Helpers {
778
+ mode?: HelperMode;
779
+ }
780
+ /**
781
+ * TypeScript Isolated Declarations for Standalone DTS Emit (async)
782
+ *
783
+ * Note: This function can be slower than `isolatedDeclarationSync` due to the overhead of spawning a thread.
784
+ */
785
+ declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): Promise<IsolatedDeclarationsResult>;
786
+ interface IsolatedDeclarationsOptions {
787
+ /**
788
+ * Do not emit declarations for code that has an @internal annotation in its JSDoc comment.
789
+ * This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
790
+ *
791
+ * Default: `false`
792
+ *
793
+ * See <https://www.typescriptlang.org/tsconfig/#stripInternal>
794
+ */
795
+ stripInternal?: boolean;
796
+ sourcemap?: boolean;
797
+ }
798
+ interface IsolatedDeclarationsResult {
799
+ code: string;
800
+ map?: SourceMap;
801
+ errors: Array<OxcError>;
802
+ }
803
+ /** TypeScript Isolated Declarations for Standalone DTS Emit */
804
+ declare function isolatedDeclarationSync(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult;
805
+ /**
806
+ * Configure how TSX and JSX are transformed.
807
+ *
808
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
809
+ */
810
+ interface JsxOptions {
811
+ /**
812
+ * Decides which runtime to use.
813
+ *
814
+ * - 'automatic' - auto-import the correct JSX factories
815
+ * - 'classic' - no auto-import
816
+ *
817
+ * @default 'automatic'
818
+ */
819
+ runtime?: 'classic' | 'automatic';
820
+ /**
821
+ * Emit development-specific information, such as `__source` and `__self`.
822
+ *
823
+ * @default false
824
+ *
825
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
826
+ */
827
+ development?: boolean;
828
+ /**
829
+ * Toggles whether or not to throw an error if an XML namespaced tag name
830
+ * is used.
831
+ *
832
+ * Though the JSX spec allows this, it is disabled by default since React's
833
+ * JSX does not currently have support for it.
834
+ *
835
+ * @default true
836
+ */
837
+ throwIfNamespace?: boolean;
838
+ /**
839
+ * Enables `@babel/plugin-transform-react-pure-annotations`.
840
+ *
841
+ * It will mark JSX elements and top-level React method calls as pure for tree shaking.
842
+ *
843
+ * @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
844
+ *
845
+ * @default true
846
+ */
847
+ pure?: boolean;
848
+ /**
849
+ * Replaces the import source when importing functions.
850
+ *
851
+ * @default 'react'
852
+ */
853
+ importSource?: string;
854
+ /**
855
+ * Replace the function used when compiling JSX expressions. It should be a
856
+ * qualified name (e.g. `React.createElement`) or an identifier (e.g.
857
+ * `createElement`).
858
+ *
859
+ * Only used for `classic` {@link runtime}.
860
+ *
861
+ * @default 'React.createElement'
862
+ */
863
+ pragma?: string;
864
+ /**
865
+ * Replace the component used when compiling JSX fragments. It should be a
866
+ * valid JSX tag name.
867
+ *
868
+ * Only used for `classic` {@link runtime}.
869
+ *
870
+ * @default 'React.Fragment'
871
+ */
872
+ pragmaFrag?: string;
873
+ /**
874
+ * When spreading props, use `Object.assign` directly instead of an extend helper.
875
+ *
876
+ * Only used for `classic` {@link runtime}.
877
+ *
878
+ * @default false
879
+ */
880
+ useBuiltIns?: boolean;
881
+ /**
882
+ * When spreading props, use inline object with spread elements directly
883
+ * instead of an extend helper or Object.assign.
884
+ *
885
+ * Only used for `classic` {@link runtime}.
886
+ *
887
+ * @default false
888
+ */
889
+ useSpread?: boolean;
890
+ /**
891
+ * Enable React Fast Refresh .
892
+ *
893
+ * Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
894
+ *
895
+ * @default false
896
+ */
897
+ refresh?: boolean | ReactRefreshOptions;
898
+ }
899
+ /**
900
+ * Transform JavaScript code to a Vite Node runnable module.
901
+ *
902
+ * @param filename The name of the file being transformed.
903
+ * @param sourceText the source code itself
904
+ * @param options The options for the transformation. See {@link
905
+ * ModuleRunnerTransformOptions} for more information.
906
+ *
907
+ * @returns an object containing the transformed code, source maps, and any
908
+ * errors that occurred during parsing or transformation.
909
+ *
910
+ * Note: This function can be slower than `moduleRunnerTransformSync` due to the overhead of spawning a thread.
911
+ *
912
+ * @deprecated Only works for Vite.
913
+ */
914
+ declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): Promise<ModuleRunnerTransformResult>;
915
+ interface ModuleRunnerTransformOptions {
916
+ /**
917
+ * Enable source map generation.
918
+ *
919
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
920
+ *
921
+ * @default false
922
+ *
923
+ * @see {@link SourceMap}
924
+ */
925
+ sourcemap?: boolean;
926
+ }
927
+ interface ModuleRunnerTransformResult {
928
+ /**
929
+ * The transformed code.
930
+ *
931
+ * If parsing failed, this will be an empty string.
932
+ */
933
+ code: string;
934
+ /**
935
+ * The source map for the transformed code.
936
+ *
937
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
938
+ */
939
+ map?: SourceMap;
940
+ deps: Array<string>;
941
+ dynamicDeps: Array<string>;
942
+ /**
943
+ * Parse and transformation errors.
944
+ *
945
+ * Oxc's parser recovers from common syntax errors, meaning that
946
+ * transformed code may still be available even if there are errors in this
947
+ * list.
948
+ */
949
+ errors: Array<OxcError>;
950
+ }
951
+ interface PluginsOptions {
952
+ styledComponents?: StyledComponentsOptions;
953
+ taggedTemplateEscape?: boolean;
954
+ }
955
+ interface ReactRefreshOptions {
956
+ /**
957
+ * Specify the identifier of the refresh registration variable.
958
+ *
959
+ * @default `$RefreshReg$`.
960
+ */
961
+ refreshReg?: string;
962
+ /**
963
+ * Specify the identifier of the refresh signature variable.
964
+ *
965
+ * @default `$RefreshSig$`.
966
+ */
967
+ refreshSig?: string;
968
+ emitFullSignatures?: boolean;
969
+ }
970
+ /**
971
+ * Configure how styled-components are transformed.
972
+ *
973
+ * @see {@link https://styled-components.com/docs/tooling#babel-plugin}
974
+ */
975
+ interface StyledComponentsOptions {
976
+ /**
977
+ * Enhances the attached CSS class name on each component with richer output to help
978
+ * identify your components in the DOM without React DevTools.
979
+ *
980
+ * @default true
981
+ */
982
+ displayName?: boolean;
983
+ /**
984
+ * Controls whether the `displayName` of a component will be prefixed with the filename
985
+ * to make the component name as unique as possible.
986
+ *
987
+ * @default true
988
+ */
989
+ fileName?: boolean;
990
+ /**
991
+ * Adds a unique identifier to every styled component to avoid checksum mismatches
992
+ * due to different class generation on the client and server during server-side rendering.
993
+ *
994
+ * @default true
995
+ */
996
+ ssr?: boolean;
997
+ /**
998
+ * Transpiles styled-components tagged template literals to a smaller representation
999
+ * than what Babel normally creates, helping to reduce bundle size.
1000
+ *
1001
+ * @default true
1002
+ */
1003
+ transpileTemplateLiterals?: boolean;
1004
+ /**
1005
+ * Minifies CSS content by removing all whitespace and comments from your CSS,
1006
+ * keeping valuable bytes out of your bundles.
1007
+ *
1008
+ * @default true
1009
+ */
1010
+ minify?: boolean;
1011
+ /**
1012
+ * Enables transformation of JSX `css` prop when using styled-components.
1013
+ *
1014
+ * **Note: This feature is not yet implemented in oxc.**
1015
+ *
1016
+ * @default true
1017
+ */
1018
+ cssProp?: boolean;
1019
+ /**
1020
+ * Enables "pure annotation" to aid dead code elimination by bundlers.
1021
+ *
1022
+ * @default false
1023
+ */
1024
+ pure?: boolean;
1025
+ /**
1026
+ * Adds a namespace prefix to component identifiers to ensure class names are unique.
1027
+ *
1028
+ * Example: With `namespace: "my-app"`, generates `componentId: "my-app__sc-3rfj0a-1"`
1029
+ */
1030
+ namespace?: string;
1031
+ /**
1032
+ * List of file names that are considered meaningless for component naming purposes.
1033
+ *
1034
+ * When the `fileName` option is enabled and a component is in a file with a name
1035
+ * from this list, the directory name will be used instead of the file name for
1036
+ * the component's display name.
1037
+ *
1038
+ * @default `["index"]`
1039
+ */
1040
+ meaninglessFileNames?: Array<string>;
1041
+ /**
1042
+ * Import paths to be considered as styled-components imports at the top level.
1043
+ *
1044
+ * **Note: This feature is not yet implemented in oxc.**
1045
+ */
1046
+ topLevelImportPaths?: Array<string>;
1047
+ }
1048
+ /**
1049
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
1050
+ *
1051
+ * Note: This function can be slower than `transform` due to the overhead of spawning a thread.
1052
+ *
1053
+ * @param filename The name of the file being transformed. If this is a
1054
+ * relative path, consider setting the {@link TransformOptions#cwd} option.
1055
+ * @param sourceText the source code itself
1056
+ * @param options The options for the transformation. See {@link
1057
+ * TransformOptions} for more information.
1058
+ *
1059
+ * @returns a promise that resolves to an object containing the transformed code,
1060
+ * source maps, and any errors that occurred during parsing or transformation.
1061
+ */
1062
+ declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): Promise<TransformResult>;
1063
+ /**
1064
+ * Options for transforming a JavaScript or TypeScript file.
1065
+ *
1066
+ * @see {@link transform}
1067
+ */
1068
+ interface TransformOptions {
1069
+ /** Treat the source text as `js`, `jsx`, `ts`, `tsx`, or `dts`. */
1070
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx' | 'dts';
1071
+ /** Treat the source text as `script` or `module` code. */
1072
+ sourceType?: 'script' | 'module' | 'commonjs' | 'unambiguous' | undefined;
1073
+ /**
1074
+ * The current working directory. Used to resolve relative paths in other
1075
+ * options.
1076
+ */
1077
+ cwd?: string;
1078
+ /**
1079
+ * Enable source map generation.
1080
+ *
1081
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
1082
+ *
1083
+ * @default false
1084
+ *
1085
+ * @see {@link SourceMap}
1086
+ */
1087
+ sourcemap?: boolean;
1088
+ /** Set assumptions in order to produce smaller output. */
1089
+ assumptions?: CompilerAssumptions;
1090
+ /** Configure how TypeScript is transformed. */
1091
+ typescript?: TypeScriptOptions;
1092
+ /** Configure how TSX and JSX are transformed. */
1093
+ jsx?: 'preserve' | JsxOptions;
1094
+ /**
1095
+ * Sets the target environment for the generated JavaScript.
1096
+ *
1097
+ * The lowest target is `es2015`.
1098
+ *
1099
+ * Example:
1100
+ *
1101
+ * * `'es2015'`
1102
+ * * `['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']`
1103
+ *
1104
+ * @default `esnext` (No transformation)
1105
+ *
1106
+ * @see [esbuild#target](https://esbuild.github.io/api/#target)
1107
+ */
1108
+ target?: string | Array<string>;
1109
+ /** Behaviour for runtime helpers. */
1110
+ helpers?: Helpers;
1111
+ /** Define Plugin */
1112
+ define?: Record<string, string>;
1113
+ /** Inject Plugin */
1114
+ inject?: Record<string, string | [string, string]>;
1115
+ /** Decorator plugin */
1116
+ decorator?: DecoratorOptions;
1117
+ /** Third-party plugins to use. */
1118
+ plugins?: PluginsOptions;
1119
+ }
1120
+ interface TransformResult {
1121
+ /**
1122
+ * The transformed code.
1123
+ *
1124
+ * If parsing failed, this will be an empty string.
1125
+ */
1126
+ code: string;
1127
+ /**
1128
+ * The source map for the transformed code.
1129
+ *
1130
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
1131
+ */
1132
+ map?: SourceMap;
1133
+ /**
1134
+ * The `.d.ts` declaration file for the transformed code. Declarations are
1135
+ * only generated if `declaration` is set to `true` and a TypeScript file
1136
+ * is provided.
1137
+ *
1138
+ * If parsing failed and `declaration` is set, this will be an empty string.
1139
+ *
1140
+ * @see {@link TypeScriptOptions#declaration}
1141
+ * @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
1142
+ */
1143
+ declaration?: string;
1144
+ /**
1145
+ * Declaration source map. Only generated if both
1146
+ * {@link TypeScriptOptions#declaration declaration} and
1147
+ * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
1148
+ */
1149
+ declarationMap?: SourceMap;
1150
+ /**
1151
+ * Helpers used.
1152
+ *
1153
+ * @internal
1154
+ *
1155
+ * Example:
1156
+ *
1157
+ * ```text
1158
+ * { "_objectSpread": "@oxc-project/runtime/helpers/objectSpread2" }
1159
+ * ```
1160
+ */
1161
+ helpersUsed: Record<string, string>;
1162
+ /**
1163
+ * Parse and transformation errors.
1164
+ *
1165
+ * Oxc's parser recovers from common syntax errors, meaning that
1166
+ * transformed code may still be available even if there are errors in this
1167
+ * list.
1168
+ */
1169
+ errors: Array<OxcError>;
1170
+ }
1171
+ /**
1172
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version.
1173
+ *
1174
+ * @param filename The name of the file being transformed. If this is a
1175
+ * relative path, consider setting the {@link TransformOptions#cwd} option..
1176
+ * @param sourceText the source code itself
1177
+ * @param options The options for the transformation. See {@link
1178
+ * TransformOptions} for more information.
1179
+ *
1180
+ * @returns an object containing the transformed code, source maps, and any
1181
+ * errors that occurred during parsing or transformation.
1182
+ */
1183
+ declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult;
1184
+ interface TypeScriptOptions {
1185
+ jsxPragma?: string;
1186
+ jsxPragmaFrag?: string;
1187
+ onlyRemoveTypeImports?: boolean;
1188
+ allowNamespaces?: boolean;
1189
+ /**
1190
+ * When enabled, type-only class fields are only removed if they are prefixed with the declare modifier:
1191
+ *
1192
+ * @deprecated
1193
+ *
1194
+ * Allowing `declare` fields is built-in support in Oxc without any option. If you want to remove class fields
1195
+ * without initializer, you can use `remove_class_fields_without_initializer: true` instead.
1196
+ */
1197
+ allowDeclareFields?: boolean;
1198
+ /**
1199
+ * When enabled, class fields without initializers are removed.
1200
+ *
1201
+ * For example:
1202
+ * ```ts
1203
+ * class Foo {
1204
+ * x: number;
1205
+ * y: number = 0;
1206
+ * }
1207
+ * ```
1208
+ * // transform into
1209
+ * ```js
1210
+ * class Foo {
1211
+ * x: number;
1212
+ * }
1213
+ * ```
1214
+ *
1215
+ * The option is used to align with the behavior of TypeScript's `useDefineForClassFields: false` option.
1216
+ * When you want to enable this, you also need to set [`crate::CompilerAssumptions::set_public_class_fields`]
1217
+ * to `true`. The `set_public_class_fields: true` + `remove_class_fields_without_initializer: true` is
1218
+ * equivalent to `useDefineForClassFields: false` in TypeScript.
1219
+ *
1220
+ * When `set_public_class_fields` is true and class-properties plugin is enabled, the above example transforms into:
1221
+ *
1222
+ * ```js
1223
+ * class Foo {
1224
+ * constructor() {
1225
+ * this.y = 0;
1226
+ * }
1227
+ * }
1228
+ * ```
1229
+ *
1230
+ * Defaults to `false`.
1231
+ */
1232
+ removeClassFieldsWithoutInitializer?: boolean;
1233
+ /**
1234
+ * Also generate a `.d.ts` declaration file for TypeScript files.
1235
+ *
1236
+ * The source file must be compliant with all
1237
+ * [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
1238
+ * requirements.
1239
+ *
1240
+ * @default false
1241
+ */
1242
+ declaration?: IsolatedDeclarationsOptions;
1243
+ /**
1244
+ * Rewrite or remove TypeScript import/export declaration extensions.
1245
+ *
1246
+ * - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
1247
+ * - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
1248
+ * - When set to `true`, it's equivalent to `rewrite`.
1249
+ * - When set to `false` or omitted, no changes will be made to the extensions.
1250
+ *
1251
+ * @default false
1252
+ */
1253
+ rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
1254
+ }
1255
+ /** A decoded source map with mappings as an array of arrays instead of VLQ-encoded string. */
1256
+ declare class BindingDecodedMap {
1257
+ /** The source map version (always 3). */
1258
+ get version(): number;
1259
+ /** The generated file name. */
1260
+ get file(): string | null;
1261
+ /** The list of original source files. */
1262
+ get sources(): Array<string>;
1263
+ /** The original source contents (if `includeContent` was true). */
1264
+ get sourcesContent(): Array<string | undefined | null>;
1265
+ /** The list of symbol names used in mappings. */
1266
+ get names(): Array<string>;
1267
+ /**
1268
+ * The decoded mappings as an array of line arrays.
1269
+ * Each line is an array of segments, where each segment is [generatedColumn, sourceIndex, originalLine, originalColumn, nameIndex?].
1270
+ */
1271
+ get mappings(): Array<Array<Array<number>>>;
1272
+ }
1273
+ declare class BindingMagicString {
1274
+ constructor(source: string, options?: BindingMagicStringOptions | undefined | null);
1275
+ get filename(): string | null;
1276
+ replace(from: string, to: string): this;
1277
+ replaceAll(from: string, to: string): this;
1278
+ prepend(content: string): this;
1279
+ append(content: string): this;
1280
+ prependLeft(index: number, content: string): this;
1281
+ prependRight(index: number, content: string): this;
1282
+ appendLeft(index: number, content: string): this;
1283
+ appendRight(index: number, content: string): this;
1284
+ overwrite(start: number, end: number, content: string): this;
1285
+ toString(): string;
1286
+ hasChanged(): boolean;
1287
+ length(): number;
1288
+ isEmpty(): boolean;
1289
+ remove(start: number, end: number): this;
1290
+ update(start: number, end: number, content: string): this;
1291
+ relocate(start: number, end: number, to: number): this;
1292
+ /**
1293
+ * Alias for `relocate` to match the original magic-string API.
1294
+ * Moves the characters from `start` to `end` to `index`.
1295
+ * Returns `this` for method chaining.
1296
+ */
1297
+ move(start: number, end: number, index: number): this;
1298
+ indent(indentor?: string | undefined | null): this;
1299
+ /** Trims whitespace or specified characters from the start and end. */
1300
+ trim(charType?: string | undefined | null): this;
1301
+ /** Trims whitespace or specified characters from the start. */
1302
+ trimStart(charType?: string | undefined | null): this;
1303
+ /** Trims whitespace or specified characters from the end. */
1304
+ trimEnd(charType?: string | undefined | null): this;
1305
+ /** Trims newlines from the start and end. */
1306
+ trimLines(): this;
1307
+ /**
1308
+ * Deprecated method that throws an error directing users to use prependRight or appendLeft.
1309
+ * This matches the original magic-string API which deprecated this method.
1310
+ */
1311
+ insert(index: number, content: string): void;
1312
+ /** Returns a clone of the MagicString instance. */
1313
+ clone(): BindingMagicString;
1314
+ /** Returns the last character of the generated string, or an empty string if empty. */
1315
+ lastChar(): string;
1316
+ /** Returns the content after the last newline in the generated string. */
1317
+ lastLine(): string;
1318
+ /** Returns a clone with content outside the specified range removed. */
1319
+ snip(start: number, end: number): BindingMagicString;
1320
+ /**
1321
+ * Resets the portion of the string from `start` to `end` to its original content.
1322
+ * This undoes any modifications made to that range.
1323
+ * Supports negative indices (counting from the end).
1324
+ */
1325
+ reset(start: number, end: number): this;
1326
+ /**
1327
+ * Returns the content between the specified original character positions.
1328
+ * Supports negative indices (counting from the end).
1329
+ */
1330
+ slice(start?: number | undefined | null, end?: number | undefined | null): string;
1331
+ /**
1332
+ * Generates a source map for the transformations applied to this MagicString.
1333
+ * Returns a BindingSourceMap object with version, file, sources, sourcesContent, names, mappings.
1334
+ */
1335
+ generateMap(options?: BindingSourceMapOptions | undefined | null): BindingSourceMap;
1336
+ /**
1337
+ * Generates a decoded source map for the transformations applied to this MagicString.
1338
+ * Returns a BindingDecodedMap object with mappings as an array of arrays.
1339
+ */
1340
+ generateDecodedMap(options?: BindingSourceMapOptions | undefined | null): BindingDecodedMap;
1341
+ }
1342
+ declare class BindingNormalizedOptions {
1343
+ get input(): Array<string> | Record<string, string>;
1344
+ get cwd(): string;
1345
+ get platform(): 'node' | 'browser' | 'neutral';
1346
+ get shimMissingExports(): boolean;
1347
+ get name(): string | null;
1348
+ get cssEntryFilenames(): string | undefined;
1349
+ get cssChunkFilenames(): string | undefined;
1350
+ get entryFilenames(): string | undefined;
1351
+ get chunkFilenames(): string | undefined;
1352
+ get assetFilenames(): string | undefined;
1353
+ get dir(): string | null;
1354
+ get file(): string | null;
1355
+ get format(): 'es' | 'cjs' | 'iife' | 'umd';
1356
+ get exports(): 'default' | 'named' | 'none' | 'auto';
1357
+ get esModule(): boolean | 'if-default-prop';
1358
+ get codeSplitting(): boolean;
1359
+ get dynamicImportInCjs(): boolean;
1360
+ get sourcemap(): boolean | 'inline' | 'hidden';
1361
+ get sourcemapBaseUrl(): string | null;
1362
+ get banner(): string | undefined | null | undefined;
1363
+ get footer(): string | undefined | null | undefined;
1364
+ get intro(): string | undefined | null | undefined;
1365
+ get outro(): string | undefined | null | undefined;
1366
+ get postBanner(): string | undefined | null | undefined;
1367
+ get postFooter(): string | undefined | null | undefined;
1368
+ get externalLiveBindings(): boolean;
1369
+ get extend(): boolean;
1370
+ get globals(): Record<string, string> | undefined;
1371
+ get hashCharacters(): 'base64' | 'base36' | 'hex';
1372
+ get sourcemapDebugIds(): boolean;
1373
+ get polyfillRequire(): boolean;
1374
+ get minify(): false | 'dce-only' | MinifyOptions;
1375
+ get legalComments(): 'none' | 'inline';
1376
+ get preserveModules(): boolean;
1377
+ get preserveModulesRoot(): string | undefined;
1378
+ get virtualDirname(): string;
1379
+ get topLevelVar(): boolean;
1380
+ get minifyInternalExports(): boolean;
1381
+ get context(): string;
1382
+ }
1383
+ declare class BindingRenderedChunk {
1384
+ get name(): string;
1385
+ get isEntry(): boolean;
1386
+ get isDynamicEntry(): boolean;
1387
+ get facadeModuleId(): string | null;
1388
+ get moduleIds(): Array<string>;
1389
+ get exports(): Array<string>;
1390
+ get fileName(): string;
1391
+ get modules(): BindingModules;
1392
+ get imports(): Array<string>;
1393
+ get dynamicImports(): Array<string>;
1394
+ }
1395
+ declare class BindingRenderedModule {
1396
+ get code(): string | null;
1397
+ get renderedExports(): Array<string>;
1398
+ }
1399
+ /** A source map object with properties matching the SourceMap V3 specification. */
1400
+ declare class BindingSourceMap {
1401
+ /** The source map version (always 3). */
1402
+ get version(): number;
1403
+ /** The generated file name. */
1404
+ get file(): string | null;
1405
+ /** The list of original source files. */
1406
+ get sources(): Array<string>;
1407
+ /** The original source contents (if `includeContent` was true). */
1408
+ get sourcesContent(): Array<string | undefined | null>;
1409
+ /** The list of symbol names used in mappings. */
1410
+ get names(): Array<string>;
1411
+ /** The VLQ-encoded mappings string. */
1412
+ get mappings(): string;
1413
+ /** Returns the source map as a JSON string. */
1414
+ toString(): string;
1415
+ /** Returns the source map as a base64-encoded data URL. */
1416
+ toUrl(): string;
1417
+ }
1418
+ /**
1419
+ * Minimal wrapper around the core `Bundler` for watcher events.
1420
+ * This is returned from watcher event data to allow access to the bundler instance.
1421
+ */
1422
+ declare class BindingWatcherBundler {
1423
+ close(): Promise<void>;
1424
+ }
1425
+ type BindingBuiltinPluginName = 'builtin:esm-external-require' | 'builtin:isolated-declaration' | 'builtin:replace' | 'builtin:vite-alias' | 'builtin:vite-build-import-analysis' | 'builtin:vite-dynamic-import-vars' | 'builtin:vite-import-glob' | 'builtin:vite-json' | 'builtin:vite-load-fallback' | 'builtin:vite-manifest' | 'builtin:vite-module-preload-polyfill' | 'builtin:vite-react-refresh-wrapper' | 'builtin:vite-reporter' | 'builtin:vite-resolve' | 'builtin:vite-transform' | 'builtin:vite-wasm-fallback' | 'builtin:vite-wasm-helper' | 'builtin:vite-web-worker-post';
1426
+ interface BindingBundleState {
1427
+ lastFullBuildFailed: boolean;
1428
+ hasStaleOutput: boolean;
1429
+ }
1430
+ interface BindingClientHmrUpdate {
1431
+ clientId: string;
1432
+ update: BindingHmrUpdate;
1433
+ }
1434
+ interface BindingEsmExternalRequirePluginConfig {
1435
+ external: Array<BindingStringOrRegex>;
1436
+ skipDuplicateCheck?: boolean;
1437
+ }
1438
+ interface BindingHmrBoundaryOutput {
1439
+ boundary: string;
1440
+ acceptedVia: string;
1441
+ }
1442
+ type BindingHmrUpdate = {
1443
+ type: 'Patch';
1444
+ code: string;
1445
+ filename: string;
1446
+ sourcemap?: string;
1447
+ sourcemapFilename?: string;
1448
+ hmrBoundaries: Array<BindingHmrBoundaryOutput>;
1449
+ } | {
1450
+ type: 'FullReload';
1451
+ reason?: string;
1452
+ } | {
1453
+ type: 'Noop';
1454
+ };
1455
+ interface BindingHookResolveIdExtraArgs {
1456
+ custom?: number;
1457
+ isEntry: boolean;
1458
+ /**
1459
+ * - `import-statement`: `import { foo } from './lib.js';`
1460
+ * - `dynamic-import`: `import('./lib.js')`
1461
+ * - `require-call`: `require('./lib.js')`
1462
+ * - `import-rule`: `@import 'bg-color.css'`
1463
+ * - `url-token`: `url('./icon.png')`
1464
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
1465
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
1466
+ */
1467
+ kind: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
1468
+ }
1469
+ interface BindingIsolatedDeclarationPluginConfig {
1470
+ stripInternal?: boolean;
1471
+ }
1472
+ interface BindingMagicStringOptions {
1473
+ filename?: string;
1474
+ }
1475
+ interface BindingModulePreloadOptions {
1476
+ polyfill: boolean;
1477
+ resolveDependencies?: (filename: string, deps: string[], context: {
1478
+ hostId: string;
1479
+ hostType: 'html' | 'js';
1480
+ }) => string[];
1481
+ }
1482
+ interface BindingModules {
1483
+ values: Array<BindingRenderedModule>;
1484
+ keys: Array<string>;
1485
+ }
1486
+ interface BindingPluginContextResolveOptions {
1487
+ /**
1488
+ * - `import-statement`: `import { foo } from './lib.js';`
1489
+ * - `dynamic-import`: `import('./lib.js')`
1490
+ * - `require-call`: `require('./lib.js')`
1491
+ * - `import-rule`: `@import 'bg-color.css'`
1492
+ * - `url-token`: `url('./icon.png')`
1493
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
1494
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
1495
+ */
1496
+ importKind?: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
1497
+ isEntry?: boolean;
1498
+ skipSelf?: boolean;
1499
+ custom?: number;
1500
+ vitePluginCustom?: BindingVitePluginCustom;
1501
+ }
1502
+ declare enum BindingRebuildStrategy {
1503
+ Always = 0,
1504
+ Auto = 1,
1505
+ Never = 2,
1506
+ }
1507
+ interface BindingRenderBuiltUrlConfig {
1508
+ ssr: boolean;
1509
+ type: 'asset' | 'public';
1510
+ hostId: string;
1511
+ hostType: 'js' | 'css' | 'html';
1512
+ }
1513
+ interface BindingRenderBuiltUrlRet {
1514
+ relative?: boolean;
1515
+ runtime?: string;
1516
+ }
1517
+ interface BindingReplacePluginConfig {
1518
+ values: Record<string, string>;
1519
+ delimiters?: [string, string];
1520
+ preventAssignment?: boolean;
1521
+ objectGuards?: boolean;
1522
+ sourcemap?: boolean;
1523
+ }
1524
+ interface BindingSourceMapOptions {
1525
+ /** The filename for the generated file (goes into `map.file`) */
1526
+ file?: string;
1527
+ /** The filename of the original source (goes into `map.sources`) */
1528
+ source?: string;
1529
+ includeContent?: boolean;
1530
+ /**
1531
+ * Accepts boolean or string: true, false, "boundary"
1532
+ * - true: high-resolution sourcemaps (character-level)
1533
+ * - false: low-resolution sourcemaps (line-level) - default
1534
+ * - "boundary": high-resolution only at word boundaries
1535
+ */
1536
+ hires?: boolean | string;
1537
+ }
1538
+ interface BindingTransformHookExtraArgs {
1539
+ moduleType: string;
1540
+ }
1541
+ interface BindingViteBuildImportAnalysisPluginConfig {
1542
+ preloadCode: string;
1543
+ insertPreload: boolean;
1544
+ optimizeModulePreloadRelativePaths: boolean;
1545
+ renderBuiltUrl: boolean;
1546
+ isRelativeBase: boolean;
1547
+ v2?: BindingViteBuildImportAnalysisPluginV2Config;
1548
+ }
1549
+ interface BindingViteBuildImportAnalysisPluginV2Config {
1550
+ isSsr: boolean;
1551
+ urlBase: string;
1552
+ decodedBase: string;
1553
+ modulePreload: false | BindingModulePreloadOptions;
1554
+ renderBuiltUrl?: (filename: string, type: BindingRenderBuiltUrlConfig) => undefined | string | BindingRenderBuiltUrlRet;
1555
+ }
1556
+ interface BindingViteDynamicImportVarsPluginConfig {
1557
+ include?: Array<BindingStringOrRegex>;
1558
+ exclude?: Array<BindingStringOrRegex>;
1559
+ resolver?: (id: string, importer: string) => MaybePromise<string | undefined>;
1560
+ isV2?: BindingViteDynamicImportVarsPluginV2Config;
1561
+ }
1562
+ interface BindingViteDynamicImportVarsPluginV2Config {
1563
+ sourcemap: boolean;
1564
+ }
1565
+ interface BindingViteImportGlobPluginConfig {
1566
+ root?: string;
1567
+ restoreQueryExtension?: boolean;
1568
+ isV2?: BindingViteImportGlobPluginV2Config;
1569
+ }
1570
+ interface BindingViteImportGlobPluginV2Config {
1571
+ sourcemap?: boolean;
1572
+ }
1573
+ interface BindingViteJsonPluginConfig {
1574
+ minify?: boolean;
1575
+ namedExports?: boolean;
1576
+ stringify?: BindingViteJsonPluginStringify;
1577
+ }
1578
+ type BindingViteJsonPluginStringify = boolean | string;
1579
+ interface BindingViteManifestPluginConfig {
1580
+ root: string;
1581
+ outPath: string;
1582
+ isEnableV2?: boolean;
1583
+ isLegacy?: (args: BindingNormalizedOptions) => boolean;
1584
+ cssEntries: () => Record<string, string>;
1585
+ }
1586
+ interface BindingViteModulePreloadPolyfillPluginConfig {
1587
+ isServer?: boolean;
1588
+ }
1589
+ interface BindingVitePluginCustom {
1590
+ 'vite:import-glob'?: ViteImportGlobMeta;
1591
+ }
1592
+ interface BindingViteReactRefreshWrapperPluginConfig {
1593
+ cwd: string;
1594
+ include?: Array<BindingStringOrRegex>;
1595
+ exclude?: Array<BindingStringOrRegex>;
1596
+ jsxImportSource: string;
1597
+ reactRefreshHost: string;
1598
+ }
1599
+ interface BindingViteReporterPluginConfig {
1600
+ root: string;
1601
+ isTty: boolean;
1602
+ isLib: boolean;
1603
+ assetsDir: string;
1604
+ chunkLimit: number;
1605
+ shouldLogInfo: boolean;
1606
+ warnLargeChunks: boolean;
1607
+ reportCompressedSize: boolean;
1608
+ }
1609
+ interface BindingViteResolvePluginConfig {
1610
+ resolveOptions: BindingViteResolvePluginResolveOptions;
1611
+ environmentConsumer: string;
1612
+ environmentName: string;
1613
+ builtins: Array<BindingStringOrRegex>;
1614
+ external: true | string[];
1615
+ noExternal: true | Array<string | RegExp>;
1616
+ dedupe: Array<string>;
1617
+ disableCache?: boolean;
1618
+ legacyInconsistentCjsInterop?: boolean;
1619
+ finalizeBareSpecifier?: (resolvedId: string, rawId: string, importer: string | null | undefined) => VoidNullable<string>;
1620
+ finalizeOtherSpecifiers?: (resolvedId: string, rawId: string) => VoidNullable<string>;
1621
+ resolveSubpathImports: (id: string, importer: string, isRequire: boolean, scan: boolean) => VoidNullable<string>;
1622
+ onWarn?: (message: string) => void;
1623
+ onDebug?: (message: string) => void;
1624
+ yarnPnp: boolean;
1625
+ }
1626
+ interface BindingViteResolvePluginResolveOptions {
1627
+ isBuild: boolean;
1628
+ isProduction: boolean;
1629
+ asSrc: boolean;
1630
+ preferRelative: boolean;
1631
+ isRequire?: boolean;
1632
+ root: string;
1633
+ scan: boolean;
1634
+ mainFields: Array<string>;
1635
+ conditions: Array<string>;
1636
+ externalConditions: Array<string>;
1637
+ extensions: Array<string>;
1638
+ tryIndex: boolean;
1639
+ tryPrefix?: string;
1640
+ preserveSymlinks: boolean;
1641
+ tsconfigPaths: boolean;
1642
+ }
1643
+ interface BindingViteTransformPluginConfig {
1644
+ root: string;
1645
+ include?: Array<BindingStringOrRegex>;
1646
+ exclude?: Array<BindingStringOrRegex>;
1647
+ jsxRefreshInclude?: Array<BindingStringOrRegex>;
1648
+ jsxRefreshExclude?: Array<BindingStringOrRegex>;
1649
+ isServerConsumer?: boolean;
1650
+ jsxInject?: string;
1651
+ transformOptions?: TransformOptions;
1652
+ yarnPnp?: boolean;
1653
+ }
1654
+ interface BindingViteWasmHelperPluginConfig {
1655
+ decodedBase: string;
1656
+ v2?: BindingViteWasmHelperPluginV2Config;
1657
+ }
1658
+ interface BindingViteWasmHelperPluginV2Config {
1659
+ root: string;
1660
+ isLib: boolean;
1661
+ publicDir: string;
1662
+ assetInlineLimit: number | ((file: string, content: Buffer) => boolean | undefined);
1663
+ }
1664
+ declare function createTokioRuntime(blockingThreads?: number | undefined | null): void;
1665
+ interface ExternalMemoryStatus {
1666
+ freed: boolean;
1667
+ reason?: string;
1668
+ }
1669
+ interface PreRenderedChunk {
1670
+ /** The name of this chunk, which is used in naming patterns. */
1671
+ name: string;
1672
+ /** Whether this chunk is a static entry point. */
1673
+ isEntry: boolean;
1674
+ /** Whether this chunk is a dynamic entry point. */
1675
+ isDynamicEntry: boolean;
1676
+ /** The id of a module that this chunk corresponds to. */
1677
+ facadeModuleId?: string;
1678
+ /** The list of ids of modules included in this chunk. */
1679
+ moduleIds: Array<string>;
1680
+ /** Exported variable names from this chunk. */
1681
+ exports: Array<string>;
1682
+ }
1683
+ interface ViteImportGlobMeta {
1684
+ isSubImportsPattern?: boolean;
1685
+ }
1686
+ //#endregion
1687
+ export { MinifyResult as A, isolatedDeclaration as B, BindingViteWasmHelperPluginConfig as C, IsolatedDeclarationsResult as D, IsolatedDeclarationsOptions as E, ResolveResult as F, transform as G, minify as H, ResolverFactory as I, transformSync as K, TransformOptions as L, ParseResult as M, ParserOptions as N, JsxOptions as O, PreRenderedChunk as P, TransformResult as R, BindingViteTransformPluginConfig as S, ExternalMemoryStatus as T, minifySync as U, isolatedDeclarationSync as V, moduleRunnerTransform as W, BindingViteManifestPluginConfig as _, BindingHookResolveIdExtraArgs as a, BindingViteReporterPluginConfig as b, BindingPluginContextResolveOptions as c, BindingReplacePluginConfig as d, BindingTransformHookExtraArgs as f, BindingViteJsonPluginConfig as g, BindingViteImportGlobPluginConfig as h, BindingEsmExternalRequirePluginConfig as i, NapiResolveOptions as j, MinifyOptions as k, BindingRebuildStrategy as l, BindingViteDynamicImportVarsPluginConfig as m, BindingBundleState as n, BindingIsolatedDeclarationPluginConfig as o, BindingViteBuildImportAnalysisPluginConfig as p, BindingClientHmrUpdate as r, BindingMagicString as s, BindingBuiltinPluginName as t, BindingRenderedChunk as u, BindingViteModulePreloadPolyfillPluginConfig as v, BindingWatcherBundler as w, BindingViteResolvePluginConfig as x, BindingViteReactRefreshWrapperPluginConfig as y, createTokioRuntime as z };