rolldown 0.12.2 → 0.13.0-snapshot-d24c337-20240904003206

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 (67) hide show
  1. package/dist/cjs/cli.cjs +1552 -584
  2. package/dist/cjs/experimental-index.cjs +40 -0
  3. package/dist/cjs/index.cjs +5 -22
  4. package/dist/cjs/parallel-plugin-worker.cjs +7 -7
  5. package/dist/cjs/parallel-plugin.cjs +1 -1
  6. package/dist/esm/cli.mjs +1549 -583
  7. package/dist/esm/experimental-index.mjs +23 -0
  8. package/dist/esm/index.mjs +5 -17
  9. package/dist/esm/parallel-plugin-worker.mjs +6 -6
  10. package/dist/esm/parallel-plugin.mjs +1 -1
  11. package/dist/shared/{chunk-1xb6WR3y.cjs → chunk-gQ4GMlVi.cjs} +3 -2
  12. package/dist/shared/{consola.36c0034f-N8xiTrv3.cjs → consola.36c0034f-eps_ogJv.cjs} +188 -188
  13. package/dist/shared/{consola.36c0034f-jtHhMkSX.mjs → consola.36c0034f-m5cABVv4.mjs} +187 -187
  14. package/dist/shared/package-3VR4tEG7.mjs +9 -0
  15. package/dist/shared/package-OJCNSbf0.cjs +11 -0
  16. package/dist/shared/plugin-context-data-AMG1kfMv.mjs +1443 -0
  17. package/dist/shared/plugin-context-data-S1bXhfAf.cjs +1436 -0
  18. package/dist/shared/{prompt-pjyLzLci.mjs → prompt-9VjtYvi_.mjs} +182 -182
  19. package/dist/shared/{prompt-1K6oCkIU.cjs → prompt-Ah5G71p-.cjs} +183 -183
  20. package/dist/shared/rolldown-NGdGAW73.mjs +1069 -0
  21. package/dist/shared/rolldown-binding.wasi.cjs +70 -51
  22. package/dist/shared/rolldown-z62CIhEW.cjs +1085 -0
  23. package/dist/types/binding.d.ts +329 -14
  24. package/dist/types/cli/arguments/alias.d.ts +8 -0
  25. package/dist/types/cli/arguments/index.d.ts +13 -0
  26. package/dist/types/cli/arguments/normalize.d.ts +15 -0
  27. package/dist/types/cli/arguments/schema.d.ts +161 -0
  28. package/dist/types/cli/arguments/utils.d.ts +6 -0
  29. package/dist/types/cli/commands/bundle.d.ts +3 -1
  30. package/dist/types/cli/commands/help.d.ts +1 -0
  31. package/dist/types/cli/utils.d.ts +1 -1
  32. package/dist/types/constants/plugin-context.d.ts +7 -0
  33. package/dist/types/constants/plugin.d.ts +36 -0
  34. package/dist/types/experimental-index.d.ts +5 -0
  35. package/dist/types/index.d.ts +8 -8
  36. package/dist/types/options/input-options.d.ts +139 -27
  37. package/dist/types/options/normalized-alias-plugin-config.d.ts +10 -0
  38. package/dist/types/options/normalized-ecma-transform-plugin-config.d.ts +8 -0
  39. package/dist/types/options/normalized-output-options.d.ts +8 -3
  40. package/dist/types/options/output-options.d.ts +102 -11
  41. package/dist/types/options/utils.d.ts +2 -0
  42. package/dist/types/plugin/bindingify-build-hooks.d.ts +9 -8
  43. package/dist/types/plugin/bindingify-hook-filter.d.ts +5 -0
  44. package/dist/types/plugin/bindingify-output-hooks.d.ts +11 -7
  45. package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +8 -0
  46. package/dist/types/plugin/bindingify-plugin.d.ts +2 -1
  47. package/dist/types/plugin/builtin-plugin.d.ts +75 -7
  48. package/dist/types/plugin/index.d.ts +68 -28
  49. package/dist/types/plugin/plugin-context-data.d.ts +6 -0
  50. package/dist/types/plugin/plugin-context.d.ts +18 -8
  51. package/dist/types/plugin/plugin-driver.d.ts +2 -2
  52. package/dist/types/rollup.d.ts +1 -0
  53. package/dist/types/types/rolldown-output.d.ts +1 -0
  54. package/dist/types/utils/compose-js-plugins.d.ts +2 -0
  55. package/dist/types/utils/misc.d.ts +1 -0
  56. package/dist/types/utils/normalize-hook.d.ts +7 -5
  57. package/dist/types/utils/plugin/index.d.ts +2 -0
  58. package/dist/types/utils/type-assert.d.ts +1 -0
  59. package/package.json +30 -22
  60. package/dist/shared/rolldown-SCF5NBN_.cjs +0 -49
  61. package/dist/shared/rolldown-kYz4BvAA.mjs +0 -48
  62. package/dist/shared/utils_index-_DFpKlu1.mjs +0 -1582
  63. package/dist/shared/utils_index-xb2NoRNm.cjs +0 -1557
  64. package/dist/types/cli/constants.d.ts +0 -1
  65. package/dist/types/utils/ensure-array.d.ts +0 -1
  66. package/dist/types/utils/index.d.ts +0 -9
  67. /package/dist/types/plugin/{transfrom-plugin-context.d.ts → transform-plugin-context.d.ts} +0 -0
