rolldown 0.14.0 → 0.15.0-commit.ac58858

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 (101) hide show
  1. package/dist/cjs/cli.cjs +902 -960
  2. package/dist/cjs/experimental-index.cjs +68 -26
  3. package/dist/cjs/index.cjs +6 -8
  4. package/dist/cjs/parallel-plugin-worker.cjs +20 -14
  5. package/dist/cjs/parallel-plugin.cjs +1 -3
  6. package/dist/esm/cli.mjs +855 -915
  7. package/dist/esm/experimental-index.mjs +44 -7
  8. package/dist/esm/index.mjs +2 -4
  9. package/dist/esm/parallel-plugin-worker.mjs +15 -10
  10. package/dist/esm/parallel-plugin.mjs +1 -3
  11. package/dist/shared/{chunk-JoMxl5V2.cjs → chunk-BFvIen8E.cjs} +13 -11
  12. package/dist/shared/{consola.36c0034f-HcmWcfPe.cjs → consola_36c0034f-B7L-radJ.cjs} +249 -295
  13. package/dist/shared/{consola.36c0034f-Xyw7SC_7.mjs → consola_36c0034f-D9ce-831.mjs} +221 -286
  14. package/dist/shared/{prompt-9Ij3R3TG.cjs → prompt-BiXtYIJ2.cjs} +157 -204
  15. package/dist/shared/{prompt-hoPhcrA-.mjs → prompt-DlQ-08lk.mjs} +125 -174
  16. package/dist/shared/src-Bs7g4_us.cjs +2985 -0
  17. package/dist/shared/src-C-NQjnqV.mjs +2851 -0
  18. package/dist/tsconfig.dts.tsbuildinfo +1 -0
  19. package/dist/types/api/build.d.ts +16 -0
  20. package/dist/types/api/experimental.d.ts +7 -0
  21. package/dist/types/api/rolldown/index.d.ts +3 -0
  22. package/dist/types/api/rolldown/rolldown-build.d.ts +12 -0
  23. package/dist/types/api/watch/index.d.ts +3 -0
  24. package/dist/types/{watcher.d.ts → api/watch/watch-emitter.d.ts} +17 -17
  25. package/dist/types/api/watch/watcher.d.ts +13 -0
  26. package/dist/types/binding.d.ts +273 -49
  27. package/dist/types/builtin-plugin/alias-plugin.d.ts +10 -0
  28. package/dist/types/builtin-plugin/constructors.d.ts +16 -0
  29. package/dist/types/builtin-plugin/replace-plugin.d.ts +28 -0
  30. package/dist/types/{options/normalized-ecma-transform-plugin-config.d.ts → builtin-plugin/transform-plugin.d.ts} +2 -1
  31. package/dist/types/builtin-plugin/utils.d.ts +8 -0
  32. package/dist/types/cli/arguments/index.d.ts +5 -3
  33. package/dist/types/cli/arguments/normalize.d.ts +2 -6
  34. package/dist/types/cli/arguments/schema.d.ts +10 -309
  35. package/dist/types/cli/colors.d.ts +11 -1
  36. package/dist/types/cli/utils.d.ts +2 -1
  37. package/dist/types/constants/plugin.d.ts +10 -1
  38. package/dist/types/experimental-index.d.ts +5 -2
  39. package/dist/types/index.d.ts +13 -10
  40. package/dist/types/log/logger.d.ts +2 -16
  41. package/dist/types/log/logging.d.ts +11 -8
  42. package/dist/types/log/logs.d.ts +3 -0
  43. package/dist/types/options/input-options-schema.d.ts +4 -0
  44. package/dist/types/options/input-options.d.ts +89 -430
  45. package/dist/types/options/normalized-input-options.d.ts +17 -11
  46. package/dist/types/options/normalized-output-options.d.ts +60 -21
  47. package/dist/types/options/output-options-schema.d.ts +3 -0
  48. package/dist/types/options/output-options.d.ts +73 -265
  49. package/dist/types/options/watch-options.d.ts +5 -0
  50. package/dist/types/plugin/bindingify-build-hooks.d.ts +9 -11
  51. package/dist/types/plugin/bindingify-hook-filter.d.ts +5 -5
  52. package/dist/types/plugin/bindingify-output-hooks.d.ts +13 -16
  53. package/dist/types/plugin/bindingify-plugin.d.ts +12 -3
  54. package/dist/types/plugin/bindingify-watch-hooks.d.ts +3 -5
  55. package/dist/types/plugin/hook-filter.d.ts +1 -1
  56. package/dist/types/plugin/index.d.ts +21 -18
  57. package/dist/types/plugin/minimal-plugin-context.d.ts +15 -0
  58. package/dist/types/plugin/plugin-context-data.d.ts +4 -4
  59. package/dist/types/plugin/plugin-context.d.ts +9 -4
  60. package/dist/types/plugin/plugin-driver.d.ts +4 -5
  61. package/dist/types/plugin/transform-plugin-context.d.ts +4 -3
  62. package/dist/types/rollup-types.d.ts +1 -1
  63. package/dist/types/rollup.d.ts +4 -0
  64. package/dist/types/treeshake/index.d.ts +0 -12
  65. package/dist/types/treeshake/module-side-effects.d.ts +14 -15
  66. package/dist/types/types/rolldown-output.d.ts +17 -2
  67. package/dist/types/types/utils.d.ts +1 -0
  68. package/dist/types/utils/bindingify-input-options.d.ts +7 -0
  69. package/dist/types/utils/bindingify-output-options.d.ts +3 -0
  70. package/dist/types/utils/create-bundler-option.d.ts +11 -0
  71. package/dist/types/utils/define-config.d.ts +3 -0
  72. package/dist/types/utils/error.d.ts +2 -0
  73. package/dist/types/utils/misc.d.ts +1 -0
  74. package/dist/types/utils/normalize-hook.d.ts +1 -1
  75. package/dist/types/utils/normalize-plugin-option.d.ts +8 -3
  76. package/dist/types/{options/utils.d.ts → utils/normalize-string-or-regex.d.ts} +1 -1
  77. package/dist/types/utils/transform-rendered-chunk.d.ts +4 -0
  78. package/dist/types/utils/transform-rendered-module.d.ts +3 -0
  79. package/dist/types/utils/transform-sourcemap.d.ts +2 -0
  80. package/dist/types/utils/transform-to-rollup-output.d.ts +1 -0
  81. package/dist/types/utils/zod-ext.d.ts +6 -5
  82. package/package.json +31 -23
  83. package/dist/shared/rolldown-binding.wasi.cjs +0 -187
  84. package/dist/shared/src_index-3pqhEViJ.cjs +0 -2785
  85. package/dist/shared/src_index-ywYMd4vB.mjs +0 -2786
  86. package/dist/shared/wasi-worker-browser.mjs +0 -39
  87. package/dist/shared/wasi-worker.mjs +0 -63
  88. package/dist/shared/watcher-worker.js +0 -1
  89. package/dist/types/constants/types.d.ts +0 -1
  90. package/dist/types/options/bindingify-input-options.d.ts +0 -4
  91. package/dist/types/options/bindingify-output-options.d.ts +0 -3
  92. package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -8
  93. package/dist/types/options/watch-option.d.ts +0 -5
  94. package/dist/types/plugin/builtin-plugin.d.ts +0 -81
  95. package/dist/types/rolldown-build.d.ts +0 -10
  96. package/dist/types/rolldown.d.ts +0 -12
  97. package/dist/types/types/rendered-module.d.ts +0 -2
  98. package/dist/types/utils/normalize-input-options.d.ts +0 -3
  99. package/dist/types/utils/normalize-output-options.d.ts +0 -3
  100. package/dist/types/utils/normalize-tree-shake.d.ts +0 -3
  101. /package/dist/types/{utils/type-assert.d.ts → types/assert.d.ts} +0 -0
