terser.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /// <reference lib="es2015" />
  2. import { RawSourceMap } from 'source-map';
  3. export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
  4. export interface ParseOptions {
  5. bare_returns?: boolean;
  6. ecma?: ECMA;
  7. html5_comments?: boolean;
  8. shebang?: boolean;
  9. }
  10. export interface CompressOptions {
  11. arguments?: boolean;
  12. arrows?: boolean;
  13. booleans_as_integers?: boolean;
  14. booleans?: boolean;
  15. collapse_vars?: boolean;
  16. comparisons?: boolean;
  17. computed_props?: boolean;
  18. conditionals?: boolean;
  19. dead_code?: boolean;
  20. defaults?: boolean;
  21. directives?: boolean;
  22. drop_console?: boolean;
  23. drop_debugger?: boolean;
  24. ecma?: ECMA;
  25. evaluate?: boolean;
  26. expression?: boolean;
  27. global_defs?: object;
  28. hoist_funs?: boolean;
  29. hoist_props?: boolean;
  30. hoist_vars?: boolean;
  31. ie8?: boolean;
  32. if_return?: boolean;
  33. inline?: boolean | InlineFunctions;
  34. join_vars?: boolean;
  35. keep_classnames?: boolean | RegExp;
  36. keep_fargs?: boolean;
  37. keep_fnames?: boolean | RegExp;
  38. keep_infinity?: boolean;
  39. loops?: boolean;
  40. module?: boolean;
  41. negate_iife?: boolean;
  42. passes?: number;
  43. properties?: boolean;
  44. pure_funcs?: string[];
  45. pure_getters?: boolean | 'strict';
  46. reduce_funcs?: boolean;
  47. reduce_vars?: boolean;
  48. sequences?: boolean | number;
  49. side_effects?: boolean;
  50. switches?: boolean;
  51. toplevel?: boolean;
  52. top_retain?: null | string | string[] | RegExp;
  53. typeofs?: boolean;
  54. unsafe_arrows?: boolean;
  55. unsafe?: boolean;
  56. unsafe_comps?: boolean;
  57. unsafe_Function?: boolean;
  58. unsafe_math?: boolean;
  59. unsafe_symbols?: boolean;
  60. unsafe_methods?: boolean;
  61. unsafe_proto?: boolean;
  62. unsafe_regexp?: boolean;
  63. unsafe_undefined?: boolean;
  64. unused?: boolean;
  65. }
  66. export enum InlineFunctions {
  67. Disabled = 0,
  68. SimpleFunctions = 1,
  69. WithArguments = 2,
  70. WithArgumentsAndVariables = 3
  71. }
  72. export interface MangleOptions {
  73. eval?: boolean;
  74. keep_classnames?: boolean | RegExp;
  75. keep_fnames?: boolean | RegExp;
  76. module?: boolean;
  77. properties?: boolean | ManglePropertiesOptions;
  78. reserved?: string[];
  79. safari10?: boolean;
  80. toplevel?: boolean;
  81. }
  82. export interface ManglePropertiesOptions {
  83. builtins?: boolean;
  84. debug?: boolean;
  85. keep_quoted?: boolean | 'strict';
  86. regex?: RegExp | string;
  87. reserved?: string[];
  88. }
  89. export interface FormatOptions {
  90. ascii_only?: boolean;
  91. beautify?: boolean;
  92. braces?: boolean;
  93. comments?: boolean | 'all' | 'some' | RegExp | ( (node: any, comment: {
  94. value: string,
  95. type: 'comment1' | 'comment2' | 'comment3' | 'comment4',
  96. pos: number,
  97. line: number,
  98. col: number,
  99. }) => boolean );
  100. ecma?: ECMA;
  101. ie8?: boolean;
  102. indent_level?: number;
  103. indent_start?: number;
  104. inline_script?: boolean;
  105. keep_quoted_props?: boolean;
  106. max_line_len?: number | false;
  107. preamble?: string;
  108. preserve_annotations?: boolean;
  109. quote_keys?: boolean;
  110. quote_style?: OutputQuoteStyle;
  111. safari10?: boolean;
  112. semicolons?: boolean;
  113. shebang?: boolean;
  114. shorthand?: boolean;
  115. source_map?: SourceMapOptions;
  116. webkit?: boolean;
  117. width?: number;
  118. wrap_iife?: boolean;
  119. wrap_func_args?: boolean;
  120. }
  121. export enum OutputQuoteStyle {
  122. PreferDouble = 0,
  123. AlwaysSingle = 1,
  124. AlwaysDouble = 2,
  125. AlwaysOriginal = 3
  126. }
  127. export interface MinifyOptions {
  128. compress?: boolean | CompressOptions;
  129. ecma?: ECMA;
  130. ie8?: boolean;
  131. keep_classnames?: boolean | RegExp;
  132. keep_fnames?: boolean | RegExp;
  133. mangle?: boolean | MangleOptions;
  134. module?: boolean;
  135. nameCache?: object;
  136. format?: FormatOptions;
  137. /** @deprecated */
  138. output?: FormatOptions;
  139. parse?: ParseOptions;
  140. safari10?: boolean;
  141. sourceMap?: boolean | SourceMapOptions;
  142. toplevel?: boolean;
  143. }
  144. export interface MinifyOutput {
  145. code?: string;
  146. map?: RawSourceMap | string;
  147. }
  148. export interface SourceMapOptions {
  149. /** Source map object, 'inline' or source map file content */
  150. content?: RawSourceMap | string;
  151. includeSources?: boolean;
  152. filename?: string;
  153. root?: string;
  154. url?: string | 'inline';
  155. }
  156. export function minify(files: string | string[] | { [file: string]: string }, options?: MinifyOptions): Promise<MinifyOutput>;