@@ -18,6 +18,7 @@ export declare class BindingModuleInfo {
18
18
 
19
19
  export declare class BindingOutputAsset {
20
20
  get fileName(): string
21
+ get originalFileName(): string | null
21
22
  get source(): BindingAssetSource
22
23
  set source(source: BindingAssetSource)
23
24
  get name(): string | null
@@ -90,33 +91,80 @@ export interface AliasItem {
90
91
  }
91
92
 
92
93
  export interface ArrowFunctionsBindingOptions {
94
+ /**
95
+ * This option enables the following:
96
+ * * Wrap the generated function in .bind(this) and keeps uses of this inside the function as-is, instead of using a renamed this.
97
+ * * Add a runtime check to ensure the functions are not instantiated.
98
+ * * Add names to arrow functions.
99
+ *
100
+ * @default false
101
+ */
93
102
  spec?: boolean
94
103
  }
95
104
 
105
+ export interface BindingAliasPluginAlias {
106
+ find: BindingStringOrRegex
107
+ replacement: string
108
+ }
109
+
110
+ export interface BindingAliasPluginConfig {
111
+ entries: Array<BindingAliasPluginAlias>
112
+ }
113
+
96
114
  export interface BindingAssetSource {
97
115
  inner: string | Uint8Array
98
116
  }
99
117
 
118
+ export interface BindingBuildImportAnalysisPluginConfig {
119
+ preloadCode: string
120
+ insertPreload: boolean
121
+ optimizeModulePreloadRelativePaths: boolean
122
+ renderBuiltUrl: boolean
123
+ isRelativeBase: boolean
124
+ }
125
+
100
126
  export interface BindingBuiltinPlugin {
101
- name: BindingBuiltinPluginName
127
+ __name: BindingBuiltinPluginName
102
128
  options?: unknown
103
129
  }
104
130
 
105
131
  export declare enum BindingBuiltinPluginName {
106
- WasmPlugin = 0,
107
- GlobImportPlugin = 1
132
+ WasmHelperPlugin = 0,
133
+ ImportGlobPlugin = 1,
134
+ DynamicImportVarsPlugin = 2,
135
+ ModulePreloadPolyfillPlugin = 3,
136
+ ManifestPlugin = 4,
137
+ LoadFallbackPlugin = 5,
138
+ TransformPlugin = 6,
139
+ WasmFallbackPlugin = 7,
140
+ AliasPlugin = 8,
141
+ JsonPlugin = 9,
142
+ BuildImportAnalysisPlugin = 10,
143
+ ReplacePlugin = 11
108
144
  }
109
145
 
110
146
  export interface BindingEmittedAsset {
111
147
  name?: string
112
148
  fileName?: string
149
+ originalFileName?: string
113
150
  source: BindingAssetSource
114
151
  }
115
152
 
153
+ export interface BindingGeneralHookFilter {
154
+ include?: Array<BindingStringOrRegex>
155
+ exclude?: Array<BindingStringOrRegex>
156
+ }
157
+
158
+ export interface BindingGlobImportPluginConfig {
159
+ root?: string
160
+ restoreQueryExtension?: boolean
161
+ }
162
+
116
163
  export interface BindingHookLoadOutput {
117
164
  code: string
118
165
  sideEffects?: BindingHookSideEffects
119
166
  map?: BindingSourcemap
167
+ moduleType?: string
120
168
  }
121
169
 
122
170
  export interface BindingHookRenderChunkOutput {
@@ -124,7 +172,8 @@ export interface BindingHookRenderChunkOutput {
124
172
  map?: BindingSourcemap
125
173
  }
126
174
 
127
- export interface BindingHookResolveIdExtraOptions {
175
+ export interface BindingHookResolveIdExtraArgs {
176
+ custom?: number
128
177
  isEntry: boolean
129
178
  kind: 'import' | 'dynamic-import' | 'require-call'
130
179
  }
@@ -145,6 +194,20 @@ export interface BindingHookTransformOutput {
145
194
  code?: string
146
195
  sideEffects?: BindingHookSideEffects
147
196
  map?: BindingSourcemap
197
+ moduleType?: string
198
+ }
199
+
200
+ export interface BindingInjectImportNamed {
201
+ tagNamed: true
202
+ imported: string
203
+ alias?: string
204
+ from: string
205
+ }
206
+
207
+ export interface BindingInjectImportNamespace {
208
+ tagNamespace: true
209
+ alias: string
210
+ from: string
148
211
  }
149
212
 
150
213
  export interface BindingInputItem {
@@ -164,6 +227,13 @@ export interface BindingInputOptions {
164
227
  cwd: string
165
228
  treeshake?: BindingTreeshake
166
229
  moduleTypes?: Record<string, string>
230
+ define?: Array<[string, string]>
231
+ inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>
232
+ }
233
+
234
+ export interface BindingJsonPluginConfig {
235
+ stringify?: boolean
236
+ isBuild?: boolean
167
237
  }
168
238
 
169
239
  export interface BindingJsonSourcemap {
@@ -182,16 +252,32 @@ export declare enum BindingLogLevel {
182
252
  Debug = 3
183
253
  }
184
254
 
255
+ export interface BindingManifestPluginConfig {
256
+ root: string
257
+ outPath: string
258
+ }
259
+
260
+ export interface BindingModulePreloadPolyfillPluginConfig {
261
+ skip?: boolean
262
+ }
263
+
185
264
  export interface BindingOutputOptions {
186
265
  name?: string
187
- entryFileNames?: string
188
- chunkFileNames?: string
266
+ entryFileNames?: string | ((chunk: PreRenderedChunk) => string)
267
+ chunkFileNames?: string | ((chunk: PreRenderedChunk) => string)
189
268
  assetFileNames?: string
190
269
  banner?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
191
270
  dir?: string
271
+ esModule?: boolean | 'if-default-prop'
192
272
  exports?: 'default' | 'named' | 'none' | 'auto'
273
+ extend?: boolean
274
+ externalLiveBindings?: boolean
193
275
  footer?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
194
276
  format?: 'es' | 'cjs' | 'iife'
277
+ globals?: Record<string, string>
278
+ inlineDynamicImports?: boolean
279
+ intro?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
280
+ outro?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
195
281
  plugins: (BindingBuiltinPlugin | BindingPluginOptions | undefined)[]
196
282
  sourcemap?: 'file' | 'inline' | 'hidden'
197
283
  sourcemapIgnoreList?: (source: string, sourcemapPath: string) => boolean
@@ -206,24 +292,58 @@ export interface BindingPluginContextResolvedId {
206
292
 
207
293
  export interface BindingPluginContextResolveOptions {
208
294
  importKind?: 'import' | 'dynamic-import' | 'require-call'
295
+ skipSelf?: boolean
296
+ custom?: number
297
+ }
298
+
299
+ export interface BindingPluginHookMeta {
300
+ order?: BindingPluginOrder
209
301
  }
210
302
 
211
303
  export interface BindingPluginOptions {
212
304
  name: string
213
305
  buildStart?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
214
- resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraOptions) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
306
+ buildStartMeta?: BindingPluginHookMeta
307
+ resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
308
+ resolveIdMeta?: BindingPluginHookMeta
309
+ resolveIdFilter?: BindingGeneralHookFilter
215
310
  resolveDynamicImport?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
311
+ resolveDynamicImportMeta?: BindingPluginHookMeta
216
312
  load?: (ctx: BindingPluginContext, id: string) => MaybePromise<VoidNullable<BindingHookLoadOutput>>
217
- transform?: (ctx: BindingTransformPluginContext, id: string, code: string) => MaybePromise<VoidNullable<BindingHookTransformOutput>>
313
+ loadMeta?: BindingPluginHookMeta
314
+ loadFilter?: BindingGeneralHookFilter
315
+ transform?: (ctx: BindingTransformPluginContext, id: string, code: string, module_type: BindingTransformHookExtraArgs) => MaybePromise<VoidNullable<BindingHookTransformOutput>>
316
+ transformMeta?: BindingPluginHookMeta
317
+ transformFilter?: BindingTransformHookFilter
218
318
  moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>
319
+ moduleParsedMeta?: BindingPluginHookMeta
219
320
  buildEnd?: (ctx: BindingPluginContext, error: Nullable<string>) => MaybePromise<VoidNullable>
321
+ buildEndMeta?: BindingPluginHookMeta
220
322
  renderChunk?: (ctx: BindingPluginContext, code: string, chunk: RenderedChunk) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>
323
+ renderChunkMeta?: BindingPluginHookMeta
221
324
  augmentChunkHash?: (ctx: BindingPluginContext, chunk: RenderedChunk) => MaybePromise<void | string>
325
+ augmentChunkHashMeta?: BindingPluginHookMeta
222
326
  renderStart?: (ctx: BindingPluginContext) => void
327
+ renderStartMeta?: BindingPluginHookMeta
223
328
  renderError?: (ctx: BindingPluginContext, error: string) => void
329
+ renderErrorMeta?: BindingPluginHookMeta
224
330
  generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean) => MaybePromise<VoidNullable>
331
+ generateBundleMeta?: BindingPluginHookMeta
225
332
  writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs) => MaybePromise<VoidNullable>
333
+ writeBundleMeta?: BindingPluginHookMeta
226
334
  banner?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
335
+ bannerMeta?: BindingPluginHookMeta
336
+ footer?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
337
+ footerMeta?: BindingPluginHookMeta
338
+ intro?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
339
+ introMeta?: BindingPluginHookMeta
340
+ outro?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
341
+ outroMeta?: BindingPluginHookMeta
342
+ }
343
+
344
+ export declare enum BindingPluginOrder {
345
+ Pre = 0,
346
+ Post = 1
227
347
  }
228
348
 
229
349
  export interface BindingPluginWithIndex {
@@ -235,6 +355,13 @@ export interface BindingRenderedModule {
235
355
  code?: string
236
356
  }
237
357
 
358
+ export interface BindingReplacePluginConfig {
359
+ values: Record<string, string>
360
+ delimiters?: [string, string]
361
+ preventAssignment?: boolean
362
+ objectGuards?: boolean
363
+ }
364
+
238
365
  export interface BindingResolveOptions {
239
366
  alias?: Array<AliasItem>
240
367
  aliasFields?: Array<Array<string>>
@@ -252,11 +379,42 @@ export interface BindingSourcemap {
252
379
  inner: string | BindingJsonSourcemap
253
380
  }
254
381
 
382
+ /**
383
+ * For String, value is the string content, flag is the `None`
384
+ * For Regex, value is the regular expression, flag is the `Some()`.
385
+ * Make sure put a `Some("")` in flag even there is no flag in regexp.
386
+ */
387
+ export interface BindingStringOrRegex {
388
+ value: string
389
+ /**
390
+ * There is a more compact way to represent this, `Option<u8>` with bitflags, but it will be hard
391
+ * to use(in js side), since construct a `JsRegex` is not used frequently. Optimize it when it is needed.
392
+ */
393
+ flag?: string
394
+ }
395
+
396
+ export interface BindingTransformHookExtraArgs {
397
+ moduleType: string
398
+ }
399
+
400
+ export interface BindingTransformHookFilter {
401
+ code?: BindingGeneralHookFilter
402
+ moduleType?: Array<string>
403
+ id?: BindingGeneralHookFilter
404
+ }
405
+
406
+ export interface BindingTransformPluginConfig {
407
+ include?: Array<BindingStringOrRegex>
408
+ exclude?: Array<BindingStringOrRegex>
409
+ jsxInject?: string
410
+ }
411
+
255
412
  export interface BindingTreeshake {
256
413
  moduleSideEffects: string
257
414
  }
258
415
 
259
416
  export interface Es2015BindingOptions {
417
+ /** Transform arrow functions into function expressions. */
260
418
  arrowFunction?: ArrowFunctionsBindingOptions
261
419
  }
262
420
 
@@ -268,15 +426,97 @@ export interface IsolatedDeclarationsResult {
268
426
  errors: Array<string>
269
427
  }
270
428
 
429
+ export interface PreRenderedChunk {
430
+ name: string
431
+ isEntry: boolean
432
+ isDynamicEntry: boolean
433
+ facadeModuleId?: string
434
+ moduleIds: Array<string>
435
+ exports: Array<string>
436
+ }
437
+
438
+ /**
439
+ * Configure how TSX and JSX are transformed.
440
+ *
441
+ * @see [@babel/plugin-transform-react-jsx](https://babeljs.io/docs/babel-plugin-transform-react-jsx#options)
442
+ */
271
443
  export interface ReactBindingOptions {
444
+ /**
445
+ * Decides which runtime to use.
446
+ *
447
+ * - 'automatic' - auto-import the correct JSX factories
448
+ * - 'classic' - no auto-import
449
+ *
450
+ * @default 'automatic'
451
+ */
272
452
  runtime?: 'classic' | 'automatic'
453
+ /**
454
+ * Emit development-specific information, such as `__source` and `__self`.
455
+ *
456
+ * @default false
457
+ *
458
+ * @see [@babel/plugin-transform-react-jsx-development](https://babeljs.io/docs/babel-plugin-transform-react-jsx-development)
459
+ */
273
460
  development?: boolean
461
+ /**
462
+ * Toggles whether or not to throw an error if an XML namespaced tag name
463
+ * is used.
464
+ *
465
+ * Though the JSX spec allows this, it is disabled by default since React's
466
+ * JSX does not currently have support for it.
467
+ *
468
+ * @default true
469
+ */
274
470
  throwIfNamespace?: boolean
471
+ /**
472
+ * Enables [@babel/plugin-transform-react-pure-annotations](https://babeljs.io/docs/en/babel-plugin-transform-react-pure-annotations).
473
+ *
474
+ * It will mark top-level React method calls as pure for tree shaking.
475
+ *
476
+ * @default true
477
+ */
275
478
  pure?: boolean
479
+ /**
480
+ * Replaces the import source when importing functions.
481
+ *
482
+ * @default 'react'
483
+ */
276
484
  importSource?: string
485
+ /**
486
+ * Replace the function used when compiling JSX expressions. It should be a
487
+ * qualified name (e.g. `React.createElement`) or an identifier (e.g.
488
+ * `createElement`).
489
+ *
490
+ * Only used for `classic` {@link runtime}.
491
+ *
492
+ * @default 'React.createElement'
493
+ */
277
494
  pragma?: string
495
+ /**
496
+ * Replace the component used when compiling JSX fragments. It should be a
497
+ * valid JSX tag name.
498
+ *
499
+ * Only used for `classic` {@link runtime}.
500
+ *
501
+ * @default 'React.Fragment'
502
+ */
278
503
  pragmaFrag?: string
504
+ /**
505
+ * When spreading props, use `Object.assign` directly instead of an extend helper.
506
+ *
507
+ * Only used for `classic` {@link runtime}.
508
+ *
509
+ * @default false
510
+ */
279
511
  useBuiltIns?: boolean
512
+ /**
513
+ * When spreading props, use inline object with spread elements directly
514
+ * instead of an extend helper or Object.assign.
515
+ *
516
+ * Only used for `classic` {@link runtime}.
517
+ *
518
+ * @default false
519
+ */
280
520
  useSpread?: boolean
281
521
  }
282
522
 
@@ -295,7 +535,7 @@ export interface RenderedChunk {
295
535
  dynamicImports: Array<string>
296
536
  }
297
537
 
298
- export interface Sourcemap {
538
+ export interface SourceMap {
299
539
  file?: string
300
540
  mappings?: string
301
541
  sourceRoot?: string
@@ -304,28 +544,93 @@ export interface Sourcemap {
304
544
  names?: Array<string>
305
545
  }
306
546
 
547
+ /**
548
+ * Transpile a JavaScript or TypeScript into a target ECMAScript version.
549
+ *
550
+ * @param filename The name of the file being transformed. If this is a
551
+ * relative path, consider setting the {@link TransformOptions#cwd} option..
552
+ * @param sourceText the source code itself
553
+ * @param options The options for the transformation. See {@link
554
+ * TransformOptions} for more information.
555
+ *
556
+ * @returns an object containing the transformed code, source maps, and any
557
+ * errors that occurred during parsing or transformation.
558
+ */
307
559
  export declare function transform(filename: string, sourceText: string, options?: TransformOptions | undefined | null): TransformResult
308
560
 
561
+ /**
562
+ * Options for transforming a JavaScript or TypeScript file.
563
+ *
564
+ * @see {@link transform}
565
+ */
309
566
  export interface TransformOptions {
310
567
  sourceType?: 'script' | 'module' | 'unambiguous' | undefined
311
- /** Force jsx parsing, */
568
+ /**
569
+ * The current working directory. Used to resolve relative paths in other
570
+ * options.
571
+ */
572
+ cwd?: string
573
+ /**
574
+ * Force jsx parsing,
575
+ *
576
+ * @default false
577
+ */
312
578
  jsx?: boolean
579
+ /** Configure how TypeScript is transformed. */
313
580
  typescript?: TypeScriptBindingOptions
581
+ /** Configure how TSX and JSX are transformed. */
314
582
  react?: ReactBindingOptions
583
+ /** Enable ES2015 transformations. */
315
584
  es2015?: Es2015BindingOptions
316
585
  /**
317
- * Enable Sourcemap
586
+ * Enable source map generation.
587
+ *
588
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
318
589
  *
319
- * * `true` to generate a sourcemap for the code and include it in the result object.
590
+ * @default false
320
591
  *
321
- * Default: false
592
+ * @see {@link SourceMap}
322
593
  */
323
594
  sourcemap?: boolean
324
595
  }
325
596
 
326
597
  export interface TransformResult {
598
+ /**
599
+ * The transformed code.
600
+ *
601
+ * If parsing failed, this will be an empty string.
602
+ */
327
603
  sourceText: string
328
- map?: Sourcemap
604
+ /**
605
+ * The source map for the transformed code.
606
+ *
607
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
608
+ */
609
+ sourceMap?: SourceMap
610
+ /**
611
+ * The `.d.ts` declaration file for the transformed code. Declarations are
612
+ * only generated if `declaration` is set to `true` and a TypeScript file
613
+ * is provided.
614
+ *
615
+ * If parsing failed and `declaration` is set, this will be an empty string.
616
+ *
617
+ * @see {@link TypeScriptBindingOptions#declaration}
618
+ * @see [declaration tsconfig option](https://www.typescriptlang.org/tsconfig/#declaration)
619
+ */
620
+ declaration?: string
621
+ /**
622
+ * Declaration source map. Only generated if both
623
+ * {@link TypeScriptBindingOptions#declaration declaration} and
624
+ * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
625
+ */
626
+ declarationMap?: SourceMap
627
+ /**
628
+ * Parse and transformation errors.
629
+ *
630
+ * Oxc's parser recovers from common syntax errors, meaning that
631
+ * transformed code may still be available even if there are errors in this
632
+ * list.
633
+ */
329
634
  errors: Array<string>
330
635
  }
331
636
 
@@ -335,5 +640,15 @@ export interface TypeScriptBindingOptions {
335
640
  onlyRemoveTypeImports?: boolean
336
641
  allowNamespaces?: boolean
337
642
  allowDeclareFields?: boolean
643
+ /**
644
+ * Also generate a `.d.ts` declaration file for TypeScript files.
645
+ *
646
+ * The source file must be compliant with all
647
+ * [`isolatedDeclarations`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
648
+ * requirements.
649
+ *
650
+ * @default false
651
+ */
652
+ declaration?: boolean
338
653
  }
339
654
 
@@ -0,0 +1,8 @@
1
+ import { CliOptions } from './schema';
2
+ export interface OptionConfig {
3
+ abbreviation?: string;
4
+ description?: string;
5
+ default?: string | boolean;
6
+ hint?: string;
7
+ }
8
+ export declare const alias: Partial<Record<keyof CliOptions, OptionConfig>>;
@@ -0,0 +1,13 @@
1
+ export declare const flattenedSchema: Record<string, import("./types").Schema>;
2
+ export declare const options: {
3
+ [k: string]: {
4
+ type: "boolean" | "string";
5
+ multiple: boolean;
6
+ short?: string;
7
+ default?: boolean | string | string[];
8
+ hint?: string;
9
+ description?: string;
10
+ };
11
+ };
12
+ export type ParseArgsOptions = typeof options;
13
+ export declare function parseCliArguments(): import("./normalize").NormalizedCliOptions;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @description This file is used for normalize the options.
3
+ * In CLI, the input options and output options are mixed together. We need to tell them apart.
4
+ */
5
+ import { InputOptions } from '../../options/input-options';
6
+ import { OutputOptions } from '../../options/output-options';
7
+ import { CliOptions } from './schema';
8
+ export interface NormalizedCliOptions {
9
+ input: InputOptions;
10
+ output: OutputOptions;
11
+ help: boolean;
12
+ config: string;
13
+ version: boolean;
14
+ }
15
+ export declare function normalizeCliOptions(cliOptions: CliOptions, positionals: string[]): NormalizedCliOptions;