@@ -3,6 +3,23 @@ type Nullable<T> = T | null | undefined
3
3
  type VoidNullable<T = void> = T | null | undefined | void
4
4
  export type BindingStringOrRegex = string | RegExp
5
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
+
6
23
  export declare class BindingLog {
7
24
  code: string
8
25
  message: string
@@ -18,11 +35,45 @@ export declare class BindingModuleInfo {
18
35
  get code(): string | null
19
36
  }
20
37
 
38
+ export declare class BindingNormalizedOptions {
39
+ get input(): Array<string> | Record<string, string>
40
+ get cwd(): string | null
41
+ get platform(): 'node' | 'browser' | 'neutral'
42
+ get shimMissingExports(): boolean
43
+ get name(): string | null
44
+ get cssEntryFilenames(): string | undefined
45
+ get cssChunkFilenames(): string | undefined
46
+ get entryFilenames(): string | undefined
47
+ get chunkFilenames(): string | undefined
48
+ get assetFilenames(): string
49
+ get dir(): string | null
50
+ get file(): string | null
51
+ get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd'
52
+ get exports(): 'default' | 'named' | 'none' | 'auto'
53
+ get esModule(): boolean | 'if-default-prop'
54
+ get inlineDynamicImports(): boolean
55
+ get sourcemap(): boolean | 'inline' | 'hidden'
56
+ get banner(): string | undefined | null | undefined
57
+ get footer(): string | undefined | null | undefined
58
+ get intro(): string | undefined | null | undefined
59
+ get outro(): string | undefined | null | undefined
60
+ get externalLiveBindings(): boolean
61
+ get extend(): boolean
62
+ get globals(): Record<string, string> | undefined
63
+ get hashCharacters(): 'base64' | 'base36' | 'hex'
64
+ get sourcemapDebugIds(): boolean
65
+ get minify(): boolean
66
+ get polyfillRequire(): boolean
67
+ get comments(): 'none' | 'preserve-legal'
68
+ }
69
+
21
70
  export declare class BindingOutputAsset {
22
71
  get fileName(): string
23
72
  get originalFileName(): string | null
73
+ get originalFileNames(): Array<string>
24
74
  get source(): BindingAssetSource
25
75
  get name(): string | null
76
+ get names(): Array<string>
26
77
  }
27
78
 
28
79
  export declare class BindingOutputChunk {
@@ -45,33 +96,54 @@ export declare class BindingOutputChunk {
45
96
  export declare class BindingOutputs {
46
97
  get chunks(): Array<BindingOutputChunk>
47
98
  get assets(): Array<BindingOutputAsset>
99
+ get errors(): Array<Error | BindingError>
48
100
  }
49
101
 
50
102
  export declare class BindingPluginContext {
103
+ load(specifier: string, sideEffects: BindingHookSideEffects | undefined, fn: () => void): Promise<void>
51
104
  resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>
52
105
  emitFile(file: BindingEmittedAsset): string
53
106
  getFileName(referenceId: string): string
54
107
  getModuleInfo(moduleId: string): BindingModuleInfo | null
55
- getModuleIds(): Array<string> | null
108
+ getModuleIds(): Array<string>
56
109
  addWatchFile(file: string): void
57
110
  }
58
111
 
112
+ export declare class BindingRenderedModule {
113
+ get code(): string | null
114
+ }
115
+
59
116
  export declare class BindingTransformPluginContext {
117
+ getCombinedSourcemap(): string
60
118
  inner(): BindingPluginContext
61
119
  }
62
120
 
63
121
  export declare class BindingWatcher {
122
+ constructor(options: Array<BindingBundlerOptions>, notifyOption?: BindingNotifyOption | undefined | null)
64
123
  close(): Promise<void>
65
- on(event: BindingWatcherEvent, listener: (data?: Record<string, string>) => void): void
124
+ start(listener: (data: BindingWatcherEvent) => void): Promise<void>
125
+ }
126
+
127
+ export declare class BindingWatcherChangeData {
128
+ path: string
129
+ kind: string
130
+ }
131
+
132
+ export declare class BindingWatcherEvent {
133
+ eventKind(): string
134
+ watchChangeData(): BindingWatcherChangeData
135
+ bundleEndData(): BindingBundleEndEventData
136
+ bundleEventKind(): string
137
+ errors(): Array<Error | BindingError>
66
138
  }
67
139
 
68
140
  export declare class Bundler {
69
- constructor(inputOptions: BindingInputOptions, outputOptions: BindingOutputOptions, parallelPluginsRegistry?: ParallelJsPluginRegistry | undefined | null)
141
+ constructor(option: BindingBundlerOptions)
70
142
  write(): Promise<BindingOutputs>
71
143
  generate(): Promise<BindingOutputs>
72
- scan(): Promise<void>
144
+ scan(): Promise<BindingOutputs>
73
145
  close(): Promise<void>
74
- watch(): Promise<BindingWatcher>
146
+ get closed(): boolean
75
147
  }
76
148
 
77
149
  export declare class ParallelJsPluginRegistry {
@@ -129,19 +201,28 @@ export interface BindingBuiltinPlugin {
129
201
  options?: unknown
130
202
  }
131
203
 
132
- export declare enum BindingBuiltinPluginName {
133
- WasmHelperPlugin = 0,
134
- ImportGlobPlugin = 1,
135
- DynamicImportVarsPlugin = 2,
136
- ModulePreloadPolyfillPlugin = 3,
137
- ManifestPlugin = 4,
138
- LoadFallbackPlugin = 5,
139
- TransformPlugin = 6,
140
- WasmFallbackPlugin = 7,
141
- AliasPlugin = 8,
142
- JsonPlugin = 9,
143
- BuildImportAnalysisPlugin = 10,
144
- ReplacePlugin = 11
204
+ export type BindingBuiltinPluginName = 'builtin:wasm-helper'|
205
+ 'builtin:import-glob'|
206
+ 'builtin:dynamic-import-vars'|
207
+ 'builtin:module-preload-polyfill'|
208
+ 'builtin:manifest'|
209
+ 'builtin:load-fallback'|
210
+ 'builtin:transform'|
211
+ 'builtin:wasm-fallback'|
212
+ 'builtin:alias'|
213
+ 'builtin:json'|
214
+ 'builtin:build-import-analysis'|
215
+ 'builtin:replace'|
216
+ 'builtin:vite-resolve';
217
+
218
+ export interface BindingBundlerOptions {
219
+ inputOptions: BindingInputOptions
220
+ outputOptions: BindingOutputOptions
221
+ parallelPluginsRegistry?: ParallelJsPluginRegistry
222
+ }
223
+
224
+ export interface BindingChecksOptions {
225
+ circularDependency?: boolean
145
226
  }
146
227
 
147
228
  export interface BindingEmittedAsset {
@@ -154,6 +235,8 @@ export interface BindingEmittedAsset {
154
235
  export interface BindingExperimentalOptions {
155
236
  strictExecutionOrder?: boolean
156
237
  disableLiveBindings?: boolean
238
+ viteMode?: boolean
239
+ resolveNewUrlToAsset?: boolean
157
240
  }
158
241
 
159
242
  export interface BindingGeneralHookFilter {
@@ -166,6 +249,22 @@ export interface BindingGlobImportPluginConfig {
166
249
  restoreQueryExtension?: boolean
167
250
  }
168
251
 
252
+ export interface BindingHookJsLoadOutput {
253
+ code: string
254
+ map?: string
255
+ sideEffects: boolean | 'no-treeshake'
256
+ }
257
+
258
+ export interface BindingHookJsResolveIdOptions {
259
+ scan?: boolean
260
+ }
261
+
262
+ export interface BindingHookJsResolveIdOutput {
263
+ id: string
264
+ external?: boolean
265
+ sideEffects: boolean | 'no-treeshake'
266
+ }
267
+
169
268
  export interface BindingHookLoadOutput {
170
269
  code: string
171
270
  sideEffects?: BindingHookSideEffects
@@ -228,24 +327,31 @@ export interface BindingInputOptions {
228
327
  resolve?: BindingResolveOptions
229
328
  shimMissingExports?: boolean
230
329
  platform?: 'node' | 'browser' | 'neutral'
231
- logLevel?: BindingLogLevel
330
+ logLevel: BindingLogLevel
232
331
  onLog: (logLevel: 'debug' | 'warn' | 'info', log: BindingLog) => void
233
332
  cwd: string
234
333
  treeshake?: BindingTreeshake
235
334
  moduleTypes?: Record<string, string>
236
335
  define?: Array<[string, string]>
336
+ dropLabels?: Array<string>
237
337
  inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>
238
338
  experimental?: BindingExperimentalOptions
239
339
  profilerNames?: boolean
240
340
  jsx?: JsxOptions
241
341
  watch?: BindingWatchOption
342
+ keepNames?: boolean
343
+ checks?: BindingChecksOptions
242
344
  }
243
345
 
244
346
  export interface BindingJsonPluginConfig {
245
- stringify?: boolean
347
+ stringify?: BindingJsonPluginStringify
246
348
  isBuild?: boolean
349
+ namedExports?: boolean
247
350
  }
248
351
 
352
+ export type BindingJsonPluginStringify =
353
+ boolean | string
354
+
249
355
  export interface BindingJsonSourcemap {
250
356
  file?: string
251
357
  mappings?: string
@@ -255,6 +361,10 @@ export interface BindingJsonSourcemap {
255
361
  names?: Array<string>
256
362
  }
257
363
 
364
+ export interface BindingJsWatchChangeEvent {
365
+ event: string
366
+ }
367
+
258
368
  export declare enum BindingLogLevel {
259
369
  Silent = 0,
260
370
  Warn = 1,
@@ -279,6 +389,12 @@ export interface BindingModulePreloadPolyfillPluginConfig {
279
389
  skip?: boolean
280
390
  }
281
391
 
392
+ export interface BindingModuleSideEffectsRule {
393
+ test?: RegExp | undefined
394
+ sideEffects: boolean
395
+ external?: boolean | undefined
396
+ }
397
+
282
398
  export interface BindingNotifyOption {
283
399
  pollInterval?: number
284
400
  compareContents?: boolean
@@ -286,9 +402,11 @@ export interface BindingNotifyOption {
286
402
 
287
403
  export interface BindingOutputOptions {
288
404
  name?: string
405
+ assetFileNames?: string
289
406
  entryFileNames?: string | ((chunk: PreRenderedChunk) => string)
290
407
  chunkFileNames?: string | ((chunk: PreRenderedChunk) => string)
291
- assetFileNames?: string
408
+ cssEntryFileNames?: string | ((chunk: PreRenderedChunk) => string)
409
+ cssChunkFileNames?: string | ((chunk: PreRenderedChunk) => string)
292
410
  banner?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
293
411
  dir?: string
294
412
  file?: string
@@ -297,8 +415,9 @@ export interface BindingOutputOptions {
297
415
  extend?: boolean
298
416
  externalLiveBindings?: boolean
299
417
  footer?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
300
- format?: 'es' | 'cjs' | 'iife' | 'umd'
301
- globals?: Record<string, string>
418
+ format?: 'es' | 'cjs' | 'iife' | 'umd' | 'app'
419
+ globals?: Record<string, string> | ((name: string) => string)
420
+ hashCharacters?: 'base64' | 'base36' | 'hex'
302
421
  inlineDynamicImports?: boolean
303
422
  intro?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
304
423
  outro?: (chunk: RenderedChunk) => MaybePromise<VoidNullable<string>>
@@ -309,6 +428,8 @@ export interface BindingOutputOptions {
309
428
  sourcemapPathTransform?: (source: string, sourcemapPath: string) => string
310
429
  minify?: boolean
311
430
  advancedChunks?: BindingAdvancedChunksOptions
431
+ comments?: 'none' | 'preserve-legal'
432
+ polyfillRequire?: boolean
312
433
  }
313
434
 
314
435
  export interface BindingPluginContextResolvedId {
@@ -328,7 +449,7 @@ export interface BindingPluginHookMeta {
328
449
 
329
450
  export interface BindingPluginOptions {
330
451
  name: string
331
- buildStart?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
452
+ buildStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable>
332
453
  buildStartMeta?: BindingPluginHookMeta
333
454
  resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
334
455
  resolveIdMeta?: BindingPluginHookMeta
@@ -343,19 +464,19 @@ export interface BindingPluginOptions {
343
464
  transformFilter?: BindingTransformHookFilter
344
465
  moduleParsed?: (ctx: BindingPluginContext, module: BindingModuleInfo) => MaybePromise<VoidNullable>
345
466
  moduleParsedMeta?: BindingPluginHookMeta
346
- buildEnd?: (ctx: BindingPluginContext, error: Nullable<string>) => MaybePromise<VoidNullable>
467
+ buildEnd?: (ctx: BindingPluginContext, error?: (Error | BindingError)[]) => MaybePromise<VoidNullable>
347
468
  buildEndMeta?: BindingPluginHookMeta
348
- renderChunk?: (ctx: BindingPluginContext, code: string, chunk: RenderedChunk) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>
469
+ renderChunk?: (ctx: BindingPluginContext, code: string, chunk: RenderedChunk, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<BindingHookRenderChunkOutput>>
349
470
  renderChunkMeta?: BindingPluginHookMeta
350
471
  augmentChunkHash?: (ctx: BindingPluginContext, chunk: RenderedChunk) => MaybePromise<void | string>
351
472
  augmentChunkHashMeta?: BindingPluginHookMeta
352
- renderStart?: (ctx: BindingPluginContext) => void
473
+ renderStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => void
353
474
  renderStartMeta?: BindingPluginHookMeta
354
- renderError?: (ctx: BindingPluginContext, error: string) => void
475
+ renderError?: (ctx: BindingPluginContext, error: (Error | BindingError)[]) => void
355
476
  renderErrorMeta?: BindingPluginHookMeta
356
- generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean) => MaybePromise<VoidNullable<JsChangedOutputs>>
477
+ generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>
357
478
  generateBundleMeta?: BindingPluginHookMeta
358
- writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs) => MaybePromise<VoidNullable<JsChangedOutputs>>
479
+ writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>
359
480
  writeBundleMeta?: BindingPluginHookMeta
360
481
  closeBundle?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
361
482
  closeBundleMeta?: BindingPluginHookMeta
@@ -383,15 +504,12 @@ export interface BindingPluginWithIndex {
383
504
  plugin: BindingPluginOptions
384
505
  }
385
506
 
386
- export interface BindingRenderedModule {
387
- code?: string
388
- }
389
-
390
507
  export interface BindingReplacePluginConfig {
391
508
  values: Record<string, string>
392
509
  delimiters?: [string, string]
393
510
  preventAssignment?: boolean
394
511
  objectGuards?: boolean
512
+ sourcemap?: boolean
395
513
  }
396
514
 
397
515
  export interface BindingResolveOptions {
@@ -426,27 +544,65 @@ export interface BindingTransformPluginConfig {
426
544
  include?: Array<BindingStringOrRegex>
427
545
  exclude?: Array<BindingStringOrRegex>
428
546
  jsxInject?: string
429
- targets?: string
547
+ reactRefresh?: boolean
548
+ target?: string
549
+ browserslist?: string
430
550
  }
431
551
 
432
552
  export interface BindingTreeshake {
433
- moduleSideEffects: string
434
- }
435
-
436
- export declare enum BindingWatcherEvent {
437
- Close = 0,
438
- Event = 1,
439
- ReStart = 2,
440
- Change = 3
553
+ moduleSideEffects: boolean | BindingModuleSideEffectsRule[] | ((id: string, is_external: boolean) => boolean | undefined)
554
+ annotations?: boolean
555
+ }
556
+
557
+ export interface BindingViteResolvePluginConfig {
558
+ resolveOptions: BindingViteResolvePluginResolveOptions
559
+ environmentConsumer: string
560
+ environmentName: string
561
+ external: true | string[]
562
+ noExternal: true | Array<string | RegExp>
563
+ dedupe: Array<string>
564
+ finalizeBareSpecifier?: (resolvedId: string, rawId: string, importer: string | null | undefined) => VoidNullable<string>
565
+ finalizeOtherSpecifiers?: (resolvedId: string, rawId: string) => VoidNullable<string>
566
+ runtime: string
567
+ }
568
+
569
+ export interface BindingViteResolvePluginResolveOptions {
570
+ isBuild: boolean
571
+ isProduction: boolean
572
+ asSrc: boolean
573
+ preferRelative: boolean
574
+ isRequire?: boolean
575
+ root: string
576
+ scan: boolean
577
+ mainFields: Array<string>
578
+ conditions: Array<string>
579
+ externalConditions: Array<string>
580
+ extensions: Array<string>
581
+ tryIndex: boolean
582
+ tryPrefix?: string
583
+ preserveSymlinks: boolean
441
584
  }
442
585
 
443
586
  export interface BindingWatchOption {
444
587
  skipWrite?: boolean
445
- notify?: BindingNotifyOption
446
588
  include?: Array<BindingStringOrRegex>
447
589
  exclude?: Array<BindingStringOrRegex>
448
590
  }
449
591
 
592
+ export interface CompilerAssumptions {
593
+ ignoreFunctionLength?: boolean
594
+ noDocumentAll?: boolean
595
+ objectRestNoSymbols?: boolean
596
+ pureGetters?: boolean
597
+ setPublicClassFields?: boolean
598
+ }
599
+
600
+ export interface ErrorLabel {
601
+ message?: string
602
+ start: number
603
+ end: number
604
+ }
605
+
450
606
  export interface Es2015Options {
451
607
  /** Transform arrow functions into function expressions. */
452
608
  arrowFunction?: ArrowFunctionsOptions
@@ -457,6 +613,32 @@ export interface ExtensionAliasItem {
457
613
  replacements: Array<string>
458
614
  }
459
615
 
616
+ export type HelperMode = /**
617
+ * Runtime mode (default): Helper functions are imported from a runtime package.
618
+ *
619
+ * Example:
620
+ *
621
+ * ```js
622
+ * import helperName from "@babel/runtime/helpers/helperName";
623
+ * helperName(...arguments);
624
+ * ```
625
+ */
626
+ 'Runtime'|
627
+ /**
628
+ * External mode: Helper functions are accessed from a global `babelHelpers` object.
629
+ *
630
+ * Example:
631
+ *
632
+ * ```js
633
+ * babelHelpers.helperName(...arguments);
634
+ * ```
635
+ */
636
+ 'External';
637
+
638
+ export interface Helpers {
639
+ mode?: HelperMode
640
+ }
641
+
460
642
  /** TypeScript Isolated Declarations for Standalone DTS Emit */
461
643
  export declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult
462
644
 
@@ -476,7 +658,7 @@ export interface IsolatedDeclarationsOptions {
476
658
  export interface IsolatedDeclarationsResult {
477
659
  code: string
478
660
  map?: SourceMap
479
- errors: Array<string>
661
+ errors: Array<OxcError>
480
662
  }
481
663
 
482
664
  export interface JsChangedOutputs {
@@ -486,8 +668,8 @@ export interface JsChangedOutputs {
486
668
  }
487
669
 
488
670
  export interface JsOutputAsset {
489
- name?: string
490
- originalFileName?: string
671
+ names: Array<string>
672
+ originalFileNames: Array<string>
491
673
  filename: string
492
674
  source: BindingAssetSource
493
675
  }
@@ -597,13 +779,20 @@ export interface JsxOptions {
597
779
  /**
598
780
  * Enable React Fast Refresh .
599
781
  *
600
- * Conforms to the implementation in {@link https://github.com/facebook/react/tree/main/packages/react-refresh}
782
+ * Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
601
783
  *
602
784
  * @default false
603
785
  */
604
786
  refresh?: boolean | ReactRefreshOptions
605
787
  }
606
788
 
789
+ export interface OxcError {
790
+ severity: Severity
791
+ message: string
792
+ labels: Array<ErrorLabel>
793
+ helpMessage?: string
794
+ }
795
+
607
796
  export interface PreRenderedChunk {
608
797
  name: string
609
798
  isEntry: boolean
@@ -644,6 +833,10 @@ export interface RenderedChunk {
644
833
  dynamicImports: Array<string>
645
834
  }
646
835
 
836
+ export type Severity = 'Error'|
837
+ 'Warning'|
838
+ 'Advice';
839
+
647
840
  export interface SourceMap {
648
841
  file?: string
649
842
  mappings: string
@@ -693,10 +886,29 @@ export interface TransformOptions {
693
886
  * @see {@link SourceMap}
694
887
  */
695
888
  sourcemap?: boolean
889
+ /** Set assumptions in order to produce smaller output. */
890
+ assumptions?: CompilerAssumptions
696
891
  /** Configure how TypeScript is transformed. */
697
892
  typescript?: TypeScriptOptions
698
893
  /** Configure how TSX and JSX are transformed. */
699
894
  jsx?: JsxOptions
895
+ /**
896
+ * Sets the target environment for the generated JavaScript.
897
+ *
898
+ * The lowest target is `es2015`.
899
+ *
900
+ * Example:
901
+ *
902
+ * * 'es2015'
903
+ * * ['es2020', 'chrome58', 'edge16', 'firefox57', 'node12', 'safari11']
904
+ *
905
+ * @default `esnext` (No transformation)
906
+ *
907
+ * @see [esbuild#target](https://esbuild.github.io/api/#target)
908
+ */
909
+ target?: string | Array<string>
910
+ /** Behaviour for runtime helpers. */
911
+ helpers?: Helpers
700
912
  /** Define Plugin */
701
913
  define?: Record<string, string>
702
914
  /** Inject Plugin */
@@ -733,6 +945,18 @@ export interface TransformResult {
733
945
  * {@link TransformOptions#sourcemap sourcemap} are set to `true`.
734
946
  */
735
947
  declarationMap?: SourceMap
948
+ /**
949
+ * Helpers used.
950
+ *
951
+ * @internal
952
+ *
953
+ * Example:
954
+ *
955
+ * ```text
956
+ * { "_objectSpread": "@babel/runtime/helpers/objectSpread2" }
957
+ * ```
958
+ */
959
+ helpersUsed: Record<string, string>
736
960
  /**
737
961
  * Parse and transformation errors.
738
962
  *
@@ -740,7 +964,7 @@ export interface TransformResult {
740
964
  * transformed code may still be available even if there are errors in this
741
965
  * list.
742
966
  */
743
- errors: Array<string>
967
+ errors: Array<OxcError>
744
968
  }
745
969
 
746
970
  export interface TypeScriptOptions {
@@ -0,0 +1,10 @@
1
+ import { BuiltinPlugin } from './constructors';
2
+ type AliasPluginAlias = {
3
+ find: string | RegExp;
4
+ replacement: string;
5
+ };
6
+ type AliasPluginConfig = {
7
+ entries: AliasPluginAlias[];
8
+ };
9
+ export declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
10
+ export {};
@@ -0,0 +1,16 @@
1
+ import { type BindingBuiltinPluginName, BindingGlobImportPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingJsonPluginConfig, BindingBuildImportAnalysisPluginConfig, type BindingViteResolvePluginConfig } from '../binding';
2
+ export declare class BuiltinPlugin {
3
+ name: BindingBuiltinPluginName;
4
+ _options?: unknown;
5
+ constructor(name: BindingBuiltinPluginName, _options?: unknown);
6
+ }
7
+ export declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
8
+ export declare function dynamicImportVarsPlugin(): BuiltinPlugin;
9
+ export declare function importGlobPlugin(config?: BindingGlobImportPluginConfig): BuiltinPlugin;
10
+ export declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
11
+ export declare function wasmHelperPlugin(): BuiltinPlugin;
12
+ export declare function wasmFallbackPlugin(): BuiltinPlugin;
13
+ export declare function loadFallbackPlugin(): BuiltinPlugin;
14
+ export declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
15
+ export declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
16
+ export declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, 'runtime'>): BuiltinPlugin;
@@ -0,0 +1,28 @@
1
+ import { BindingReplacePluginConfig } from '../binding';
2
+ import { BuiltinPlugin } from './constructors';
3
+ /**
4
+ * Replaces targeted strings in files while bundling.
5
+ *
6
+ * @example
7
+ * // Basic usage
8
+ * ```js
9
+ * replacePlugin({
10
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
11
+ * __buildDate__: () => JSON.stringify(new Date()),
12
+ * __buildVersion: 15
13
+ * })
14
+ * ```
15
+ * @example
16
+ * // With options
17
+ * ```js
18
+ * replacePlugin({
19
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
20
+ * __buildDate__: () => JSON.stringify(new Date()),
21
+ * __buildVersion: 15
22
+ * }, {
23
+ * preventAssignment: false,
24
+ * })
25
+ * ```
26
+ *
27
+ */
28
+ export declare function replacePlugin(values?: BindingReplacePluginConfig['values'], options?: Omit<BindingReplacePluginConfig, 'values'>): BuiltinPlugin;
@@ -1,8 +1,9 @@
1
+ import { BuiltinPlugin } from './constructors';
1
2
  import { BindingTransformPluginConfig } from '../binding';
2
3
  type TransformPattern = string | RegExp | (RegExp | string)[];
3
4
  export type TransformPluginConfig = Omit<BindingTransformPluginConfig, 'include' | 'exclude'> & {
4
5
  include?: TransformPattern;
5
6
  exclude?: TransformPattern;
6
7
  };
7
- export declare function normalizeEcmaTransformPluginConfig(config?: TransformPluginConfig): BindingTransformPluginConfig | undefined;
8
+ export declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
8
9
  export {};
@@ -0,0 +1,8 @@
1
+ import { BindingBuiltinPlugin, BindingCallableBuiltinPlugin } from '../binding';
2
+ import { BuiltinPlugin } from './constructors';
3
+ type BindingCallableBuiltinPluginLike = {
4
+ [K in keyof BindingCallableBuiltinPlugin]: BindingCallableBuiltinPlugin[K];
5
+ };
6
+ export declare function makeBuiltinPluginCallable(plugin: BuiltinPlugin): BuiltinPlugin & BindingCallableBuiltinPluginLike;
7
+ export declare function bindingifyBuiltInPlugin(plugin: BuiltinPlugin): BindingBuiltinPlugin;
8
+ export {};
@@ -1,7 +1,9 @@
1
- export declare const flattenedSchema: Record<string, import("./types").Schema>;
1
+ import { type NormalizedCliOptions } from './normalize';
2
+ import type { Schema } from './types';
3
+ export declare const flattenedSchema: Record<string, Schema>;
2
4
  export declare const options: {
3
5
  [k: string]: {
4
- type: "boolean" | "string";
6
+ type: 'boolean' | 'string';
5
7
  multiple: boolean;
6
8
  short?: string;
7
9
  default?: boolean | string | string[];
@@ -10,4 +12,4 @@ export declare const options: {
10
12
  };
11
13
  };
12
14
  export type ParseArgsOptions = typeof options;
13
- export declare function parseCliArguments(): import("./normalize").NormalizedCliOptions;
15
+ export declare function parseCliArguments(): NormalizedCliOptions;
@@ -1,10 +1,6 @@
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
1
  import { CliOptions } from './schema';
2
+ import type { InputOptions } from '../../options/input-options';
3
+ import type { OutputOptions } from '../../options/output-options';
8
4
  export interface NormalizedCliOptions {
9
5
  input: InputOptions;
10
6
  output: OutputOptions;