rolldown 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.1

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