rolldown 1.0.0-beta.4-commit.d3748b6 → 1.0.0-beta.40

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 (133) hide show
  1. package/bin/cli.mjs +2 -0
  2. package/dist/cli.d.mts +1 -0
  3. package/dist/cli.mjs +579 -0
  4. package/dist/config.d.mts +10 -0
  5. package/dist/config.mjs +10 -0
  6. package/dist/experimental-index.d.mts +147 -0
  7. package/dist/experimental-index.mjs +216 -0
  8. package/dist/experimental-runtime-types.d.ts +71 -0
  9. package/dist/filter-index.d.mts +4 -0
  10. package/dist/filter-index.mjs +44 -0
  11. package/dist/index.d.mts +3 -0
  12. package/dist/index.mjs +5 -0
  13. package/dist/parallel-plugin-worker.d.mts +1 -0
  14. package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +8 -16
  15. package/dist/parallel-plugin.d.mts +14 -0
  16. package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
  17. package/dist/parse-ast-index.d.mts +8 -0
  18. package/dist/parse-ast-index.mjs +3 -0
  19. package/dist/shared/binding-BVXbXhPv.d.mts +1413 -0
  20. package/dist/shared/define-config-0kfJrpvQ.d.mts +1454 -0
  21. package/dist/shared/load-config-BJ274Wsp.mjs +117 -0
  22. package/dist/{esm/cli.mjs → shared/logger-CiCY7ucm.mjs} +107 -868
  23. package/dist/shared/misc-CQeo-AFx.mjs +22 -0
  24. package/dist/shared/parse-ast-index-C7EYXjEA.mjs +10974 -0
  25. package/dist/shared/{prompt-CxK9euq3.mjs → prompt-D2FxOcB5.mjs} +243 -245
  26. package/dist/shared/src-BH2eQDD9.mjs +4282 -0
  27. package/package.json +62 -76
  28. package/bin/cli.js +0 -2
  29. package/dist/cjs/cli.cjs +0 -1753
  30. package/dist/cjs/experimental-index.cjs +0 -85
  31. package/dist/cjs/index.cjs +0 -8
  32. package/dist/cjs/parallel-plugin-worker.cjs +0 -41
  33. package/dist/cjs/parallel-plugin.cjs +0 -9
  34. package/dist/cjs/parse-ast-index.cjs +0 -4
  35. package/dist/esm/experimental-index.mjs +0 -57
  36. package/dist/esm/index.mjs +0 -4
  37. package/dist/esm/parse-ast-index.mjs +0 -3
  38. package/dist/shared/chunk-qZFfknuJ.cjs +0 -40
  39. package/dist/shared/parse-ast-index-CyX8MVZE.mjs +0 -674
  40. package/dist/shared/parse-ast-index-D7XtMFo4.cjs +0 -719
  41. package/dist/shared/prompt-ZZScCEWI.cjs +0 -854
  42. package/dist/shared/src-CH716UxL.cjs +0 -3056
  43. package/dist/shared/src-CzSgWS0h.mjs +0 -2875
  44. package/dist/types/api/build.d.ts +0 -18
  45. package/dist/types/api/experimental.d.ts +0 -7
  46. package/dist/types/api/rolldown/index.d.ts +0 -3
  47. package/dist/types/api/rolldown/rolldown-build.d.ts +0 -13
  48. package/dist/types/api/watch/index.d.ts +0 -3
  49. package/dist/types/api/watch/watch-emitter.d.ts +0 -31
  50. package/dist/types/api/watch/watcher.d.ts +0 -13
  51. package/dist/types/binding.d.ts +0 -1456
  52. package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
  53. package/dist/types/builtin-plugin/constructors.d.ts +0 -21
  54. package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
  55. package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
  56. package/dist/types/builtin-plugin/utils.d.ts +0 -8
  57. package/dist/types/cli/arguments/alias.d.ts +0 -16
  58. package/dist/types/cli/arguments/index.d.ts +0 -15
  59. package/dist/types/cli/arguments/normalize.d.ts +0 -12
  60. package/dist/types/cli/arguments/utils.d.ts +0 -8
  61. package/dist/types/cli/colors.d.ts +0 -11
  62. package/dist/types/cli/commands/bundle.d.ts +0 -3
  63. package/dist/types/cli/commands/help.d.ts +0 -1
  64. package/dist/types/cli/index.d.ts +0 -1
  65. package/dist/types/cli/load-config.d.ts +0 -5
  66. package/dist/types/cli/logger.d.ts +0 -5
  67. package/dist/types/constants/plugin-context.d.ts +0 -7
  68. package/dist/types/constants/plugin.d.ts +0 -45
  69. package/dist/types/experimental-index.d.ts +0 -9
  70. package/dist/types/index.d.ts +0 -30
  71. package/dist/types/log/log-handler.d.ts +0 -4
  72. package/dist/types/log/logger.d.ts +0 -6
  73. package/dist/types/log/logging.d.ts +0 -12
  74. package/dist/types/log/logs.d.ts +0 -18
  75. package/dist/types/options/generated/checks-options.d.ts +0 -57
  76. package/dist/types/options/input-options.d.ts +0 -177
  77. package/dist/types/options/normalized-input-options.d.ts +0 -18
  78. package/dist/types/options/normalized-output-options.d.ts +0 -70
  79. package/dist/types/options/output-options.d.ts +0 -182
  80. package/dist/types/options/watch-options.d.ts +0 -5
  81. package/dist/types/parallel-plugin-worker.d.ts +0 -1
  82. package/dist/types/parallel-plugin.d.ts +0 -1
  83. package/dist/types/parse-ast-index.d.ts +0 -5
  84. package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
  85. package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
  86. package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
  87. package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
  88. package/dist/types/plugin/bindingify-plugin.d.ts +0 -16
  89. package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
  90. package/dist/types/plugin/hook-filter.d.ts +0 -48
  91. package/dist/types/plugin/index.d.ts +0 -134
  92. package/dist/types/plugin/minimal-plugin-context.d.ts +0 -23
  93. package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
  94. package/dist/types/plugin/parallel-plugin.d.ts +0 -9
  95. package/dist/types/plugin/plugin-context-data.d.ts +0 -17
  96. package/dist/types/plugin/plugin-context.d.ts +0 -67
  97. package/dist/types/plugin/plugin-driver.d.ts +0 -8
  98. package/dist/types/plugin/transform-plugin-context.d.ts +0 -28
  99. package/dist/types/types/assert.d.ts +0 -14
  100. package/dist/types/types/config-export.d.ts +0 -5
  101. package/dist/types/types/misc.d.ts +0 -40
  102. package/dist/types/types/module-info.d.ts +0 -15
  103. package/dist/types/types/module-side-effects.d.ts +0 -12
  104. package/dist/types/types/output-bundle.d.ts +0 -4
  105. package/dist/types/types/rolldown-options.d.ts +0 -5
  106. package/dist/types/types/rolldown-output.d.ts +0 -66
  107. package/dist/types/types/schema.d.ts +0 -33
  108. package/dist/types/types/sourcemap.d.ts +0 -14
  109. package/dist/types/types/utils.d.ts +0 -13
  110. package/dist/types/utils/asset-source.d.ts +0 -4
  111. package/dist/types/utils/async-flatten.d.ts +0 -1
  112. package/dist/types/utils/bindingify-input-options.d.ts +0 -7
  113. package/dist/types/utils/bindingify-output-options.d.ts +0 -5
  114. package/dist/types/utils/code-frame.d.ts +0 -1
  115. package/dist/types/utils/compose-js-plugins.d.ts +0 -2
  116. package/dist/types/utils/create-bundler-option.d.ts +0 -11
  117. package/dist/types/utils/create-bundler.d.ts +0 -8
  118. package/dist/types/utils/define-config.d.ts +0 -5
  119. package/dist/types/utils/error.d.ts +0 -2
  120. package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
  121. package/dist/types/utils/misc.d.ts +0 -6
  122. package/dist/types/utils/normalize-hook.d.ts +0 -7
  123. package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
  124. package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
  125. package/dist/types/utils/plugin/index.d.ts +0 -2
  126. package/dist/types/utils/resolved-external.d.ts +0 -4
  127. package/dist/types/utils/transform-module-info.d.ts +0 -4
  128. package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
  129. package/dist/types/utils/transform-rendered-module.d.ts +0 -3
  130. package/dist/types/utils/transform-side-effects.d.ts +0 -3
  131. package/dist/types/utils/transform-sourcemap.d.ts +0 -3
  132. package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
  133. package/dist/types/utils/validator.d.ts +0 -6
