transform-Kz3D2LbX.d.mts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { a as RolldownLog } from "./logging-C6h4g8dA.mjs";
  2. import { F as MinifyResult$1, H as SourceMap, L as ParseResult$1, P as MinifyOptions$1, R as ParserOptions$1, W as TsconfigCache$1, a as BindingEnhancedTransformOptions, o as BindingEnhancedTransformResult, v as BindingTsconfigResult } from "./binding-DUEnSb0A.mjs";
  3. //#region src/utils/resolve-tsconfig.d.ts
  4. /**
  5. * Cache for tsconfig resolution to avoid redundant file system operations.
  6. *
  7. * The cache stores resolved tsconfig configurations keyed by their file paths.
  8. * When transforming multiple files in the same project, tsconfig lookups are
  9. * deduplicated, improving performance.
  10. *
  11. * @category Utilities
  12. * @experimental
  13. */
  14. declare class TsconfigCache extends TsconfigCache$1 {
  15. constructor();
  16. }
  17. /** @hidden This is only expected to be used by Vite */
  18. declare function resolveTsconfig(filename: string, cache?: TsconfigCache | null): BindingTsconfigResult | null;
  19. //#endregion
  20. //#region src/utils/parse.d.ts
  21. /**
  22. * Result of parsing a code
  23. *
  24. * @category Utilities
  25. */
  26. interface ParseResult extends ParseResult$1 {}
  27. /**
  28. * Options for parsing a code
  29. *
  30. * @category Utilities
  31. */
  32. interface ParserOptions extends ParserOptions$1 {}
  33. /**
  34. * Parse JS/TS source asynchronously on a separate thread.
  35. *
  36. * Note that not all of the workload can happen on a separate thread.
  37. * Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
  38. * has to happen on current thread. This synchronous deserialization work typically outweighs
  39. * the asynchronous parsing by a factor of between 3 and 20.
  40. *
  41. * i.e. the majority of the workload cannot be parallelized by using this method.
  42. *
  43. * Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
  44. * If you need to parallelize parsing multiple files, it is recommended to use worker threads.
  45. *
  46. * @category Utilities
  47. */
  48. declare function parse(filename: string, sourceText: string, options?: ParserOptions | null): Promise<ParseResult>;
  49. /**
  50. * Parse JS/TS source synchronously on current thread.
  51. *
  52. * This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
  53. * of spawning a thread, and the majority of the workload cannot be parallelized anyway
  54. * (see {@linkcode parse} documentation for details).
  55. *
  56. * If you need to parallelize parsing multiple files, it is recommended to use worker threads
  57. * with {@linkcode parseSync} rather than using {@linkcode parse}.
  58. *
  59. * @category Utilities
  60. */
  61. declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | null): ParseResult;
  62. //#endregion
  63. //#region src/utils/minify.d.ts
  64. /**
  65. * Options for minification.
  66. *
  67. * @category Utilities
  68. */
  69. interface MinifyOptions extends MinifyOptions$1 {
  70. inputMap?: SourceMap;
  71. }
  72. /**
  73. * The result of minification.
  74. *
  75. * @category Utilities
  76. */
  77. interface MinifyResult extends MinifyResult$1 {}
  78. /**
  79. * Minify asynchronously.
  80. *
  81. * Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
  82. *
  83. * @category Utilities
  84. * @experimental
  85. */
  86. declare function minify(filename: string, sourceText: string, options?: MinifyOptions | null): Promise<MinifyResult>;
  87. /**
  88. * Minify synchronously.
  89. *
  90. * @category Utilities
  91. * @experimental
  92. */
  93. declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | null): MinifyResult;
  94. //#endregion
  95. //#region src/utils/transform.d.ts
  96. /**
  97. * Options for transforming a code.
  98. *
  99. * @category Utilities
  100. */
  101. interface TransformOptions extends BindingEnhancedTransformOptions {}
  102. /**
  103. * Result of transforming a code.
  104. *
  105. * @category Utilities
  106. */
  107. type TransformResult = Omit<BindingEnhancedTransformResult, "errors" | "warnings"> & {
  108. errors: Error[];
  109. warnings: RolldownLog[];
  110. };
  111. /**
  112. * Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
  113. *
  114. * Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
  115. *
  116. * @param filename The name of the file being transformed. If this is a
  117. * relative path, consider setting the {@linkcode TransformOptions#cwd} option.
  118. * @param sourceText The source code to transform.
  119. * @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
  120. * @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
  121. * Only used when `options.tsconfig` is `true`.
  122. *
  123. * @returns a promise that resolves to an object containing the transformed code,
  124. * source maps, and any errors that occurred during parsing or transformation.
  125. *
  126. * @category Utilities
  127. * @experimental
  128. */
  129. declare function transform(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): Promise<TransformResult>;
  130. /**
  131. * Transpile a JavaScript or TypeScript into a target ECMAScript version.
  132. *
  133. * @param filename The name of the file being transformed. If this is a
  134. * relative path, consider setting the {@linkcode TransformOptions#cwd} option.
  135. * @param sourceText The source code to transform.
  136. * @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
  137. * @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
  138. * Only used when `options.tsconfig` is `true`.
  139. *
  140. * @returns an object containing the transformed code, source maps, and any errors
  141. * that occurred during parsing or transformation.
  142. *
  143. * @category Utilities
  144. * @experimental
  145. */
  146. declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): TransformResult;
  147. //#endregion
  148. export { MinifyOptions as a, minifySync as c, parse as d, parseSync as f, transformSync as i, ParseResult as l, resolveTsconfig as m, TransformResult as n, MinifyResult as o, TsconfigCache as p, transform as r, minify as s, TransformOptions as t, ParserOptions as u };