transform-D4RDjIPI.d.mts 6.2 KB

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