@rollipop/rolldown 0.0.0-beta.0 → 0.0.0

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