terser.d.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. /** @deprecated Not implemented anymore */
  92. beautify?: boolean;
  93. braces?: boolean;
  94. comments?: boolean | 'all' | 'some' | RegExp | ( (node: any, comment: {
  95. value: string,
  96. type: 'comment1' | 'comment2' | 'comment3' | 'comment4',
  97. pos: number,
  98. line: number,
  99. col: number,
  100. }) => boolean );
  101. ecma?: ECMA;
  102. ie8?: boolean;
  103. indent_level?: number;
  104. indent_start?: number;
  105. inline_script?: boolean;
  106. keep_quoted_props?: boolean;
  107. max_line_len?: number | false;
  108. preamble?: string;
  109. preserve_annotations?: boolean;
  110. quote_keys?: boolean;
  111. quote_style?: OutputQuoteStyle;
  112. safari10?: boolean;
  113. semicolons?: boolean;
  114. shebang?: boolean;
  115. shorthand?: boolean;
  116. source_map?: SourceMapOptions;
  117. webkit?: boolean;
  118. width?: number;
  119. wrap_iife?: boolean;
  120. wrap_func_args?: boolean;
  121. }
  122. export enum OutputQuoteStyle {
  123. PreferDouble = 0,
  124. AlwaysSingle = 1,
  125. AlwaysDouble = 2,
  126. AlwaysOriginal = 3
  127. }
  128. export interface MinifyOptions {
  129. compress?: boolean | CompressOptions;
  130. ecma?: ECMA;
  131. ie8?: boolean;
  132. keep_classnames?: boolean | RegExp;
  133. keep_fnames?: boolean | RegExp;
  134. mangle?: boolean | MangleOptions;
  135. module?: boolean;
  136. nameCache?: object;
  137. format?: FormatOptions;
  138. /** @deprecated */
  139. output?: FormatOptions;
  140. parse?: ParseOptions;
  141. safari10?: boolean;
  142. sourceMap?: boolean | SourceMapOptions;
  143. toplevel?: boolean;
  144. }
  145. export interface MinifyOutput {
  146. code?: string;
  147. map?: RawSourceMap | string;
  148. }
  149. export interface SourceMapOptions {
  150. /** Source map object, 'inline' or source map file content */
  151. content?: RawSourceMap | string;
  152. includeSources?: boolean;
  153. filename?: string;
  154. root?: string;
  155. url?: string | 'inline';
  156. }
  157. export function minify(files: string | string[] | { [file: string]: string }, options?: MinifyOptions): Promise<MinifyOutput>;