@@ -1,1456 +0,0 @@
1
- type MaybePromise<T> = T | Promise<T>
2
- type Nullable<T> = T | null | undefined
3
- type VoidNullable<T = void> = T | null | undefined | void
4
- export type BindingStringOrRegex = string | RegExp
5
-
6
- export declare class BindingBundleEndEventData {
7
- output: string
8
- duration: number
9
- }
10
-
11
- export declare class BindingCallableBuiltinPlugin {
12
- constructor(plugin: BindingBuiltinPlugin)
13
- resolveId(id: string, importer?: string | undefined | null, options?: BindingHookJsResolveIdOptions | undefined | null): Promise<BindingHookJsResolveIdOutput | null>
14
- load(id: string): Promise<BindingHookJsLoadOutput | null>
15
- watchChange(path: string, event: BindingJsWatchChangeEvent): Promise<void>
16
- }
17
-
18
- export declare class BindingError {
19
- kind: string
20
- message: string
21
- }
22
-
23
- export declare class BindingModuleInfo {
24
- id: string
25
- importers: Array<string>
26
- dynamicImporters: Array<string>
27
- importedIds: Array<string>
28
- dynamicallyImportedIds: Array<string>
29
- exports: Array<string>
30
- isEntry: boolean
31
- get code(): string | null
32
- }
33
-
34
- export declare class BindingNormalizedOptions {
35
- get input(): Array<string> | Record<string, string>
36
- get cwd(): string | null
37
- get platform(): 'node' | 'browser' | 'neutral'
38
- get shimMissingExports(): boolean
39
- get name(): string | null
40
- get cssEntryFilenames(): string | undefined
41
- get cssChunkFilenames(): string | undefined
42
- get entryFilenames(): string | undefined
43
- get chunkFilenames(): string | undefined
44
- get assetFilenames(): string | undefined
45
- get dir(): string | null
46
- get file(): string | null
47
- get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd'
48
- get exports(): 'default' | 'named' | 'none' | 'auto'
49
- get esModule(): boolean | 'if-default-prop'
50
- get inlineDynamicImports(): boolean
51
- get sourcemap(): boolean | 'inline' | 'hidden'
52
- get banner(): string | undefined | null | undefined
53
- get footer(): string | undefined | null | undefined
54
- get intro(): string | undefined | null | undefined
55
- get outro(): string | undefined | null | undefined
56
- get externalLiveBindings(): boolean
57
- get extend(): boolean
58
- get globals(): Record<string, string> | undefined
59
- get hashCharacters(): 'base64' | 'base36' | 'hex'
60
- get sourcemapDebugIds(): boolean
61
- get minify(): false | BindingMinifyOptions
62
- get polyfillRequire(): boolean
63
- get comments(): 'none' | 'preserve-legal'
64
- }
65
-
66
- export declare class BindingOutputAsset {
67
- get fileName(): string
68
- get originalFileName(): string | null
69
- get originalFileNames(): Array<string>
70
- get source(): BindingAssetSource
71
- get name(): string | null
72
- get names(): Array<string>
73
- }
74
-
75
- export declare class BindingOutputChunk {
76
- get isEntry(): boolean
77
- get isDynamicEntry(): boolean
78
- get facadeModuleId(): string | null
79
- get moduleIds(): Array<string>
80
- get exports(): Array<string>
81
- get fileName(): string
82
- get modules(): BindingModules
83
- get imports(): Array<string>
84
- get dynamicImports(): Array<string>
85
- get code(): string
86
- get map(): string | null
87
- get sourcemapFileName(): string | null
88
- get preliminaryFileName(): string
89
- get name(): string
90
- }
91
-
92
- export declare class BindingOutputs {
93
- get chunks(): Array<BindingOutputChunk>
94
- get assets(): Array<BindingOutputAsset>
95
- get errors(): Array<Error | BindingError>
96
- }
97
-
98
- export declare class BindingPluginContext {
99
- load(specifier: string, sideEffects: BindingHookSideEffects | undefined, fn: () => void): Promise<void>
100
- resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>
101
- emitFile(file: BindingEmittedAsset, assetFilename?: string | undefined | null, fnSanitizedFileName?: string | undefined | null): string
102
- emitChunk(file: BindingEmittedChunk): string
103
- getFileName(referenceId: string): string
104
- getModuleInfo(moduleId: string): BindingModuleInfo | null
105
- getModuleIds(): Array<string>
106
- addWatchFile(file: string): void
107
- }
108
-
109
- export declare class BindingRenderedModule {
110
- get code(): string | null
111
- get renderedExports(): Array<string>
112
- }
113
-
114
- export declare class BindingTransformPluginContext {
115
- getCombinedSourcemap(): string
116
- inner(): BindingPluginContext
117
- }
118
-
119
- export declare class BindingWatcher {
120
- constructor(options: Array<BindingBundlerOptions>, notifyOption?: BindingNotifyOption | undefined | null)
121
- close(): Promise<void>
122
- start(listener: (data: BindingWatcherEvent) => void): Promise<void>
123
- }
124
-
125
- export declare class BindingWatcherChangeData {
126
- path: string
127
- kind: string
128
- }
129
-
130
- export declare class BindingWatcherEvent {
131
- eventKind(): string
132
- watchChangeData(): BindingWatcherChangeData
133
- bundleEndData(): BindingBundleEndEventData
134
- bundleEventKind(): string
135
- errors(): Array<Error | BindingError>
136
- }
137
-
138
- export declare class Bundler {
139
- constructor(option: BindingBundlerOptions)
140
- write(): Promise<BindingOutputs>
141
- generate(): Promise<BindingOutputs>
142
- scan(): Promise<BindingOutputs>
143
- close(): Promise<void>
144
- get closed(): boolean
145
- generateHmrPatch(changedFiles: Array<string>): Promise<string>
146
- }
147
-
148
- export declare class ParallelJsPluginRegistry {
149
- id: number
150
- workerCount: number
151
- constructor(workerCount: number)
152
- }
153
-
154
- export declare class ParseResult {
155
- get program(): import("@oxc-project/types").Program
156
- get module(): EcmaScriptModule
157
- get comments(): Array<Comment>
158
- get errors(): Array<OxcError>
159
- }
160
-
161
- export declare class RenderedChunk {
162
- get name(): string
163
- get isEntry(): boolean
164
- get isDynamicEntry(): boolean
165
- get facadeModuleId(): string | null
166
- get moduleIds(): Array<string>
167
- get exports(): Array<string>
168
- get fileName(): string
169
- get modules(): BindingModules
170
- get imports(): Array<string>
171
- get dynamicImports(): Array<string>
172
- }
173
-
174
- export interface AliasItem {
175
- find: string
176
- replacements: Array<string>
177
- }
178
-
179
- export interface ArrowFunctionsOptions {
180
- /**
181
- * This option enables the following:
182
- * * Wrap the generated function in .bind(this) and keeps uses of this inside the function as-is, instead of using a renamed this.
183
- * * Add a runtime check to ensure the functions are not instantiated.
184
- * * Add names to arrow functions.
185
- *
186
- * @default false
187
- */
188
- spec?: boolean
189
- }
190
-
191
- export interface BindingAdvancedChunksOptions {
192
- minSize?: number
193
- minShareCount?: number
194
- groups?: Array<BindingMatchGroup>
195
- maxSize?: number
196
- minModuleSize?: number
197
- maxModuleSize?: number
198
- }
199
-
200
- export interface BindingAliasPluginAlias {
201
- find: BindingStringOrRegex
202
- replacement: string
203
- }
204
-
205
- export interface BindingAliasPluginConfig {
206
- entries: Array<BindingAliasPluginAlias>
207
- }
208
-
209
- export interface BindingAssetSource {
210
- inner: string | Uint8Array
211
- }
212
-
213
- export interface BindingBuildImportAnalysisPluginConfig {
214
- preloadCode: string
215
- insertPreload: boolean
216
- optimizeModulePreloadRelativePaths: boolean
217
- renderBuiltUrl: boolean
218
- isRelativeBase: boolean
219
- }
220
-
221
- export interface BindingBuiltinPlugin {
222
- __name: BindingBuiltinPluginName
223
- options?: unknown
224
- }
225
-
226
- export type BindingBuiltinPluginName = 'builtin:wasm-helper'|
227
- 'builtin:import-glob'|
228
- 'builtin:dynamic-import-vars'|
229
- 'builtin:module-preload-polyfill'|
230
- 'builtin:manifest'|
231
- 'builtin:load-fallback'|
232
- 'builtin:transform'|
233
- 'builtin:wasm-fallback'|
234
- 'builtin:alias'|
235
- 'builtin:json'|
236
- 'builtin:build-import-analysis'|
237
- 'builtin:replace'|
238
- 'builtin:vite-resolve'|
239
- 'builtin:module-federation';
240
-
241
- export interface BindingBundlerOptions {
242
- inputOptions: BindingInputOptions
243
- outputOptions: BindingOutputOptions
244
- parallelPluginsRegistry?: ParallelJsPluginRegistry
245
- }
246
-
247
- export interface BindingChecksOptions {
248
- circularDependency?: boolean
249
- eval?: boolean
250
- missingGlobalName?: boolean
251
- missingNameOptionForIifeExport?: boolean
252
- mixedExport?: boolean
253
- unresolvedEntry?: boolean
254
- unresolvedImport?: boolean
255
- filenameConflict?: boolean
256
- commonJsVariableInEsm?: boolean
257
- importIsUndefined?: boolean
258
- configurationFieldConflict?: boolean
259
- }
260
-
261
- export interface BindingDeferSyncScanData {
262
- /** ModuleId */
263
- id: string
264
- sideEffects?: BindingHookSideEffects
265
- }
266
-
267
- export interface BindingEmittedAsset {
268
- name?: string
269
- fileName?: string
270
- originalFileName?: string
271
- source: BindingAssetSource
272
- }
273
-
274
- export interface BindingEmittedChunk {
275
- name?: string
276
- fileName?: string
277
- id: string
278
- importer?: string
279
- }
280
-
281
- export interface BindingExperimentalOptions {
282
- strictExecutionOrder?: boolean
283
- disableLiveBindings?: boolean
284
- viteMode?: boolean
285
- resolveNewUrlToAsset?: boolean
286
- hmr?: boolean
287
- }
288
-
289
- export interface BindingGeneralHookFilter {
290
- include?: Array<BindingStringOrRegex>
291
- exclude?: Array<BindingStringOrRegex>
292
- }
293
-
294
- export interface BindingGlobImportPluginConfig {
295
- root?: string
296
- restoreQueryExtension?: boolean
297
- }
298
-
299
- export interface BindingHookJsLoadOutput {
300
- code: string
301
- map?: string
302
- sideEffects: boolean | 'no-treeshake'
303
- }
304
-
305
- export interface BindingHookJsResolveIdOptions {
306
- scan?: boolean
307
- }
308
-
309
- export interface BindingHookJsResolveIdOutput {
310
- id: string
311
- external?: BindingResolvedExternal
312
- sideEffects: boolean | 'no-treeshake'
313
- }
314
-
315
- export interface BindingHookLoadOutput {
316
- code: string
317
- sideEffects?: BindingHookSideEffects
318
- map?: BindingSourcemap
319
- moduleType?: string
320
- }
321
-
322
- export interface BindingHookRenderChunkOutput {
323
- code: string
324
- map?: BindingSourcemap
325
- }
326
-
327
- export interface BindingHookResolveIdExtraArgs {
328
- custom?: number
329
- isEntry: boolean
330
- kind: 'import' | 'dynamic-import' | 'require-call'
331
- }
332
-
333
- export interface BindingHookResolveIdOutput {
334
- id: string
335
- external?: BindingResolvedExternal
336
- normalizeExternalId?: boolean
337
- sideEffects?: BindingHookSideEffects
338
- }
339
-
340
- export declare enum BindingHookSideEffects {
341
- True = 0,
342
- False = 1,
343
- NoTreeshake = 2
344
- }
345
-
346
- export interface BindingHookTransformOutput {
347
- code?: string
348
- sideEffects?: BindingHookSideEffects
349
- map?: BindingSourcemap
350
- moduleType?: string
351
- }
352
-
353
- export interface BindingInjectImportNamed {
354
- tagNamed: true
355
- imported: string
356
- alias?: string
357
- from: string
358
- }
359
-
360
- export interface BindingInjectImportNamespace {
361
- tagNamespace: true
362
- alias: string
363
- from: string
364
- }
365
-
366
- export interface BindingInputItem {
367
- name?: string
368
- import: string
369
- }
370
-
371
- export interface BindingInputOptions {
372
- external?: undefined | ((source: string, importer: string | undefined, isResolved: boolean) => boolean)
373
- input: Array<BindingInputItem>
374
- plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[]
375
- resolve?: BindingResolveOptions
376
- shimMissingExports?: boolean
377
- platform?: 'node' | 'browser' | 'neutral'
378
- logLevel: BindingLogLevel
379
- onLog: (logLevel: 'debug' | 'warn' | 'info', log: BindingLog) => void
380
- cwd: string
381
- treeshake?: BindingTreeshake
382
- moduleTypes?: Record<string, string>
383
- define?: Array<[string, string]>
384
- dropLabels?: Array<string>
385
- inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>
386
- experimental?: BindingExperimentalOptions
387
- profilerNames?: boolean
388
- jsx?: BindingJsx
389
- transform?: TransformOptions
390
- watch?: BindingWatchOption
391
- keepNames?: boolean
392
- checks?: BindingChecksOptions
393
- deferSyncScanData?: undefined | (() => BindingDeferSyncScanData[])
394
- makeAbsoluteExternalsRelative?: BindingMakeAbsoluteExternalsRelative
395
- }
396
-
397
- export interface BindingJsonPluginConfig {
398
- stringify?: BindingJsonPluginStringify
399
- isBuild?: boolean
400
- namedExports?: boolean
401
- }
402
-
403
- export type BindingJsonPluginStringify =
404
- boolean | string
405
-
406
- export interface BindingJsonSourcemap {
407
- file?: string
408
- mappings?: string
409
- sourceRoot?: string
410
- sources?: Array<string | undefined | null>
411
- sourcesContent?: Array<string | undefined | null>
412
- names?: Array<string>
413
- debugId?: string
414
- x_google_ignoreList?: Array<number>
415
- }
416
-
417
- export interface BindingJsWatchChangeEvent {
418
- event: string
419
- }
420
-
421
- /** TODO: support `preserve-react` mode */
422
- export type BindingJsx =
423
- | { type: 'Disable' }
424
- | { type: 'Preserve' }
425
- | { type: 'React' }
426
- | { type: 'ReactJsx' }
427
- | { type: 'Enable', field0: JsxOptions }
428
-
429
- export interface BindingLog {
430
- code: string
431
- message: string
432
- id?: string
433
- exporter?: string
434
- }
435
-
436
- export declare enum BindingLogLevel {
437
- Silent = 0,
438
- Warn = 1,
439
- Info = 2,
440
- Debug = 3
441
- }
442
-
443
- export type BindingMakeAbsoluteExternalsRelative =
444
- | { type: 'Bool', field0: boolean }
445
- | { type: 'IfRelativeSource' }
446
-
447
- export interface BindingManifestPluginConfig {
448
- root: string
449
- outPath: string
450
- }
451
-
452
- export interface BindingMatchGroup {
453
- name: string
454
- test?: BindingStringOrRegex
455
- priority?: number
456
- minSize?: number
457
- minShareCount?: number
458
- minModuleSize?: number
459
- maxModuleSize?: number
460
- maxSize?: number
461
- }
462
-
463
- export interface BindingMfManifest {
464
- filePath?: string
465
- disableAssetsAnalyze?: boolean
466
- fileName?: string
467
- }
468
-
469
- export interface BindingMinifyOptions {
470
- mangle: boolean
471
- compress: boolean
472
- removeWhitespace: boolean
473
- }
474
-
475
- export interface BindingModuleFederationPluginOption {
476
- name: string
477
- filename?: string
478
- exposes?: Record<string, string>
479
- remotes?: Array<BindingRemote>
480
- shared?: Record<string, BindingShared>
481
- runtimePlugins?: Array<string>
482
- manifest?: BindingMfManifest
483
- getPublicPath?: string
484
- }
485
-
486
- export interface BindingModulePreloadPolyfillPluginConfig {
487
- skip?: boolean
488
- }
489
-
490
- export interface BindingModules {
491
- values: Array<BindingRenderedModule>
492
- keys: Array<string>
493
- }
494
-
495
- export interface BindingModuleSideEffectsRule {
496
- test?: RegExp | undefined
497
- sideEffects: boolean
498
- external?: boolean | undefined
499
- }
500
-
501
- export interface BindingNotifyOption {
502
- pollInterval?: number
503
- compareContents?: boolean
504
- }
505
-
506
- export interface BindingOutputOptions {
507
- name?: string
508
- assetFileNames?: string | ((chunk: BindingPreRenderedAsset) => string)
509
- entryFileNames?: string | ((chunk: PreRenderedChunk) => string)
510
- chunkFileNames?: string | ((chunk: PreRenderedChunk) => string)
511
- cssEntryFileNames?: string | ((chunk: PreRenderedChunk) => string)
512
- cssChunkFileNames?: string | ((chunk: PreRenderedChunk) => string)
513
- sanitizeFileName?: boolean | ((name: string) => string)
514
- banner?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
515
- dir?: string
516
- file?: string
517
- esModule?: boolean | 'if-default-prop'
518
- exports?: 'default' | 'named' | 'none' | 'auto'
519
- extend?: boolean
520
- externalLiveBindings?: boolean
521
- footer?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
522
- format?: 'es' | 'cjs' | 'iife' | 'umd' | 'app'
523
- globals?: Record<string, string> | ((name: string) => string)
524
- hashCharacters?: 'base64' | 'base36' | 'hex'
525
- inlineDynamicImports?: boolean
526
- intro?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
527
- outro?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
528
- plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[]
529
- sourcemap?: 'file' | 'inline' | 'hidden'
530
- sourcemapIgnoreList?: (source: string, sourcemapPath: string) => boolean
531
- sourcemapDebugIds?: boolean
532
- sourcemapPathTransform?: (source: string, sourcemapPath: string) => string
533
- minify?: boolean | 'dce-only' | BindingMinifyOptions
534
- advancedChunks?: BindingAdvancedChunksOptions
535
- comments?: 'none' | 'preserve-legal'
536
- polyfillRequire?: boolean
537
- target?: string
538
- }
539
-
540
- export interface BindingPluginContextResolvedId {
541
- id: string
542
- external: BindingResolvedExternal
543
- }
544
-
545
- export interface BindingPluginContextResolveOptions {
546
- importKind?: 'import' | 'dynamic-import' | 'require-call'
547
- skipSelf?: boolean
548
- custom?: number
549
- }
550
-
551
- export interface BindingPluginHookMeta {
552
- order?: BindingPluginOrder
553
- }
554
-
555
- export interface BindingPluginOptions {
556
- name: string
557
- buildStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable>
558
- buildStartMeta?: BindingPluginHookMeta
559
- resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
560
- resolveIdMeta?: BindingPluginHookMeta
561
- resolveIdFilter?: BindingGeneralHookFilter
562
- resolveDynamicImport?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
563
- resolveDynamicImportMeta?: BindingPluginHookMeta
564
- load?: (ctx: BindingPluginContext, id: string) => MaybePromise<VoidNullable<BindingHookLoadOutput>>
565
- loadMeta?: BindingPluginHookMeta
566
- loadFilter?: BindingGeneralHookFilter
567
- transform?: (ctx: BindingTransformPluginContext, id: string, code: string, module_type: BindingTransformHookExtraArgs) => MaybePromise<VoidNullable<BindingHookTransformOutput>>
568
- transformMeta?: BindingPluginHookMeta
569
- transformFilter?: BindingTransformHookFilter
570
- moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>
571
- moduleParsedMeta?: BindingPluginHookMeta
572
- buildEnd?: (ctx: BindingPluginContext, error?: (Error | BindingError)[]) => MaybePromise<VoidNullable>
573
- buildEndMeta?: BindingPluginHookMeta
574
- renderChunk?: (ctx: BindingPluginContext, code: string, chunk: RenderedChunk, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>
575
- renderChunkMeta?: BindingPluginHookMeta
576
- augmentChunkHash?: (ctx: BindingPluginContext, chunk: RenderedChunk) => MaybePromise<void | string>
577
- augmentChunkHashMeta?: BindingPluginHookMeta
578
- renderStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => void
579
- renderStartMeta?: BindingPluginHookMeta
580
- renderError?: (ctx: BindingPluginContext, error: (Error | BindingError)[]) => void
581
- renderErrorMeta?: BindingPluginHookMeta
582
- generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>
583
- generateBundleMeta?: BindingPluginHookMeta
584
- writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>
585
- writeBundleMeta?: BindingPluginHookMeta
586
- closeBundle?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
587
- closeBundleMeta?: BindingPluginHookMeta
588
- watchChange?: (ctx: BindingPluginContext, path: string, event: string) => MaybePromise<VoidNullable>
589
- watchChangeMeta?: BindingPluginHookMeta
590
- closeWatcher?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
591
- closeWatcherMeta?: BindingPluginHookMeta
592
- banner?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
593
- bannerMeta?: BindingPluginHookMeta
594
- footer?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
595
- footerMeta?: BindingPluginHookMeta
596
- intro?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
597
- introMeta?: BindingPluginHookMeta
598
- outro?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
599
- outroMeta?: BindingPluginHookMeta
600
- }
601
-
602
- export declare enum BindingPluginOrder {
603
- Pre = 0,
604
- Post = 1
605
- }
606
-
607
- export interface BindingPluginWithIndex {
608
- index: number
609
- plugin: BindingPluginOptions
610
- }
611
-
612
- export interface BindingPreRenderedAsset {
613
- names: Array<string>
614
- originalFileNames: Array<string>
615
- source: BindingAssetSource
616
- }
617
-
618
- export interface BindingRemote {
619
- type?: string
620
- entry: string
621
- name: string
622
- entryGlobalName?: string
623
- shareScope?: string
624
- }
625
-
626
- export interface BindingReplacePluginConfig {
627
- values: Record<string, string>
628
- delimiters?: [string, string]
629
- preventAssignment?: boolean
630
- objectGuards?: boolean
631
- sourcemap?: boolean
632
- }
633
-
634
- export type BindingResolvedExternal =
635
- | { type: 'Bool', field0: boolean }
636
- | { type: 'Absolute' }
637
- | { type: 'Relative' }
638
-
639
- export interface BindingResolveOptions {
640
- alias?: Array<AliasItem>
641
- aliasFields?: Array<Array<string>>
642
- conditionNames?: Array<string>
643
- exportsFields?: Array<Array<string>>
644
- extensions?: Array<string>
645
- extensionAlias?: Array<ExtensionAliasItem>
646
- mainFields?: Array<string>
647
- mainFiles?: Array<string>
648
- modules?: Array<string>
649
- symlinks?: boolean
650
- tsconfigFilename?: string
651
- }
652
-
653
- export interface BindingShared {
654
- version?: string
655
- shareScope?: string
656
- singleton?: boolean
657
- requiredVersion?: string
658
- strictVersion?: boolean
659
- }
660
-
661
- export interface BindingSourcemap {
662
- inner: string | BindingJsonSourcemap
663
- }
664
-
665
- export interface BindingTransformHookExtraArgs {
666
- moduleType: string
667
- }
668
-
669
- export interface BindingTransformHookFilter {
670
- code?: BindingGeneralHookFilter
671
- moduleType?: Array<string>
672
- id?: BindingGeneralHookFilter
673
- }
674
-
675
- export interface BindingTransformPluginConfig {
676
- include?: Array<BindingStringOrRegex>
677
- exclude?: Array<BindingStringOrRegex>
678
- jsxInject?: string
679
- reactRefresh?: boolean
680
- target?: string
681
- browserslist?: string
682
- }
683
-
684
- export interface BindingTreeshake {
685
- moduleSideEffects: boolean | BindingModuleSideEffectsRule[] | ((id: string, is_external: boolean) => boolean | undefined)
686
- annotations?: boolean
687
- manualPureFunctions?: Array<string>
688
- unknownGlobalSideEffects?: boolean
689
- }
690
-
691
- export interface BindingViteResolvePluginConfig {
692
- resolveOptions: BindingViteResolvePluginResolveOptions
693
- environmentConsumer: string
694
- environmentName: string
695
- external: true | string[]
696
- noExternal: true | Array<string | RegExp>
697
- dedupe: Array<string>
698
- finalizeBareSpecifier?: (resolvedId: string, rawId: string, importer: string | null | undefined) => VoidNullable<string>
699
- finalizeOtherSpecifiers?: (resolvedId: string, rawId: string) => VoidNullable<string>
700
- runtime: string
701
- }
702
-
703
- export interface BindingViteResolvePluginResolveOptions {
704
- isBuild: boolean
705
- isProduction: boolean
706
- asSrc: boolean
707
- preferRelative: boolean
708
- isRequire?: boolean
709
- root: string
710
- scan: boolean
711
- mainFields: Array<string>
712
- conditions: Array<string>
713
- externalConditions: Array<string>
714
- extensions: Array<string>
715
- tryIndex: boolean
716
- tryPrefix?: string
717
- preserveSymlinks: boolean
718
- }
719
-
720
- export interface BindingWatchOption {
721
- skipWrite?: boolean
722
- include?: Array<BindingStringOrRegex>
723
- exclude?: Array<BindingStringOrRegex>
724
- buildDelay?: number
725
- }
726
-
727
- export interface Comment {
728
- type: 'Line' | 'Block'
729
- value: string
730
- start: number
731
- end: number
732
- }
733
-
734
- export interface CompilerAssumptions {
735
- ignoreFunctionLength?: boolean
736
- noDocumentAll?: boolean
737
- objectRestNoSymbols?: boolean
738
- pureGetters?: boolean
739
- setPublicClassFields?: boolean
740
- }
741
-
742
- export interface DecoratorOptions {
743
- /**
744
- * Enables experimental support for decorators, which is a version of decorators that predates the TC39 standardization process.
745
- *
746
- * Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification.
747
- * This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
748
- *
749
- * @see https://www.typescriptlang.org/tsconfig/#experimentalDecorators
750
- * @default false
751
- */
752
- legacy?: boolean
753
- /**
754
- * Enables emitting decorator metadata.
755
- *
756
- * This option the same as [emitDecoratorMetadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata)
757
- * in TypeScript, and it only works when `legacy` is true.
758
- *
759
- * @see https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata
760
- * @default false
761
- */
762
- emitDecoratorMetadata?: boolean
763
- }
764
-
765
- export interface DynamicImport {
766
- start: number
767
- end: number
768
- moduleRequest: Span
769
- }
770
-
771
- export interface EcmaScriptModule {
772
- /**
773
- * Has ESM syntax.
774
- *
775
- * i.e. `import` and `export` statements, and `import.meta`.
776
- *
777
- * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
778
- */
779
- hasModuleSyntax: boolean
780
- /** Import statements. */
781
- staticImports: Array<StaticImport>
782
- /** Export statements. */
783
- staticExports: Array<StaticExport>
784
- /** Dynamic import expressions. */
785
- dynamicImports: Array<DynamicImport>
786
- /** Span positions` of `import.meta` */
787
- importMetas: Array<Span>
788
- }
789
-
790
- export interface ErrorLabel {
791
- message?: string
792
- start: number
793
- end: number
794
- }
795
-
796
- export interface Es2015Options {
797
- /** Transform arrow functions into function expressions. */
798
- arrowFunction?: ArrowFunctionsOptions
799
- }
800
-
801
- export interface ExportExportName {
802
- kind: ExportExportNameKind
803
- name?: string
804
- start?: number
805
- end?: number
806
- }
807
-
808
- export type ExportExportNameKind = /** `export { name } */
809
- 'Name'|
810
- /** `export default expression` */
811
- 'Default'|
812
- /** `export * from "mod" */
813
- 'None';
814
-
815
- export interface ExportImportName {
816
- kind: ExportImportNameKind
817
- name?: string
818
- start?: number
819
- end?: number
820
- }
821
-
822
- export type ExportImportNameKind = /** `export { name } */
823
- 'Name'|
824
- /** `export * as ns from "mod"` */
825
- 'All'|
826
- /** `export * from "mod"` */
827
- 'AllButDefault'|
828
- /** Does not have a specifier. */
829
- 'None';
830
-
831
- export interface ExportLocalName {
832
- kind: ExportLocalNameKind
833
- name?: string
834
- start?: number
835
- end?: number
836
- }
837
-
838
- export type ExportLocalNameKind = /** `export { name } */
839
- 'Name'|
840
- /** `export default expression` */
841
- 'Default'|
842
- /**
843
- * If the exported value is not locally accessible from within the module.
844
- * `export default function () {}`
845
- */
846
- 'None';
847
-
848
- export interface ExtensionAliasItem {
849
- target: string
850
- replacements: Array<string>
851
- }
852
-
853
- /**
854
- * Get offset within a `Uint8Array` which is aligned on 4 GiB.
855
- *
856
- * Does not check that the offset is within bounds of `buffer`.
857
- * To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
858
- */
859
- export declare function getBufferOffset(buffer: Uint8Array): number
860
-
861
- export type HelperMode = /**
862
- * Runtime mode (default): Helper functions are imported from a runtime package.
863
- *
864
- * Example:
865
- *
866
- * ```js
867
- * import helperName from "@oxc-project/runtime/helpers/helperName";
868
- * helperName(...arguments);
869
- * ```
870
- */
871
- 'Runtime'|
872
- /**
873
- * External mode: Helper functions are accessed from a global `babelHelpers` object.
874
- *
875
- * Example:
876
- *
877
- * ```js
878
- * babelHelpers.helperName(...arguments);
879
- * ```
880
- */
881
- 'External';
882
-
883
- export interface Helpers {
884
- mode?: HelperMode
885
- }
886
-
887
- export interface ImportName {
888
- kind: ImportNameKind
889
- name?: string
890
- start?: number
891
- end?: number
892
- }
893
-
894
- export type ImportNameKind = /** `import { x } from "mod"` */
895
- 'Name'|
896
- /** `import * as ns from "mod"` */
897
- 'NamespaceObject'|
898
- /** `import defaultExport from "mod"` */
899
- 'Default';
900
-
901
- /** TypeScript Isolated Declarations for Standalone DTS Emit */
902
- export declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult
903
-
904
- export interface IsolatedDeclarationsOptions {
905
- /**
906
- * Do not emit declarations for code that has an @internal annotation in its JSDoc comment.
907
- * This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
908
- *
909
- * Default: `false`
910
- *
911
- * See <https://www.typescriptlang.org/tsconfig/#stripInternal>
912
- */
913
- stripInternal?: boolean
914
- sourcemap?: boolean
915
- }
916
-
917
- export interface IsolatedDeclarationsResult {
918
- code: string
919
- map?: SourceMap
920
- errors: Array<OxcError>
921
- }
922
-
923
- export interface JsChangedOutputs {
924
- chunks: Array<JsOutputChunk>
925
- assets: Array<JsOutputAsset>
926
- deleted: Array<string>
927
- }
928
-
929
- export interface JsOutputAsset {
930
- names: Array<string>
931
- originalFileNames: Array<string>
932
- filename: string
933
- source: BindingAssetSource
934
- }
935
-
936
- export interface JsOutputChunk {
937
- name: string
938
- isEntry: boolean
939
- isDynamicEntry: boolean
940
- facadeModuleId?: string
941
- moduleIds: Array<string>
942
- exports: Array<string>
943
- filename: string
944
- modules: Record<string, BindingRenderedModule>
945
- imports: Array<string>
946
- dynamicImports: Array<string>
947
- code: string
948
- map?: BindingSourcemap
949
- sourcemapFilename?: string
950
- preliminaryFilename: string
951
- }
952
-
953
- /**
954
- * Configure how TSX and JSX are transformed.
955
- *
956
- * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#options}
957
- */
958
- export interface JsxOptions {
959
- /**
960
- * Decides which runtime to use.
961
- *
962
- * - 'automatic' - auto-import the correct JSX factories
963
- * - 'classic' - no auto-import
964
- *
965
- * @default 'automatic'
966
- */
967
- runtime?: 'classic' | 'automatic'
968
- /**
969
- * Emit development-specific information, such as `__source` and `__self`.
970
- *
971
- * @default false
972
- *
973
- * @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx-development}
974
- */
975
- development?: boolean
976
- /**
977
- * Toggles whether or not to throw an error if an XML namespaced tag name
978
- * is used.
979
- *
980
- * Though the JSX spec allows this, it is disabled by default since React's
981
- * JSX does not currently have support for it.
982
- *
983
- * @default true
984
- */
985
- throwIfNamespace?: boolean
986
- /**
987
- * Enables `@babel/plugin-transform-react-pure-annotations`.
988
- *
989
- * It will mark top-level React method calls as pure for tree shaking.
990
- *
991
- * @see {@link https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations}
992
- *
993
- * @default true
994
- */
995
- pure?: boolean
996
- /**
997
- * Replaces the import source when importing functions.
998
- *
999
- * @default 'react'
1000
- */
1001
- importSource?: string
1002
- /**
1003
- * Replace the function used when compiling JSX expressions. It should be a
1004
- * qualified name (e.g. `React.createElement`) or an identifier (e.g.
1005
- * `createElement`).
1006
- *
1007
- * Only used for `classic` {@link runtime}.
1008
- *
1009
- * @default 'React.createElement'
1010
- */
1011
- pragma?: string
1012
- /**
1013
- * Replace the component used when compiling JSX fragments. It should be a
1014
- * valid JSX tag name.
1015
- *
1016
- * Only used for `classic` {@link runtime}.
1017
- *
1018
- * @default 'React.Fragment'
1019
- */
1020
- pragmaFrag?: string
1021
- /**
1022
- * When spreading props, use `Object.assign` directly instead of an extend helper.
1023
- *
1024
- * Only used for `classic` {@link runtime}.
1025
- *
1026
- * @default false
1027
- */
1028
- useBuiltIns?: boolean
1029
- /**
1030
- * When spreading props, use inline object with spread elements directly
1031
- * instead of an extend helper or Object.assign.
1032
- *
1033
- * Only used for `classic` {@link runtime}.
1034
- *
1035
- * @default false
1036
- */
1037
- useSpread?: boolean
1038
- /**
1039
- * Enable React Fast Refresh .
1040
- *
1041
- * Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
1042
- *
1043
- * @default false
1044
- */
1045
- refresh?: boolean | ReactRefreshOptions
1046
- }
1047
-
1048
- /**
1049
- * Transform JavaScript code to a Vite Node runnable module.
1050
- *
1051
- * @param filename The name of the file being transformed.
1052
- * @param sourceText the source code itself
1053
- * @param options The options for the transformation. See {@link
1054
- * ModuleRunnerTransformOptions} for more information.
1055
- *
1056
- * @returns an object containing the transformed code, source maps, and any
1057
- * errors that occurred during parsing or transformation.
1058
- *
1059
- * @deprecated Only works for Vite.
1060
- */
1061
- export declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult
1062
-
1063
- export interface ModuleRunnerTransformOptions {
1064
- /**
1065
- * Enable source map generation.
1066
- *
1067
- * When `true`, the `sourceMap` field of transform result objects will be populated.
1068
- *
1069
- * @default false
1070
- *
1071
- * @see {@link SourceMap}
1072
- */
1073
- sourcemap?: boolean
1074
- }
1075
-
1076
- export interface ModuleRunnerTransformResult {
1077
- /**
1078
- * The transformed code.
1079
- *
1080
- * If parsing failed, this will be an empty string.
1081
- */
1082
- code: string
1083
- /**
1084
- * The source map for the transformed code.
1085
- *
1086
- * This will be set if {@link TransformOptions#sourcemap} is `true`.
1087
- */
1088
- map?: SourceMap
1089
- deps: Array<string>
1090
- dynamicDeps: Array<string>
1091
- /**
1092
- * Parse and transformation errors.
1093
- *
1094
- * Oxc's parser recovers from common syntax errors, meaning that
1095
- * transformed code may still be available even if there are errors in this
1096
- * list.
1097
- */
1098
- errors: Array<OxcError>
1099
- }
1100
-
1101
- export interface OxcError {
1102
- severity: Severity
1103
- message: string
1104
- labels: Array<ErrorLabel>
1105
- helpMessage?: string
1106
- }
1107
-
1108
- /**
1109
- * Parse asynchronously.
1110
- *
1111
- * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
1112
- */
1113
- export declare function parseAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
1114
-
1115
- export interface ParserOptions {
1116
- sourceType?: 'script' | 'module' | 'unambiguous' | undefined
1117
- /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1118
- lang?: 'js' | 'jsx' | 'ts' | 'tsx'
1119
- /**
1120
- * Return an AST which includes TypeScript-related properties, or excludes them.
1121
- *
1122
- * `'js'` is default for JS / JSX files.
1123
- * `'ts'` is default for TS / TSX files.
1124
- * The type of the file is determined from `lang` option, or extension of provided `filename`.
1125
- */
1126
- astType?: 'js' | 'ts'
1127
- /**
1128
- * Emit `ParenthesizedExpression` and `TSParenthesizedType` in AST.
1129
- *
1130
- * If this option is true, parenthesized expressions are represented by
1131
- * (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` nodes that
1132
- * have a single `expression` property containing the expression inside parentheses.
1133
- *
1134
- * @default true
1135
- */
1136
- preserveParens?: boolean
1137
- /**
1138
- * Produce semantic errors with an additional AST pass.
1139
- * Semantic errors depend on symbols and scopes, where the parser does not construct.
1140
- * This adds a small performance overhead.
1141
- *
1142
- * @default false
1143
- */
1144
- showSemanticErrors?: boolean
1145
- }
1146
-
1147
- /** Parse synchronously. */
1148
- export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
1149
-
1150
- /**
1151
- * Parses AST into provided `Uint8Array` buffer.
1152
- *
1153
- * Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
1154
- * provided as `source_len`.
1155
- *
1156
- * This function will parse the source, and write the AST into the buffer, starting at the end.
1157
- *
1158
- * It also writes to the very end of the buffer the offset of `Program` within the buffer.
1159
- *
1160
- * Caller can deserialize data from the buffer on JS side.
1161
- *
1162
- * # SAFETY
1163
- *
1164
- * Caller must ensure:
1165
- * * Source text is written into start of the buffer.
1166
- * * Source text's UTF-8 byte length is `source_len`.
1167
- * * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
1168
- *
1169
- * If source text is originally a JS string on JS side, and converted to a buffer with
1170
- * `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
1171
- *
1172
- * # Panics
1173
- *
1174
- * Panics if source text is too long, or AST takes more memory than is available in the buffer.
1175
- */
1176
- export declare function parseSyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): void
1177
-
1178
- export interface PreRenderedChunk {
1179
- name: string
1180
- isEntry: boolean
1181
- isDynamicEntry: boolean
1182
- facadeModuleId?: string
1183
- moduleIds: Array<string>
1184
- exports: Array<string>
1185
- }
1186
-
1187
- /** Returns `true` if raw transfer is supported on this platform. */
1188
- export declare function rawTransferSupported(): boolean
1189
-
1190
- export interface ReactRefreshOptions {
1191
- /**
1192
- * Specify the identifier of the refresh registration variable.
1193
- *
1194
- * @default `$RefreshReg$`.
1195
- */
1196
- refreshReg?: string
1197
- /**
1198
- * Specify the identifier of the refresh signature variable.
1199
- *
1200
- * @default `$RefreshSig$`.
1201
- */
1202
- refreshSig?: string
1203
- emitFullSignatures?: boolean
1204
- }
1205
-
1206
- export declare function registerPlugins(id: number, plugins: Array<BindingPluginWithIndex>): void
1207
-
1208
- export type Severity = 'Error'|
1209
- 'Warning'|
1210
- 'Advice';
1211
-
1212
- export interface SourceMap {
1213
- file?: string
1214
- mappings: string
1215
- names: Array<string>
1216
- sourceRoot?: string
1217
- sources: Array<string>
1218
- sourcesContent?: Array<string>
1219
- version: number
1220
- x_google_ignoreList?: Array<number>
1221
- }
1222
-
1223
- export interface Span {
1224
- start: number
1225
- end: number
1226
- }
1227
-
1228
- export interface StaticExport {
1229
- start: number
1230
- end: number
1231
- entries: Array<StaticExportEntry>
1232
- }
1233
-
1234
- export interface StaticExportEntry {
1235
- start: number
1236
- end: number
1237
- moduleRequest?: ValueSpan
1238
- /** The name under which the desired binding is exported by the module`. */
1239
- importName: ExportImportName
1240
- /** The name used to export this binding by this module. */
1241
- exportName: ExportExportName
1242
- /** The name that is used to locally access the exported value from within the importing module. */
1243
- localName: ExportLocalName
1244
- }
1245
-
1246
- export interface StaticImport {
1247
- /** Start of import statement. */
1248
- start: number
1249
- /** End of import statement. */
1250
- end: number
1251
- /**
1252
- * Import source.
1253
- *
1254
- * ```js
1255
- * import { foo } from "mod";
1256
- * // ^^^
1257
- * ```
1258
- */
1259
- moduleRequest: ValueSpan
1260
- /**
1261
- * Import specifiers.
1262
- *
1263
- * Empty for `import "mod"`.
1264
- */
1265
- entries: Array<StaticImportEntry>
1266
- }
1267
-
1268
- export interface StaticImportEntry {
1269
- /**
1270
- * The name under which the desired binding is exported by the module.
1271
- *
1272
- * ```js
1273
- * import { foo } from "mod";
1274
- * // ^^^
1275
- * import { foo as bar } from "mod";
1276
- * // ^^^
1277
- * ```
1278
- */
1279
- importName: ImportName
1280
- /**
1281
- * The name that is used to locally access the imported value from within the importing module.
1282
- * ```js
1283
- * import { foo } from "mod";
1284
- * // ^^^
1285
- * import { foo as bar } from "mod";
1286
- * // ^^^
1287
- * ```
1288
- */
1289
- localName: ValueSpan
1290
- /**
1291
- * Whether this binding is for a TypeScript type-only import.
1292
- *
1293
- * `true` for the following imports:
1294
- * ```ts
1295
- * import type { foo } from "mod";
1296
- * import { type foo } from "mod";
1297
- * ```
1298
- */
1299
- isType: boolean
1300
- }
1301
-
1302
- /**
1303
- * Transpile a JavaScript or TypeScript into a target ECMAScript version.
1304
- *
1305
- * @param filename The name of the file being transformed. If this is a
1306
- * relative path, consider setting the {@link TransformOptions#cwd} option..
1307
- * @param sourceText the source code itself
1308
- * @param options The options for the transformation. See {@link
1309
- * TransformOptions} for more information.
1310
- *
1311
- * @returns an object containing the transformed code, source maps, and any
1312
- * errors that occurred during parsing or transformation.
1313
- */
1314
- export declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult
1315
-
1316
- /**
1317
- * Options for transforming a JavaScript or TypeScript file.
1318
- *
1319
- * @see {@link transform}
1320
- */
1321
- export interface TransformOptions {
1322
- sourceType?: 'script' | 'module' | 'unambiguous' | undefined
1323
- /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1324
- lang?: 'js' | 'jsx' | 'ts' | 'tsx'
1325
- /**
1326
- * The current working directory. Used to resolve relative paths in other
1327
- * options.
1328
- */
1329
- cwd?: string
1330
- /**
1331
- * Enable source map generation.
1332
- *
1333
- * When `true`, the `sourceMap` field of transform result objects will be populated.
1334
- *
1335
- * @default false
1336
- *
1337
- * @see {@link SourceMap}
1338
- */
1339
- sourcemap?: boolean
1340
- /** Set assumptions in order to produce smaller output. */
1341
- assumptions?: CompilerAssumptions
1342
- /** Configure how TypeScript is transformed. */
1343
- typescript?: TypeScriptOptions
1344
- /** Configure how TSX and JSX are transformed. */
1345
- jsx?: 'preserve' | JsxOptions
1346
- /**
1347
- * Sets the target environment for the generated JavaScript.
1348
- *
1349
- * The lowest target is `es2015`.
1350
- *
1351
- * Example:
1352
- *
1353
- * * 'es2015'
1354
- * * ['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']
1355
- *
1356
- * @default `esnext` (No transformation)
1357
- *
1358
- * @see [esbuild#target](https://esbuild.github.io/api/#target)
1359
- */
1360
- target?: string | Array<string>
1361
- /** Behaviour for runtime helpers. */
1362
- helpers?: Helpers
1363
- /** Define Plugin */
1364
- define?: Record<string, string>
1365
- /** Inject Plugin */
1366
- inject?: Record<string, string | [string, string]>
1367
- /** Decorator plugin */
1368
- decorator?: DecoratorOptions
1369
- }
1370
-
1371
- export interface TransformResult {
1372
- /**
1373
- * The transformed code.
1374
- *
1375
- * If parsing failed, this will be an empty string.
1376
- */
1377
- code: string
1378
- /**
1379
- * The source map for the transformed code.
1380
- *
1381
- * This will be set if {@link TransformOptions#sourcemap} is `true`.
1382
- */
1383
- map?: SourceMap
1384
- /**
1385
- * The `.d.ts` declaration file for the transformed code. Declarations are
1386
- * only generated if `declaration` is set to `true` and a TypeScript file
1387
- * is provided.
1388
- *
1389
- * If parsing failed and `declaration` is set, this will be an empty string.
1390
- *
1391
- * @see {@link TypeScriptOptions#declaration}
1392
- * @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
1393
- */
1394
- declaration?: string
1395
- /**
1396
- * Declaration source map. Only generated if both
1397
- * {@link TypeScriptOptions#declaration declaration} and
1398
- * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
1399
- */
1400
- declarationMap?: SourceMap
1401
- /**
1402
- * Helpers used.
1403
- *
1404
- * @internal
1405
- *
1406
- * Example:
1407
- *
1408
- * ```text
1409
- * { "_objectSpread": "@oxc-project/runtime/helpers/objectSpread2" }
1410
- * ```
1411
- */
1412
- helpersUsed: Record<string, string>
1413
- /**
1414
- * Parse and transformation errors.
1415
- *
1416
- * Oxc's parser recovers from common syntax errors, meaning that
1417
- * transformed code may still be available even if there are errors in this
1418
- * list.
1419
- */
1420
- errors: Array<OxcError>
1421
- }
1422
-
1423
- export interface TypeScriptOptions {
1424
- jsxPragma?: string
1425
- jsxPragmaFrag?: string
1426
- onlyRemoveTypeImports?: boolean
1427
- allowNamespaces?: boolean
1428
- allowDeclareFields?: boolean
1429
- /**
1430
- * Also generate a `.d.ts` declaration file for TypeScript files.
1431
- *
1432
- * The source file must be compliant with all
1433
- * [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
1434
- * requirements.
1435
- *
1436
- * @default false
1437
- */
1438
- declaration?: IsolatedDeclarationsOptions
1439
- /**
1440
- * Rewrite or remove TypeScript import/export declaration extensions.
1441
- *
1442
- * - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
1443
- * - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
1444
- * - When set to `true`, it's equivalent to `rewrite`.
1445
- * - When set to `false` or omitted, no changes will be made to the extensions.
1446
- *
1447
- * @default false
1448
- */
1449
- rewriteImportExtensions?: 'rewrite' | 'remove' | boolean
1450
- }
1451
-
1452
- export interface ValueSpan {
1453
- value: string
1454
- start: number
1455
- end: number
1456
- }