transform-BoJxrM-e.d.mts 5.1 KB

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