@rolldown/browser 1.0.0-beta.10-commit.81375fe → 1.0.0-beta.10-commit.885ee53

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 (37) hide show
  1. package/dist/cli.cjs +2 -2
  2. package/dist/cli.mjs +2 -2
  3. package/dist/config.cjs +2 -2
  4. package/dist/config.d.cts +2 -3
  5. package/dist/config.d.mts +2 -3
  6. package/dist/config.mjs +2 -2
  7. package/dist/experimental-index.browser.mjs +1 -1
  8. package/dist/experimental-index.cjs +1 -1
  9. package/dist/experimental-index.d.cts +13 -44
  10. package/dist/experimental-index.d.mts +13 -44
  11. package/dist/experimental-index.mjs +1 -1
  12. package/dist/filter-index.d.cts +3 -2
  13. package/dist/filter-index.d.mts +3 -2
  14. package/dist/index.browser.mjs +1 -1
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.mjs +1 -1
  19. package/dist/parallel-plugin-worker.cjs +1 -1
  20. package/dist/parallel-plugin-worker.mjs +1 -1
  21. package/dist/parallel-plugin.d.cts +6 -6
  22. package/dist/parallel-plugin.d.mts +6 -6
  23. package/dist/parse-ast-index.d.cts +2 -2
  24. package/dist/parse-ast-index.d.mts +2 -2
  25. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  26. package/dist/shared/binding-BYafUgFF.d.cts +1652 -0
  27. package/dist/shared/binding-Dod8fhx9.d.mts +1652 -0
  28. package/dist/shared/define-config-BetvTt9D.d.cts +1048 -0
  29. package/dist/shared/define-config-cqCLLLZ-.d.mts +1048 -0
  30. package/dist/shared/{load-config-Cr472rVH.cjs → load-config-0bnuUeT5.cjs} +1 -1
  31. package/dist/shared/{load-config-a5TDbL5U.mjs → load-config-F7nMcxMb.mjs} +1 -1
  32. package/dist/shared/{src-Mp5z-lgE.mjs → src-6t_bV_L5.mjs} +46 -16
  33. package/dist/shared/{src-Cd6dJVwS.cjs → src-B3FAi7gC.cjs} +46 -16
  34. package/dist/{src--mQWdm3h.js → src-1eaUHc8G.js} +46 -16
  35. package/package.json +1 -1
  36. package/dist/shared/define-config.d-BDJzbjFe.d.mts +0 -1168
  37. package/dist/shared/define-config.d-C0X0fNDk.d.cts +0 -1168
@@ -0,0 +1,1652 @@
1
+ import * as _oxc_project_types0 from "@oxc-project/types";
2
+
3
+ //#region src/binding.d.ts
4
+ type MaybePromise<T> = T | Promise<T>;
5
+ type Nullable<T> = T | null | undefined;
6
+ type VoidNullable<T = void> = T | null | undefined | void;
7
+ type BindingStringOrRegex = string | RegExp;
8
+ declare class BindingBundleEndEventData {
9
+ output: string;
10
+ duration: number;
11
+ get result(): Bundler;
12
+ }
13
+ declare class BindingBundleErrorEventData {
14
+ get result(): Bundler;
15
+ get error(): Array<Error | BindingError>;
16
+ }
17
+ declare class BindingError {
18
+ kind: string;
19
+ message: string;
20
+ }
21
+ declare class BindingModuleInfo {
22
+ id: string;
23
+ importers: Array<string>;
24
+ dynamicImporters: Array<string>;
25
+ importedIds: Array<string>;
26
+ dynamicallyImportedIds: Array<string>;
27
+ exports: Array<string>;
28
+ isEntry: boolean;
29
+ get code(): string | null;
30
+ }
31
+ declare class BindingNormalizedOptions {
32
+ get input(): Array<string> | Record<string, string>;
33
+ get cwd(): string | null;
34
+ get platform(): 'node' | 'browser' | 'neutral';
35
+ get shimMissingExports(): boolean;
36
+ get name(): string | null;
37
+ get cssEntryFilenames(): string | undefined;
38
+ get cssChunkFilenames(): string | undefined;
39
+ get entryFilenames(): string | undefined;
40
+ get chunkFilenames(): string | undefined;
41
+ get assetFilenames(): string | undefined;
42
+ get dir(): string | null;
43
+ get file(): string | null;
44
+ get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd';
45
+ get exports(): 'default' | 'named' | 'none' | 'auto';
46
+ get esModule(): boolean | 'if-default-prop';
47
+ get inlineDynamicImports(): boolean;
48
+ get sourcemap(): boolean | 'inline' | 'hidden';
49
+ get banner(): string | undefined | null | undefined;
50
+ get footer(): string | undefined | null | undefined;
51
+ get intro(): string | undefined | null | undefined;
52
+ get outro(): string | undefined | null | undefined;
53
+ get externalLiveBindings(): boolean;
54
+ get extend(): boolean;
55
+ get globals(): Record<string, string> | undefined;
56
+ get hashCharacters(): 'base64' | 'base36' | 'hex';
57
+ get sourcemapDebugIds(): boolean;
58
+ get minify(): false | BindingMinifyOptions;
59
+ get polyfillRequire(): boolean;
60
+ get legalComments(): 'none' | 'inline';
61
+ }
62
+ declare class BindingOutputAsset {
63
+ get fileName(): string;
64
+ get originalFileName(): string | null;
65
+ get originalFileNames(): Array<string>;
66
+ get source(): BindingAssetSource;
67
+ get name(): string | null;
68
+ get names(): Array<string>;
69
+ }
70
+ declare class BindingOutputChunk {
71
+ get isEntry(): boolean;
72
+ get isDynamicEntry(): boolean;
73
+ get facadeModuleId(): string | null;
74
+ get moduleIds(): Array<string>;
75
+ get exports(): Array<string>;
76
+ get fileName(): string;
77
+ get modules(): BindingModules;
78
+ get imports(): Array<string>;
79
+ get dynamicImports(): Array<string>;
80
+ get code(): string;
81
+ get map(): string | null;
82
+ get sourcemapFileName(): string | null;
83
+ get preliminaryFileName(): string;
84
+ get name(): string;
85
+ }
86
+ declare class BindingOutputs {
87
+ get chunks(): Array<BindingOutputChunk>;
88
+ get assets(): Array<BindingOutputAsset>;
89
+ get errors(): Array<Error | BindingError>;
90
+ }
91
+ declare class BindingPluginContext {
92
+ load(specifier: string, sideEffects: BindingHookSideEffects | undefined): Promise<void>;
93
+ resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>;
94
+ emitFile(file: BindingEmittedAsset, assetFilename?: string | undefined | null, fnSanitizedFileName?: string | undefined | null): string;
95
+ emitChunk(file: BindingEmittedChunk): string;
96
+ getFileName(referenceId: string): string;
97
+ getModuleInfo(moduleId: string): BindingModuleInfo | null;
98
+ getModuleIds(): Array<string>;
99
+ addWatchFile(file: string): void;
100
+ }
101
+ declare class BindingRenderedChunk {
102
+ get name(): string;
103
+ get isEntry(): boolean;
104
+ get isDynamicEntry(): boolean;
105
+ get facadeModuleId(): string | null;
106
+ get moduleIds(): Array<string>;
107
+ get exports(): Array<string>;
108
+ get fileName(): string;
109
+ get modules(): BindingModules;
110
+ get imports(): Array<string>;
111
+ get dynamicImports(): Array<string>;
112
+ }
113
+ declare class BindingRenderedChunkMeta {
114
+ get chunks(): Record<string, BindingRenderedChunk>;
115
+ }
116
+ declare class BindingRenderedModule {
117
+ get code(): string | null;
118
+ get renderedExports(): Array<string>;
119
+ }
120
+ declare class BindingTransformPluginContext {
121
+ getCombinedSourcemap(): string;
122
+ inner(): BindingPluginContext;
123
+ }
124
+ declare class BindingWatcherChangeData {
125
+ path: string;
126
+ kind: string;
127
+ }
128
+ declare class BindingWatcherEvent {
129
+ eventKind(): string;
130
+ watchChangeData(): BindingWatcherChangeData;
131
+ bundleEndData(): BindingBundleEndEventData;
132
+ bundleEventKind(): string;
133
+ bundleErrorData(): BindingBundleErrorEventData;
134
+ }
135
+ declare class Bundler {
136
+ constructor(option: BindingBundlerOptions);
137
+ write(): Promise<BindingOutputs>;
138
+ generate(): Promise<BindingOutputs>;
139
+ scan(): Promise<BindingOutputs>;
140
+ close(): Promise<void>;
141
+ get closed(): boolean;
142
+ getWatchFiles(): Promise<Array<string>>;
143
+ generateHmrPatch(changedFiles: Array<string>): Promise<BindingHmrOutput>;
144
+ hmrInvalidate(file: string, firstInvalidatedBy?: string | undefined | null): Promise<BindingHmrOutput>;
145
+ }
146
+ declare class ParallelJsPluginRegistry {
147
+ id: number;
148
+ workerCount: number;
149
+ constructor(workerCount: number);
150
+ }
151
+ declare class ParseResult {
152
+ get program(): _oxc_project_types0.Program;
153
+ get module(): EcmaScriptModule;
154
+ get comments(): Array<Comment>;
155
+ get errors(): Array<OxcError>;
156
+ }
157
+ declare class ResolverFactory {
158
+ constructor(options?: NapiResolveOptions | undefined | null);
159
+ static default(): ResolverFactory;
160
+ /** Clone the resolver using the same underlying cache. */
161
+ cloneWithOptions(options: NapiResolveOptions): ResolverFactory;
162
+ /** Clear the underlying cache. */
163
+ clearCache(): void;
164
+ /** Synchronously resolve `specifier` at an absolute path to a `directory`. */
165
+ sync(directory: string, request: string): ResolveResult;
166
+ /** Asynchronously resolve `specifier` at an absolute path to a `directory`. */
167
+ async(directory: string, request: string): Promise<ResolveResult>;
168
+ }
169
+ interface AliasItem {
170
+ find: string;
171
+ replacements: Array<string>;
172
+ }
173
+ interface BindingAdvancedChunksOptions {
174
+ minSize?: number;
175
+ minShareCount?: number;
176
+ groups?: Array<BindingMatchGroup>;
177
+ maxSize?: number;
178
+ minModuleSize?: number;
179
+ maxModuleSize?: number;
180
+ }
181
+ interface BindingAssetPluginConfig {
182
+ isServer?: boolean;
183
+ urlBase?: string;
184
+ publicDir?: string;
185
+ assetsInclude?: Array<BindingStringOrRegex>;
186
+ }
187
+ interface BindingAssetSource {
188
+ inner: string | Uint8Array;
189
+ }
190
+ interface BindingBuildImportAnalysisPluginConfig {
191
+ preloadCode: string;
192
+ insertPreload: boolean;
193
+ optimizeModulePreloadRelativePaths: boolean;
194
+ renderBuiltUrl: boolean;
195
+ isRelativeBase: boolean;
196
+ }
197
+ interface BindingBuiltinPlugin {
198
+ __name: BindingBuiltinPluginName;
199
+ options?: unknown;
200
+ }
201
+ type BindingBuiltinPluginName = 'builtin:alias' | 'builtin:asset' | 'builtin:asset-import-meta-url' | 'builtin:build-import-analysis' | 'builtin:dynamic-import-vars' | 'builtin:import-glob' | 'builtin:isolated-declaration' | 'builtin:json' | 'builtin:load-fallback' | 'builtin:manifest' | 'builtin:module-federation' | 'builtin:module-preload-polyfill' | 'builtin:oxc-runtime' | 'builtin:reporter' | 'builtin:replace' | 'builtin:transform' | 'builtin:vite-resolve' | 'builtin:wasm-fallback' | 'builtin:wasm-helper' | 'builtin:web-worker-post';
202
+ interface BindingBundlerOptions {
203
+ inputOptions: BindingInputOptions;
204
+ outputOptions: BindingOutputOptions;
205
+ parallelPluginsRegistry?: ParallelJsPluginRegistry;
206
+ }
207
+ interface BindingChecksOptions {
208
+ circularDependency?: boolean;
209
+ eval?: boolean;
210
+ missingGlobalName?: boolean;
211
+ missingNameOptionForIifeExport?: boolean;
212
+ mixedExport?: boolean;
213
+ unresolvedEntry?: boolean;
214
+ unresolvedImport?: boolean;
215
+ filenameConflict?: boolean;
216
+ commonJsVariableInEsm?: boolean;
217
+ importIsUndefined?: boolean;
218
+ configurationFieldConflict?: boolean;
219
+ }
220
+ interface BindingDebugOptions {
221
+ sessionId?: string;
222
+ }
223
+ interface BindingDeferSyncScanData {
224
+ /** ModuleId */
225
+ id: string;
226
+ sideEffects?: BindingHookSideEffects;
227
+ }
228
+ interface BindingDynamicImportVarsPluginConfig {
229
+ include?: Array<BindingStringOrRegex>;
230
+ exclude?: Array<BindingStringOrRegex>;
231
+ resolver?: (id: string, importer: string) => MaybePromise<string | undefined>;
232
+ }
233
+ interface BindingEmittedAsset {
234
+ name?: string;
235
+ fileName?: string;
236
+ originalFileName?: string;
237
+ source: BindingAssetSource;
238
+ }
239
+ interface BindingEmittedChunk {
240
+ name?: string;
241
+ fileName?: string;
242
+ id: string;
243
+ importer?: string;
244
+ }
245
+ interface BindingExperimentalHmrOptions {
246
+ host?: string;
247
+ port?: number;
248
+ implement?: string;
249
+ }
250
+ interface BindingExperimentalOptions {
251
+ strictExecutionOrder?: boolean;
252
+ disableLiveBindings?: boolean;
253
+ viteMode?: boolean;
254
+ resolveNewUrlToAsset?: boolean;
255
+ hmr?: BindingExperimentalHmrOptions;
256
+ attachDebugInfo?: boolean;
257
+ }
258
+ interface BindingFilterToken {
259
+ kind: FilterTokenKind;
260
+ payload?: BindingStringOrRegex | number | boolean;
261
+ }
262
+ interface BindingHmrBoundaryOutput {
263
+ boundary: string;
264
+ acceptedVia: string;
265
+ }
266
+ interface BindingHmrOutput {
267
+ code: string;
268
+ filename: string;
269
+ sourcemap?: string;
270
+ sourcemapFilename?: string;
271
+ hmrBoundaries: Array<BindingHmrBoundaryOutput>;
272
+ fullReload: boolean;
273
+ firstInvalidatedBy?: string;
274
+ isSelfAccepting: boolean;
275
+ fullReloadReason?: string;
276
+ }
277
+ interface BindingHookFilter {
278
+ value?: Array<Array<BindingFilterToken>>;
279
+ }
280
+ interface BindingHookLoadOutput {
281
+ code: string;
282
+ sideEffects?: BindingHookSideEffects;
283
+ map?: BindingSourcemap;
284
+ moduleType?: string;
285
+ }
286
+ interface BindingHookRenderChunkOutput {
287
+ code: string;
288
+ map?: BindingSourcemap;
289
+ }
290
+ interface BindingHookResolveIdExtraArgs {
291
+ custom?: number;
292
+ isEntry: boolean;
293
+ /**
294
+ * - `import-statement`: `import { foo } from './lib.js';`
295
+ * - `dynamic-import`: `import('./lib.js')`
296
+ * - `require-call`: `require('./lib.js')`
297
+ * - `import-rule`: `@import 'bg-color.css'`
298
+ * - `url-token`: `url('./icon.png')`
299
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
300
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
301
+ */
302
+ kind: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
303
+ }
304
+ interface BindingHookResolveIdOutput {
305
+ id: string;
306
+ external?: BindingResolvedExternal;
307
+ normalizeExternalId?: boolean;
308
+ sideEffects?: BindingHookSideEffects;
309
+ }
310
+ declare enum BindingHookSideEffects {
311
+ True = 0,
312
+ False = 1,
313
+ NoTreeshake = 2,
314
+ }
315
+ interface BindingHookTransformOutput {
316
+ code?: string;
317
+ sideEffects?: BindingHookSideEffects;
318
+ map?: BindingSourcemap;
319
+ moduleType?: string;
320
+ }
321
+ interface BindingImportGlobPluginConfig {
322
+ root?: string;
323
+ restoreQueryExtension?: boolean;
324
+ }
325
+ interface BindingInjectImportNamed {
326
+ tagNamed: true;
327
+ imported: string;
328
+ alias?: string;
329
+ from: string;
330
+ }
331
+ interface BindingInjectImportNamespace {
332
+ tagNamespace: true;
333
+ alias: string;
334
+ from: string;
335
+ }
336
+ interface BindingInputItem {
337
+ name?: string;
338
+ import: string;
339
+ }
340
+ interface BindingInputOptions {
341
+ external?: undefined | ((source: string, importer: string | undefined, isResolved: boolean) => boolean);
342
+ input: Array<BindingInputItem>;
343
+ plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[];
344
+ resolve?: BindingResolveOptions;
345
+ shimMissingExports?: boolean;
346
+ platform?: 'node' | 'browser' | 'neutral';
347
+ logLevel: BindingLogLevel;
348
+ onLog: (logLevel: 'debug' | 'warn' | 'info', log: BindingLog) => void;
349
+ cwd: string;
350
+ treeshake?: BindingTreeshake;
351
+ moduleTypes?: Record<string, string>;
352
+ define?: Array<[string, string]>;
353
+ dropLabels?: Array<string>;
354
+ inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>;
355
+ experimental?: BindingExperimentalOptions;
356
+ profilerNames?: boolean;
357
+ jsx?: BindingJsx;
358
+ transform?: TransformOptions;
359
+ watch?: BindingWatchOption;
360
+ keepNames?: boolean;
361
+ checks?: BindingChecksOptions;
362
+ deferSyncScanData?: undefined | (() => BindingDeferSyncScanData[]);
363
+ makeAbsoluteExternalsRelative?: BindingMakeAbsoluteExternalsRelative;
364
+ debug?: BindingDebugOptions;
365
+ invalidateJsSideCache?: () => void;
366
+ markModuleLoaded?: (id: string, success: boolean) => void;
367
+ }
368
+ interface BindingIsolatedDeclarationPluginConfig {
369
+ stripInternal?: boolean;
370
+ }
371
+ interface BindingJsonPluginConfig {
372
+ minify?: boolean;
373
+ namedExports?: boolean;
374
+ stringify?: BindingJsonPluginStringify;
375
+ }
376
+ type BindingJsonPluginStringify = boolean | string;
377
+ interface BindingJsonSourcemap {
378
+ file?: string;
379
+ mappings?: string;
380
+ sourceRoot?: string;
381
+ sources?: Array<string | undefined | null>;
382
+ sourcesContent?: Array<string | undefined | null>;
383
+ names?: Array<string>;
384
+ debugId?: string;
385
+ x_google_ignoreList?: Array<number>;
386
+ }
387
+ declare enum BindingJsx {
388
+ Disable = 0,
389
+ Preserve = 1,
390
+ React = 2,
391
+ ReactJsx = 3,
392
+ }
393
+ interface BindingLog {
394
+ code: string;
395
+ message: string;
396
+ id?: string;
397
+ exporter?: string;
398
+ }
399
+ declare enum BindingLogLevel {
400
+ Silent = 0,
401
+ Warn = 1,
402
+ Info = 2,
403
+ Debug = 3,
404
+ }
405
+ type BindingMakeAbsoluteExternalsRelative = {
406
+ type: 'Bool';
407
+ field0: boolean;
408
+ } | {
409
+ type: 'IfRelativeSource';
410
+ };
411
+ interface BindingManifestPluginConfig {
412
+ root: string;
413
+ outPath: string;
414
+ }
415
+ interface BindingMatchGroup {
416
+ name: string;
417
+ test?: string | RegExp | ((id: string) => VoidNullable<boolean>);
418
+ priority?: number;
419
+ minSize?: number;
420
+ minShareCount?: number;
421
+ minModuleSize?: number;
422
+ maxModuleSize?: number;
423
+ maxSize?: number;
424
+ }
425
+ interface BindingMfManifest {
426
+ filePath?: string;
427
+ disableAssetsAnalyze?: boolean;
428
+ fileName?: string;
429
+ }
430
+ interface BindingMinifyOptions {
431
+ mangle?: boolean;
432
+ compress?: boolean;
433
+ removeWhitespace?: boolean;
434
+ }
435
+ interface BindingModuleFederationPluginOption {
436
+ name: string;
437
+ filename?: string;
438
+ exposes?: Record<string, string>;
439
+ remotes?: Array<BindingRemote>;
440
+ shared?: Record<string, BindingShared>;
441
+ runtimePlugins?: Array<string>;
442
+ manifest?: BindingMfManifest;
443
+ getPublicPath?: string;
444
+ }
445
+ interface BindingModules {
446
+ values: Array<BindingRenderedModule>;
447
+ keys: Array<string>;
448
+ }
449
+ interface BindingModuleSideEffectsRule {
450
+ test?: RegExp | undefined;
451
+ sideEffects: boolean;
452
+ external?: boolean | undefined;
453
+ }
454
+ interface BindingOutputOptions {
455
+ name?: string;
456
+ assetFileNames?: string | ((chunk: BindingPreRenderedAsset) => string);
457
+ entryFileNames?: string | ((chunk: PreRenderedChunk) => string);
458
+ chunkFileNames?: string | ((chunk: PreRenderedChunk) => string);
459
+ cssEntryFileNames?: string | ((chunk: PreRenderedChunk) => string);
460
+ cssChunkFileNames?: string | ((chunk: PreRenderedChunk) => string);
461
+ sanitizeFileName?: boolean | ((name: string) => string);
462
+ banner?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
463
+ dir?: string;
464
+ file?: string;
465
+ esModule?: boolean | 'if-default-prop';
466
+ exports?: 'default' | 'named' | 'none' | 'auto';
467
+ extend?: boolean;
468
+ externalLiveBindings?: boolean;
469
+ footer?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
470
+ format?: 'es' | 'cjs' | 'iife' | 'umd' | 'app';
471
+ globals?: Record<string, string> | ((name: string) => string);
472
+ hashCharacters?: 'base64' | 'base36' | 'hex';
473
+ inlineDynamicImports?: boolean;
474
+ intro?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
475
+ outro?: (chunk: BindingRenderedChunk) => MaybePromise<VoidNullable<string>>;
476
+ plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[];
477
+ sourcemap?: 'file' | 'inline' | 'hidden';
478
+ sourcemapIgnoreList?: (source: string, sourcemapPath: string) => boolean;
479
+ sourcemapDebugIds?: boolean;
480
+ sourcemapPathTransform?: (source: string, sourcemapPath: string) => string;
481
+ minify?: boolean | 'dce-only' | BindingMinifyOptions;
482
+ advancedChunks?: BindingAdvancedChunksOptions;
483
+ legalComments?: 'none' | 'inline';
484
+ polyfillRequire?: boolean;
485
+ preserveModules?: boolean;
486
+ virtualDirname?: string;
487
+ preserveModulesRoot?: string;
488
+ preserveEntrySignatures?: 'strict' | 'allow-extension' | 'exports-only' | false;
489
+ }
490
+ interface BindingPluginContextResolvedId {
491
+ id: string;
492
+ external: boolean | 'absolute' | 'relative';
493
+ }
494
+ interface BindingPluginContextResolveOptions {
495
+ /**
496
+ * - `import-statement`: `import { foo } from './lib.js';`
497
+ * - `dynamic-import`: `import('./lib.js')`
498
+ * - `require-call`: `require('./lib.js')`
499
+ * - `import-rule`: `@import 'bg-color.css'`
500
+ * - `url-token`: `url('./icon.png')`
501
+ * - `new-url`: `new URL('./worker.js', import.meta.url)`
502
+ * - `hot-accept`: `import.meta.hot.accept('./lib.js', () => {})`
503
+ */
504
+ importKind?: 'import-statement' | 'dynamic-import' | 'require-call' | 'import-rule' | 'url-token' | 'new-url' | 'hot-accept';
505
+ skipSelf?: boolean;
506
+ custom?: number;
507
+ }
508
+ interface BindingPluginHookMeta {
509
+ order?: BindingPluginOrder;
510
+ }
511
+ interface BindingPluginOptions {
512
+ name: string;
513
+ hookUsage: number;
514
+ buildStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable>;
515
+ buildStartMeta?: BindingPluginHookMeta;
516
+ resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>;
517
+ resolveIdMeta?: BindingPluginHookMeta;
518
+ resolveIdFilter?: BindingHookFilter;
519
+ resolveDynamicImport?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>;
520
+ resolveDynamicImportMeta?: BindingPluginHookMeta;
521
+ load?: (ctx: BindingPluginContext, id: string) => MaybePromise<VoidNullable<BindingHookLoadOutput>>;
522
+ loadMeta?: BindingPluginHookMeta;
523
+ loadFilter?: BindingHookFilter;
524
+ transform?: (ctx: BindingTransformPluginContext, id: string, code: string, module_type: BindingTransformHookExtraArgs) => MaybePromise<VoidNullable<BindingHookTransformOutput>>;
525
+ transformMeta?: BindingPluginHookMeta;
526
+ transformFilter?: BindingHookFilter;
527
+ moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>;
528
+ moduleParsedMeta?: BindingPluginHookMeta;
529
+ buildEnd?: (ctx: BindingPluginContext, error?: (Error | BindingError)[]) => MaybePromise<VoidNullable>;
530
+ buildEndMeta?: BindingPluginHookMeta;
531
+ renderChunk?: (ctx: BindingPluginContext, code: string, chunk: BindingRenderedChunk, opts: BindingNormalizedOptions, meta: BindingRenderedChunkMeta) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>;
532
+ renderChunkMeta?: BindingPluginHookMeta;
533
+ renderChunkFilter?: BindingHookFilter;
534
+ augmentChunkHash?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => MaybePromise<void | string>;
535
+ augmentChunkHashMeta?: BindingPluginHookMeta;
536
+ renderStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => void;
537
+ renderStartMeta?: BindingPluginHookMeta;
538
+ renderError?: (ctx: BindingPluginContext, error: (Error | BindingError)[]) => void;
539
+ renderErrorMeta?: BindingPluginHookMeta;
540
+ generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>;
541
+ generateBundleMeta?: BindingPluginHookMeta;
542
+ writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>;
543
+ writeBundleMeta?: BindingPluginHookMeta;
544
+ closeBundle?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>;
545
+ closeBundleMeta?: BindingPluginHookMeta;
546
+ watchChange?: (ctx: BindingPluginContext, path: string, event: string) => MaybePromise<VoidNullable>;
547
+ watchChangeMeta?: BindingPluginHookMeta;
548
+ closeWatcher?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>;
549
+ closeWatcherMeta?: BindingPluginHookMeta;
550
+ banner?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
551
+ bannerMeta?: BindingPluginHookMeta;
552
+ footer?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
553
+ footerMeta?: BindingPluginHookMeta;
554
+ intro?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
555
+ introMeta?: BindingPluginHookMeta;
556
+ outro?: (ctx: BindingPluginContext, chunk: BindingRenderedChunk) => void;
557
+ outroMeta?: BindingPluginHookMeta;
558
+ }
559
+ declare enum BindingPluginOrder {
560
+ Pre = 0,
561
+ Post = 1,
562
+ }
563
+ interface BindingPreRenderedAsset {
564
+ names: Array<string>;
565
+ originalFileNames: Array<string>;
566
+ source: BindingAssetSource;
567
+ }
568
+ interface BindingRemote {
569
+ type?: string;
570
+ entry: string;
571
+ name: string;
572
+ entryGlobalName?: string;
573
+ shareScope?: string;
574
+ }
575
+ interface BindingReplacePluginConfig {
576
+ values: Record<string, string>;
577
+ delimiters?: [string, string];
578
+ preventAssignment?: boolean;
579
+ objectGuards?: boolean;
580
+ sourcemap?: boolean;
581
+ }
582
+ interface BindingReporterPluginConfig {
583
+ isTty: boolean;
584
+ isLib: boolean;
585
+ assetsDir: string;
586
+ chunkLimit: number;
587
+ shouldLogInfo: boolean;
588
+ reportCompressedSize: boolean;
589
+ }
590
+ type BindingResolvedExternal = boolean | string;
591
+ interface BindingResolveOptions {
592
+ alias?: Array<AliasItem>;
593
+ aliasFields?: Array<Array<string>>;
594
+ conditionNames?: Array<string>;
595
+ exportsFields?: Array<Array<string>>;
596
+ extensions?: Array<string>;
597
+ extensionAlias?: Array<ExtensionAliasItem>;
598
+ mainFields?: Array<string>;
599
+ mainFiles?: Array<string>;
600
+ modules?: Array<string>;
601
+ symlinks?: boolean;
602
+ tsconfigFilename?: string;
603
+ }
604
+ interface BindingShared {
605
+ version?: string;
606
+ shareScope?: string;
607
+ singleton?: boolean;
608
+ requiredVersion?: string;
609
+ strictVersion?: boolean;
610
+ }
611
+ interface BindingSourcemap {
612
+ inner: string | BindingJsonSourcemap;
613
+ }
614
+ interface BindingTransformHookExtraArgs {
615
+ moduleType: string;
616
+ }
617
+ interface BindingTransformPluginConfig {
618
+ include?: Array<BindingStringOrRegex>;
619
+ exclude?: Array<BindingStringOrRegex>;
620
+ jsxRefreshInclude?: Array<BindingStringOrRegex>;
621
+ jsxRefreshExclude?: Array<BindingStringOrRegex>;
622
+ isServerConsumer?: boolean;
623
+ runtimeResolveBase?: string;
624
+ jsxInject?: string;
625
+ transformOptions?: TransformOptions;
626
+ }
627
+ interface BindingTreeshake {
628
+ moduleSideEffects: boolean | BindingModuleSideEffectsRule[] | ((id: string, is_external: boolean) => boolean | undefined);
629
+ annotations?: boolean;
630
+ manualPureFunctions?: Array<string>;
631
+ unknownGlobalSideEffects?: boolean;
632
+ }
633
+ interface BindingViteResolvePluginConfig {
634
+ resolveOptions: BindingViteResolvePluginResolveOptions;
635
+ environmentConsumer: string;
636
+ environmentName: string;
637
+ builtins: Array<BindingStringOrRegex>;
638
+ external: true | string[];
639
+ noExternal: true | Array<string | RegExp>;
640
+ dedupe: Array<string>;
641
+ finalizeBareSpecifier?: (resolvedId: string, rawId: string, importer: string | null | undefined) => VoidNullable<string>;
642
+ finalizeOtherSpecifiers?: (resolvedId: string, rawId: string) => VoidNullable<string>;
643
+ }
644
+ interface BindingViteResolvePluginResolveOptions {
645
+ isBuild: boolean;
646
+ isProduction: boolean;
647
+ asSrc: boolean;
648
+ preferRelative: boolean;
649
+ isRequire?: boolean;
650
+ root: string;
651
+ scan: boolean;
652
+ mainFields: Array<string>;
653
+ conditions: Array<string>;
654
+ externalConditions: Array<string>;
655
+ extensions: Array<string>;
656
+ tryIndex: boolean;
657
+ tryPrefix?: string;
658
+ preserveSymlinks: boolean;
659
+ }
660
+ interface BindingWatchOption {
661
+ skipWrite?: boolean;
662
+ include?: Array<BindingStringOrRegex>;
663
+ exclude?: Array<BindingStringOrRegex>;
664
+ buildDelay?: number;
665
+ }
666
+ interface Comment {
667
+ type: 'Line' | 'Block';
668
+ value: string;
669
+ start: number;
670
+ end: number;
671
+ }
672
+ interface CompilerAssumptions {
673
+ ignoreFunctionLength?: boolean;
674
+ noDocumentAll?: boolean;
675
+ objectRestNoSymbols?: boolean;
676
+ pureGetters?: boolean;
677
+ /**
678
+ * When using public class fields, assume that they don't shadow any getter in the current class,
679
+ * in its subclasses or in its superclass. Thus, it's safe to assign them rather than using
680
+ * `Object.defineProperty`.
681
+ *
682
+ * For example:
683
+ *
684
+ * Input:
685
+ * ```js
686
+ * class Test {
687
+ * field = 2;
688
+ *
689
+ * static staticField = 3;
690
+ * }
691
+ * ```
692
+ *
693
+ * When `set_public_class_fields` is `true`, the output will be:
694
+ * ```js
695
+ * class Test {
696
+ * constructor() {
697
+ * this.field = 2;
698
+ * }
699
+ * }
700
+ * Test.staticField = 3;
701
+ * ```
702
+ *
703
+ * Otherwise, the output will be:
704
+ * ```js
705
+ * import _defineProperty from "@oxc-project/runtime/helpers/defineProperty";
706
+ * class Test {
707
+ * constructor() {
708
+ * _defineProperty(this, "field", 2);
709
+ * }
710
+ * }
711
+ * _defineProperty(Test, "staticField", 3);
712
+ * ```
713
+ *
714
+ * NOTE: For TypeScript, if you wanted behavior is equivalent to `useDefineForClassFields: false`, you should
715
+ * set both `set_public_class_fields` and [`crate::TypeScriptOptions::remove_class_fields_without_initializer`]
716
+ * to `true`.
717
+ */
718
+ setPublicClassFields?: boolean;
719
+ }
720
+ interface DecoratorOptions {
721
+ /**
722
+ * Enables experimental support for decorators, which is a version of decorators that predates the TC39 standardization process.
723
+ *
724
+ * Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification.
725
+ * This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
726
+ *
727
+ * @see https://www.typescriptlang.org/tsconfig/#experimentalDecorators
728
+ * @default false
729
+ */
730
+ legacy?: boolean;
731
+ /**
732
+ * Enables emitting decorator metadata.
733
+ *
734
+ * This option the same as [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
735
+ * in TypeScript, and it only works when `legacy` is true.
736
+ *
737
+ * @see https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata
738
+ * @default false
739
+ */
740
+ emitDecoratorMetadata?: boolean;
741
+ }
742
+ interface DynamicImport {
743
+ start: number;
744
+ end: number;
745
+ moduleRequest: Span;
746
+ }
747
+ interface EcmaScriptModule {
748
+ /**
749
+ * Has ESM syntax.
750
+ *
751
+ * i.e. `import` and `export` statements, and `import.meta`.
752
+ *
753
+ * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
754
+ */
755
+ hasModuleSyntax: boolean;
756
+ /** Import statements. */
757
+ staticImports: Array<StaticImport>;
758
+ /** Export statements. */
759
+ staticExports: Array<StaticExport>;
760
+ /** Dynamic import expressions. */
761
+ dynamicImports: Array<DynamicImport>;
762
+ /** Span positions` of `import.meta` */
763
+ importMetas: Array<Span>;
764
+ }
765
+ declare enum EnforceExtension {
766
+ Auto = 0,
767
+ Enabled = 1,
768
+ Disabled = 2,
769
+ }
770
+ interface ErrorLabel {
771
+ message?: string;
772
+ start: number;
773
+ end: number;
774
+ }
775
+ interface ExportExportName {
776
+ kind: ExportExportNameKind;
777
+ name?: string;
778
+ start?: number;
779
+ end?: number;
780
+ }
781
+ type ExportExportNameKind = /** `export { name } */
782
+ 'Name' | /** `export default expression` */
783
+ 'Default' | /** `export * from "mod" */
784
+ 'None';
785
+ interface ExportImportName {
786
+ kind: ExportImportNameKind;
787
+ name?: string;
788
+ start?: number;
789
+ end?: number;
790
+ }
791
+ type ExportImportNameKind = /** `export { name } */
792
+ 'Name' | /** `export * as ns from "mod"` */
793
+ 'All' | /** `export * from "mod"` */
794
+ 'AllButDefault' | /** Does not have a specifier. */
795
+ 'None';
796
+ interface ExportLocalName {
797
+ kind: ExportLocalNameKind;
798
+ name?: string;
799
+ start?: number;
800
+ end?: number;
801
+ }
802
+ type ExportLocalNameKind = /** `export { name } */
803
+ 'Name' | /** `export default expression` */
804
+ 'Default' |
805
+ /**
806
+ * If the exported value is not locally accessible from within the module.
807
+ * `export default function () {}`
808
+ */
809
+ 'None';
810
+ interface ExtensionAliasItem {
811
+ target: string;
812
+ replacements: Array<string>;
813
+ }
814
+ type FilterTokenKind = 'Id' | 'Code' | 'ModuleType' | 'And' | 'Or' | 'Not' | 'Include' | 'Exclude' | 'CleanUrl' | 'QueryKey' | 'QueryValue';
815
+
816
+ /**
817
+ * Get offset within a `Uint8Array` which is aligned on 4 GiB.
818
+ *
819
+ * Does not check that the offset is within bounds of `buffer`.
820
+ * To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
821
+ */
822
+
823
+ type HelperMode =
824
+ /**
825
+ * Runtime mode (default): Helper functions are imported from a runtime package.
826
+ *
827
+ * Example:
828
+ *
829
+ * ```js
830
+ * import helperName from "@oxc-project/runtime/helpers/helperName";
831
+ * helperName(...arguments);
832
+ * ```
833
+ */
834
+ 'Runtime' |
835
+ /**
836
+ * External mode: Helper functions are accessed from a global `babelHelpers` object.
837
+ *
838
+ * Example:
839
+ *
840
+ * ```js
841
+ * babelHelpers.helperName(...arguments);
842
+ * ```
843
+ */
844
+ 'External';
845
+ interface Helpers {
846
+ mode?: HelperMode;
847
+ }
848
+ interface ImportName {
849
+ kind: ImportNameKind;
850
+ name?: string;
851
+ start?: number;
852
+ end?: number;
853
+ }
854
+ type ImportNameKind = /** `import { x } from "mod"` */
855
+ 'Name' | /** `import * as ns from "mod"` */
856
+ 'NamespaceObject' | /** `import defaultExport from "mod"` */
857
+ 'Default';
858
+
859
+ /** TypeScript Isolated Declarations for Standalone DTS Emit */
860
+ declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult;
861
+ interface IsolatedDeclarationsOptions {
862
+ /**
863
+ * Do not emit declarations for code that has an @internal annotation in its JSDoc comment.
864
+ * This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
865
+ *
866
+ * Default: `false`
867
+ *
868
+ * See <https://www.typescriptlang.org/tsconfig/#stripInternal>
869
+ */
870
+ stripInternal?: boolean;
871
+ sourcemap?: boolean;
872
+ }
873
+ interface IsolatedDeclarationsResult {
874
+ code: string;
875
+ map?: SourceMap;
876
+ errors: Array<OxcError>;
877
+ }
878
+ interface JsChangedOutputs {
879
+ chunks: Array<JsOutputChunk>;
880
+ assets: Array<JsOutputAsset>;
881
+ deleted: Array<string>;
882
+ }
883
+ interface JsOutputAsset {
884
+ names: Array<string>;
885
+ originalFileNames: Array<string>;
886
+ filename: string;
887
+ source: BindingAssetSource;
888
+ }
889
+ interface JsOutputChunk {
890
+ name: string;
891
+ isEntry: boolean;
892
+ isDynamicEntry: boolean;
893
+ facadeModuleId?: string;
894
+ moduleIds: Array<string>;
895
+ exports: Array<string>;
896
+ filename: string;
897
+ modules: Record<string, BindingRenderedModule>;
898
+ imports: Array<string>;
899
+ dynamicImports: Array<string>;
900
+ code: string;
901
+ map?: BindingSourcemap;
902
+ sourcemapFilename?: string;
903
+ preliminaryFilename: string;
904
+ }
905
+
906
+ /**
907
+ * Configure how TSX and JSX are transformed.
908
+ *
909
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
910
+ */
911
+ interface JsxOptions {
912
+ /**
913
+ * Decides which runtime to use.
914
+ *
915
+ * - 'automatic' - auto-import the correct JSX factories
916
+ * - 'classic' - no auto-import
917
+ *
918
+ * @default 'automatic'
919
+ */
920
+ runtime?: 'classic' | 'automatic';
921
+ /**
922
+ * Emit development-specific information, such as `__source` and `__self`.
923
+ *
924
+ * @default false
925
+ *
926
+ * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
927
+ */
928
+ development?: boolean;
929
+ /**
930
+ * Toggles whether or not to throw an error if an XML namespaced tag name
931
+ * is used.
932
+ *
933
+ * Though the JSX spec allows this, it is disabled by default since React's
934
+ * JSX does not currently have support for it.
935
+ *
936
+ * @default true
937
+ */
938
+ throwIfNamespace?: boolean;
939
+ /**
940
+ * Enables `@babel/plugin-transform-react-pure-annotations`.
941
+ *
942
+ * It will mark top-level React method calls as pure for tree shaking.
943
+ *
944
+ * @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
945
+ *
946
+ * @default true
947
+ */
948
+ pure?: boolean;
949
+ /**
950
+ * Replaces the import source when importing functions.
951
+ *
952
+ * @default 'react'
953
+ */
954
+ importSource?: string;
955
+ /**
956
+ * Replace the function used when compiling JSX expressions. It should be a
957
+ * qualified name (e.g. `React.createElement`) or an identifier (e.g.
958
+ * `createElement`).
959
+ *
960
+ * Only used for `classic` {@link runtime}.
961
+ *
962
+ * @default 'React.createElement'
963
+ */
964
+ pragma?: string;
965
+ /**
966
+ * Replace the component used when compiling JSX fragments. It should be a
967
+ * valid JSX tag name.
968
+ *
969
+ * Only used for `classic` {@link runtime}.
970
+ *
971
+ * @default 'React.Fragment'
972
+ */
973
+ pragmaFrag?: string;
974
+ /**
975
+ * When spreading props, use `Object.assign` directly instead of an extend helper.
976
+ *
977
+ * Only used for `classic` {@link runtime}.
978
+ *
979
+ * @default false
980
+ */
981
+ useBuiltIns?: boolean;
982
+ /**
983
+ * When spreading props, use inline object with spread elements directly
984
+ * instead of an extend helper or Object.assign.
985
+ *
986
+ * Only used for `classic` {@link runtime}.
987
+ *
988
+ * @default false
989
+ */
990
+ useSpread?: boolean;
991
+ /**
992
+ * Enable React Fast Refresh .
993
+ *
994
+ * Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
995
+ *
996
+ * @default false
997
+ */
998
+ refresh?: boolean | ReactRefreshOptions;
999
+ }
1000
+
1001
+ /**
1002
+ * Transform JavaScript code to a Vite Node runnable module.
1003
+ *
1004
+ * @param filename The name of the file being transformed.
1005
+ * @param sourceText the source code itself
1006
+ * @param options The options for the transformation. See {@link
1007
+ * ModuleRunnerTransformOptions} for more information.
1008
+ *
1009
+ * @returns an object containing the transformed code, source maps, and any
1010
+ * errors that occurred during parsing or transformation.
1011
+ *
1012
+ * @deprecated Only works for Vite.
1013
+ */
1014
+ declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult;
1015
+ interface ModuleRunnerTransformOptions {
1016
+ /**
1017
+ * Enable source map generation.
1018
+ *
1019
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
1020
+ *
1021
+ * @default false
1022
+ *
1023
+ * @see {@link SourceMap}
1024
+ */
1025
+ sourcemap?: boolean;
1026
+ }
1027
+ interface ModuleRunnerTransformResult {
1028
+ /**
1029
+ * The transformed code.
1030
+ *
1031
+ * If parsing failed, this will be an empty string.
1032
+ */
1033
+ code: string;
1034
+ /**
1035
+ * The source map for the transformed code.
1036
+ *
1037
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
1038
+ */
1039
+ map?: SourceMap;
1040
+ deps: Array<string>;
1041
+ dynamicDeps: Array<string>;
1042
+ /**
1043
+ * Parse and transformation errors.
1044
+ *
1045
+ * Oxc's parser recovers from common syntax errors, meaning that
1046
+ * transformed code may still be available even if there are errors in this
1047
+ * list.
1048
+ */
1049
+ errors: Array<OxcError>;
1050
+ }
1051
+ type ModuleType = 'module' | 'commonjs' | 'json' | 'wasm' | 'addon';
1052
+
1053
+ /**
1054
+ * Module Resolution Options
1055
+ *
1056
+ * Options are directly ported from [enhanced-resolve](https://github.com/webpack/enhanced-resolve#resolver-options).
1057
+ *
1058
+ * See [webpack resolve](https://webpack.js.org/configuration/resolve/) for information and examples
1059
+ */
1060
+ interface NapiResolveOptions {
1061
+ /**
1062
+ * Path to TypeScript configuration file.
1063
+ *
1064
+ * Default `None`
1065
+ */
1066
+ tsconfig?: TsconfigOptions;
1067
+ /**
1068
+ * Alias for [ResolveOptions::alias] and [ResolveOptions::fallback].
1069
+ *
1070
+ * For the second value of the tuple, `None -> AliasValue::Ignore`, Some(String) ->
1071
+ * AliasValue::Path(String)`
1072
+ * Create aliases to import or require certain modules more easily.
1073
+ * A trailing $ can also be added to the given object's keys to signify an exact match.
1074
+ */
1075
+ alias?: Record<string, Array<string | undefined | null>>;
1076
+ /**
1077
+ * A list of alias fields in description files.
1078
+ * Specify a field, such as `browser`, to be parsed according to [this specification](https://github.com/defunctzombie/package-browser-field-spec).
1079
+ * Can be a path to json object such as `["path", "to", "exports"]`.
1080
+ *
1081
+ * Default `[]`
1082
+ */
1083
+ aliasFields?: (string | string[])[];
1084
+ /**
1085
+ * Condition names for exports field which defines entry points of a package.
1086
+ * The key order in the exports field is significant. During condition matching, earlier entries have higher priority and take precedence over later entries.
1087
+ *
1088
+ * Default `[]`
1089
+ */
1090
+ conditionNames?: Array<string>;
1091
+ /**
1092
+ * If true, it will not allow extension-less files.
1093
+ * So by default `require('./foo')` works if `./foo` has a `.js` extension,
1094
+ * but with this enabled only `require('./foo.js')` will work.
1095
+ *
1096
+ * Default to `true` when [ResolveOptions::extensions] contains an empty string.
1097
+ * Use `Some(false)` to disable the behavior.
1098
+ * See <https://github.com/webpack/enhanced-resolve/pull/285>
1099
+ *
1100
+ * Default None, which is the same as `Some(false)` when the above empty rule is not applied.
1101
+ */
1102
+ enforceExtension?: EnforceExtension;
1103
+ /**
1104
+ * A list of exports fields in description files.
1105
+ * Can be a path to json object such as `["path", "to", "exports"]`.
1106
+ *
1107
+ * Default `[["exports"]]`.
1108
+ */
1109
+ exportsFields?: (string | string[])[];
1110
+ /**
1111
+ * Fields from `package.json` which are used to provide the internal requests of a package
1112
+ * (requests starting with # are considered internal).
1113
+ *
1114
+ * Can be a path to a JSON object such as `["path", "to", "imports"]`.
1115
+ *
1116
+ * Default `[["imports"]]`.
1117
+ */
1118
+ importsFields?: (string | string[])[];
1119
+ /**
1120
+ * An object which maps extension to extension aliases.
1121
+ *
1122
+ * Default `{}`
1123
+ */
1124
+ extensionAlias?: Record<string, Array<string>>;
1125
+ /**
1126
+ * Attempt to resolve these extensions in order.
1127
+ * If multiple files share the same name but have different extensions,
1128
+ * will resolve the one with the extension listed first in the array and skip the rest.
1129
+ *
1130
+ * Default `[".js", ".json", ".node"]`
1131
+ */
1132
+ extensions?: Array<string>;
1133
+ /**
1134
+ * Redirect module requests when normal resolving fails.
1135
+ *
1136
+ * Default `[]`
1137
+ */
1138
+ fallback?: Record<string, Array<string | undefined | null>>;
1139
+ /**
1140
+ * 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).
1141
+ *
1142
+ * See also webpack configuration [resolve.fullySpecified](https://webpack.js.org/configuration/module/#resolvefullyspecified)
1143
+ *
1144
+ * Default `false`
1145
+ */
1146
+ fullySpecified?: boolean;
1147
+ /**
1148
+ * A list of main fields in description files
1149
+ *
1150
+ * Default `["main"]`.
1151
+ */
1152
+ mainFields?: string | string[];
1153
+ /**
1154
+ * The filename to be used while resolving directories.
1155
+ *
1156
+ * Default `["index"]`
1157
+ */
1158
+ mainFiles?: Array<string>;
1159
+ /**
1160
+ * A list of directories to resolve modules from, can be absolute path or folder name.
1161
+ *
1162
+ * Default `["node_modules"]`
1163
+ */
1164
+ modules?: string | string[];
1165
+ /**
1166
+ * Resolve to a context instead of a file.
1167
+ *
1168
+ * Default `false`
1169
+ */
1170
+ resolveToContext?: boolean;
1171
+ /**
1172
+ * Prefer to resolve module requests as relative requests instead of using modules from node_modules directories.
1173
+ *
1174
+ * Default `false`
1175
+ */
1176
+ preferRelative?: boolean;
1177
+ /**
1178
+ * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in ResolveOptions::roots.
1179
+ *
1180
+ * Default `false`
1181
+ */
1182
+ preferAbsolute?: boolean;
1183
+ /**
1184
+ * A list of resolve restrictions to restrict the paths that a request can be resolved on.
1185
+ *
1186
+ * Default `[]`
1187
+ */
1188
+ restrictions?: Array<Restriction>;
1189
+ /**
1190
+ * A list of directories where requests of server-relative URLs (starting with '/') are resolved.
1191
+ * On non-Windows systems these requests are resolved as an absolute path first.
1192
+ *
1193
+ * Default `[]`
1194
+ */
1195
+ roots?: Array<string>;
1196
+ /**
1197
+ * Whether to resolve symlinks to their symlinked location.
1198
+ * When enabled, symlinked resources are resolved to their real path, not their symlinked location.
1199
+ * Note that this may cause module resolution to fail when using tools that symlink packages (like npm link).
1200
+ *
1201
+ * Default `true`
1202
+ */
1203
+ symlinks?: boolean;
1204
+ /**
1205
+ * Whether to parse [module.builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules) or not.
1206
+ * For example, "zlib" will throw [crate::ResolveError::Builtin] when set to true.
1207
+ *
1208
+ * Default `false`
1209
+ */
1210
+ builtinModules?: boolean;
1211
+ /**
1212
+ * Resolve [ResolveResult::moduleType].
1213
+ *
1214
+ * Default `false`
1215
+ */
1216
+ moduleType?: boolean;
1217
+ }
1218
+ interface OxcError {
1219
+ severity: Severity;
1220
+ message: string;
1221
+ labels: Array<ErrorLabel>;
1222
+ helpMessage?: string;
1223
+ codeframe?: string;
1224
+ }
1225
+
1226
+ /**
1227
+ * Parse asynchronously.
1228
+ *
1229
+ * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
1230
+ */
1231
+
1232
+ interface ParserOptions {
1233
+ /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1234
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx';
1235
+ /** Treat the source text as `script` or `module` code. */
1236
+ sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
1237
+ /**
1238
+ * Return an AST which includes TypeScript-related properties, or excludes them.
1239
+ *
1240
+ * `'js'` is default for JS / JSX files.
1241
+ * `'ts'` is default for TS / TSX files.
1242
+ * The type of the file is determined from `lang` option, or extension of provided `filename`.
1243
+ */
1244
+ astType?: 'js' | 'ts';
1245
+ /**
1246
+ * Emit `ParenthesizedExpression` and `TSParenthesizedType` in AST.
1247
+ *
1248
+ * If this option is true, parenthesized expressions are represented by
1249
+ * (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` nodes that
1250
+ * have a single `expression` property containing the expression inside parentheses.
1251
+ *
1252
+ * @default true
1253
+ */
1254
+ preserveParens?: boolean;
1255
+ /**
1256
+ * Produce semantic errors with an additional AST pass.
1257
+ * Semantic errors depend on symbols and scopes, where the parser does not construct.
1258
+ * This adds a small performance overhead.
1259
+ *
1260
+ * @default false
1261
+ */
1262
+ showSemanticErrors?: boolean;
1263
+ }
1264
+
1265
+ /** Parse synchronously. */
1266
+
1267
+ interface PreRenderedChunk {
1268
+ name: string;
1269
+ isEntry: boolean;
1270
+ isDynamicEntry: boolean;
1271
+ facadeModuleId?: string;
1272
+ moduleIds: Array<string>;
1273
+ exports: Array<string>;
1274
+ }
1275
+
1276
+ /** Returns `true` if raw transfer is supported on this platform. */
1277
+
1278
+ interface ReactRefreshOptions {
1279
+ /**
1280
+ * Specify the identifier of the refresh registration variable.
1281
+ *
1282
+ * @default `$RefreshReg$`.
1283
+ */
1284
+ refreshReg?: string;
1285
+ /**
1286
+ * Specify the identifier of the refresh signature variable.
1287
+ *
1288
+ * @default `$RefreshSig$`.
1289
+ */
1290
+ refreshSig?: string;
1291
+ emitFullSignatures?: boolean;
1292
+ }
1293
+ interface ResolveResult {
1294
+ path?: string;
1295
+ error?: string;
1296
+ /**
1297
+ * Module type for this path.
1298
+ *
1299
+ * Enable with `ResolveOptions#moduleType`.
1300
+ *
1301
+ * 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).
1302
+ *
1303
+ * The algorithm uses the file extension or finds the closest `package.json` with the `type` field.
1304
+ */
1305
+ moduleType?: ModuleType;
1306
+ /** `package.json` path for the given module. */
1307
+ packageJsonPath?: string;
1308
+ }
1309
+
1310
+ /**
1311
+ * Alias Value for [ResolveOptions::alias] and [ResolveOptions::fallback].
1312
+ * Use struct because napi don't support structured union now
1313
+ */
1314
+ interface Restriction {
1315
+ path?: string;
1316
+ regex?: string;
1317
+ }
1318
+ type Severity = 'Error' | 'Warning' | 'Advice';
1319
+
1320
+ /**
1321
+ * Shutdown the tokio runtime manually.
1322
+ *
1323
+ * This is required for the wasm target with `tokio_unstable` cfg.
1324
+ * In the wasm runtime, the `park` threads will hang there until the tokio::Runtime is shutdown.
1325
+ */
1326
+
1327
+ interface SourceMap {
1328
+ file?: string;
1329
+ mappings: string;
1330
+ names: Array<string>;
1331
+ sourceRoot?: string;
1332
+ sources: Array<string>;
1333
+ sourcesContent?: Array<string>;
1334
+ version: number;
1335
+ x_google_ignoreList?: Array<number>;
1336
+ }
1337
+ interface Span {
1338
+ start: number;
1339
+ end: number;
1340
+ }
1341
+
1342
+ /**
1343
+ * Start the async runtime manually.
1344
+ *
1345
+ * This is required when the async runtime is shutdown manually.
1346
+ * Usually it's used in test.
1347
+ */
1348
+
1349
+ interface StaticExport {
1350
+ start: number;
1351
+ end: number;
1352
+ entries: Array<StaticExportEntry>;
1353
+ }
1354
+ interface StaticExportEntry {
1355
+ start: number;
1356
+ end: number;
1357
+ moduleRequest?: ValueSpan;
1358
+ /** The name under which the desired binding is exported by the module`. */
1359
+ importName: ExportImportName;
1360
+ /** The name used to export this binding by this module. */
1361
+ exportName: ExportExportName;
1362
+ /** The name that is used to locally access the exported value from within the importing module. */
1363
+ localName: ExportLocalName;
1364
+ /**
1365
+ * Whether the export is a TypeScript `export type`.
1366
+ *
1367
+ * Examples:
1368
+ *
1369
+ * ```ts
1370
+ * export type * from 'mod';
1371
+ * export type * as ns from 'mod';
1372
+ * export type { foo };
1373
+ * export { type foo }:
1374
+ * export type { foo } from 'mod';
1375
+ * ```
1376
+ */
1377
+ isType: boolean;
1378
+ }
1379
+ interface StaticImport {
1380
+ /** Start of import statement. */
1381
+ start: number;
1382
+ /** End of import statement. */
1383
+ end: number;
1384
+ /**
1385
+ * Import source.
1386
+ *
1387
+ * ```js
1388
+ * import { foo } from "mod";
1389
+ * // ^^^
1390
+ * ```
1391
+ */
1392
+ moduleRequest: ValueSpan;
1393
+ /**
1394
+ * Import specifiers.
1395
+ *
1396
+ * Empty for `import "mod"`.
1397
+ */
1398
+ entries: Array<StaticImportEntry>;
1399
+ }
1400
+ interface StaticImportEntry {
1401
+ /**
1402
+ * The name under which the desired binding is exported by the module.
1403
+ *
1404
+ * ```js
1405
+ * import { foo } from "mod";
1406
+ * // ^^^
1407
+ * import { foo as bar } from "mod";
1408
+ * // ^^^
1409
+ * ```
1410
+ */
1411
+ importName: ImportName;
1412
+ /**
1413
+ * The name that is used to locally access the imported value from within the importing module.
1414
+ * ```js
1415
+ * import { foo } from "mod";
1416
+ * // ^^^
1417
+ * import { foo as bar } from "mod";
1418
+ * // ^^^
1419
+ * ```
1420
+ */
1421
+ localName: ValueSpan;
1422
+ /**
1423
+ * Whether this binding is for a TypeScript type-only import.
1424
+ *
1425
+ * `true` for the following imports:
1426
+ * ```ts
1427
+ * import type { foo } from "mod";
1428
+ * import { type foo } from "mod";
1429
+ * ```
1430
+ */
1431
+ isType: boolean;
1432
+ }
1433
+ /**
1434
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version.
1435
+ *
1436
+ * @param filename The name of the file being transformed. If this is a
1437
+ * relative path, consider setting the {@link TransformOptions#cwd} option..
1438
+ * @param sourceText the source code itself
1439
+ * @param options The options for the transformation. See {@link
1440
+ * TransformOptions} for more information.
1441
+ *
1442
+ * @returns an object containing the transformed code, source maps, and any
1443
+ * errors that occurred during parsing or transformation.
1444
+ */
1445
+ declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult;
1446
+
1447
+ /**
1448
+ * Options for transforming a JavaScript or TypeScript file.
1449
+ *
1450
+ * @see {@link transform}
1451
+ */
1452
+ interface TransformOptions {
1453
+ /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1454
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx';
1455
+ /** Treat the source text as `script` or `module` code. */
1456
+ sourceType?: 'script' | 'module' | 'unambiguous' | undefined;
1457
+ /**
1458
+ * The current working directory. Used to resolve relative paths in other
1459
+ * options.
1460
+ */
1461
+ cwd?: string;
1462
+ /**
1463
+ * Enable source map generation.
1464
+ *
1465
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
1466
+ *
1467
+ * @default false
1468
+ *
1469
+ * @see {@link SourceMap}
1470
+ */
1471
+ sourcemap?: boolean;
1472
+ /** Set assumptions in order to produce smaller output. */
1473
+ assumptions?: CompilerAssumptions;
1474
+ /** Configure how TypeScript is transformed. */
1475
+ typescript?: TypeScriptOptions;
1476
+ /** Configure how TSX and JSX are transformed. */
1477
+ jsx?: 'preserve' | JsxOptions;
1478
+ /**
1479
+ * Sets the target environment for the generated JavaScript.
1480
+ *
1481
+ * The lowest target is `es2015`.
1482
+ *
1483
+ * Example:
1484
+ *
1485
+ * * 'es2015'
1486
+ * * ['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']
1487
+ *
1488
+ * @default `esnext` (No transformation)
1489
+ *
1490
+ * @see [esbuild#target](https://esbuild.github.io/api/#target)
1491
+ */
1492
+ target?: string | Array<string>;
1493
+ /** Behaviour for runtime helpers. */
1494
+ helpers?: Helpers;
1495
+ /** Define Plugin */
1496
+ define?: Record<string, string>;
1497
+ /** Inject Plugin */
1498
+ inject?: Record<string, string | [string, string]>;
1499
+ /** Decorator plugin */
1500
+ decorator?: DecoratorOptions;
1501
+ }
1502
+ interface TransformResult {
1503
+ /**
1504
+ * The transformed code.
1505
+ *
1506
+ * If parsing failed, this will be an empty string.
1507
+ */
1508
+ code: string;
1509
+ /**
1510
+ * The source map for the transformed code.
1511
+ *
1512
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
1513
+ */
1514
+ map?: SourceMap;
1515
+ /**
1516
+ * The `.d.ts` declaration file for the transformed code. Declarations are
1517
+ * only generated if `declaration` is set to `true` and a TypeScript file
1518
+ * is provided.
1519
+ *
1520
+ * If parsing failed and `declaration` is set, this will be an empty string.
1521
+ *
1522
+ * @see {@link TypeScriptOptions#declaration}
1523
+ * @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
1524
+ */
1525
+ declaration?: string;
1526
+ /**
1527
+ * Declaration source map. Only generated if both
1528
+ * {@link TypeScriptOptions#declaration declaration} and
1529
+ * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
1530
+ */
1531
+ declarationMap?: SourceMap;
1532
+ /**
1533
+ * Helpers used.
1534
+ *
1535
+ * @internal
1536
+ *
1537
+ * Example:
1538
+ *
1539
+ * ```text
1540
+ * { "_objectSpread": "@oxc-project/runtime/helpers/objectSpread2" }
1541
+ * ```
1542
+ */
1543
+ helpersUsed: Record<string, string>;
1544
+ /**
1545
+ * Parse and transformation errors.
1546
+ *
1547
+ * Oxc's parser recovers from common syntax errors, meaning that
1548
+ * transformed code may still be available even if there are errors in this
1549
+ * list.
1550
+ */
1551
+ errors: Array<OxcError>;
1552
+ }
1553
+
1554
+ /**
1555
+ * Tsconfig Options
1556
+ *
1557
+ * Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options)
1558
+ */
1559
+ interface TsconfigOptions {
1560
+ /**
1561
+ * Allows you to specify where to find the TypeScript configuration file.
1562
+ * You may provide
1563
+ * * a relative path to the configuration file. It will be resolved relative to cwd.
1564
+ * * an absolute path to the configuration file.
1565
+ */
1566
+ configFile: string;
1567
+ /**
1568
+ * Support for Typescript Project References.
1569
+ *
1570
+ * * `'auto'`: use the `references` field from tsconfig of `config_file`.
1571
+ * * `string[]`: manually provided relative or absolute path.
1572
+ */
1573
+ references?: 'auto' | string[];
1574
+ }
1575
+ interface TypeScriptOptions {
1576
+ jsxPragma?: string;
1577
+ jsxPragmaFrag?: string;
1578
+ onlyRemoveTypeImports?: boolean;
1579
+ allowNamespaces?: boolean;
1580
+ /**
1581
+ * When enabled, type-only class fields are only removed if they are prefixed with the declare modifier:
1582
+ *
1583
+ * @deprecated
1584
+ *
1585
+ * Allowing `declare` fields is built-in support in Oxc without any option. If you want to remove class fields
1586
+ * without initializer, you can use `remove_class_fields_without_initializer: true` instead.
1587
+ */
1588
+ allowDeclareFields?: boolean;
1589
+ /**
1590
+ * When enabled, class fields without initializers are removed.
1591
+ *
1592
+ * For example:
1593
+ * ```ts
1594
+ * class Foo {
1595
+ * x: number;
1596
+ * y: number = 0;
1597
+ * }
1598
+ * ```
1599
+ * // transform into
1600
+ * ```js
1601
+ * class Foo {
1602
+ * x: number;
1603
+ * }
1604
+ * ```
1605
+ *
1606
+ * The option is used to align with the behavior of TypeScript's `useDefineForClassFields: false` option.
1607
+ * When you want to enable this, you also need to set [`crate::CompilerAssumptions::set_public_class_fields`]
1608
+ * to `true`. The `set_public_class_fields: true` + `remove_class_fields_without_initializer: true` is
1609
+ * equivalent to `useDefineForClassFields: false` in TypeScript.
1610
+ *
1611
+ * When `set_public_class_fields` is true and class-properties plugin is enabled, the above example transforms into:
1612
+ *
1613
+ * ```js
1614
+ * class Foo {
1615
+ * constructor() {
1616
+ * this.y = 0;
1617
+ * }
1618
+ * }
1619
+ * ```
1620
+ *
1621
+ * Defaults to `false`.
1622
+ */
1623
+ removeClassFieldsWithoutInitializer?: boolean;
1624
+ /**
1625
+ * Also generate a `.d.ts` declaration file for TypeScript files.
1626
+ *
1627
+ * The source file must be compliant with all
1628
+ * [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
1629
+ * requirements.
1630
+ *
1631
+ * @default false
1632
+ */
1633
+ declaration?: IsolatedDeclarationsOptions;
1634
+ /**
1635
+ * Rewrite or remove TypeScript import/export declaration extensions.
1636
+ *
1637
+ * - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
1638
+ * - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
1639
+ * - When set to `true`, it's equivalent to `rewrite`.
1640
+ * - When set to `false` or omitted, no changes will be made to the extensions.
1641
+ *
1642
+ * @default false
1643
+ */
1644
+ rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
1645
+ }
1646
+ interface ValueSpan {
1647
+ value: string;
1648
+ start: number;
1649
+ end: number;
1650
+ }
1651
+ //#endregion
1652
+ export { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingDynamicImportVarsPluginConfig, BindingHmrOutput, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingMinifyOptions, BindingModuleFederationPluginOption, BindingRemote, BindingRenderedChunk, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWatcherEvent, Bundler, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ParseResult, ParserOptions, PreRenderedChunk, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform };