Class: Oxc::Minifier

Inherits:
Object
  • Object
show all
Defined in:
lib/oxc/minifier.rb,
sig/oxc/minifier.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Minifier

: (?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> void

Parameters:

  • filename: (String, nil)
  • lang: (String, nil)
  • source_type: (String, nil)
  • compress: (compress, nil)
  • mangle: (mangle, nil)
  • codegen: (codegen, nil)
  • sourcemap: (Boolean)
  • strict: (Boolean)


8
9
10
11
12
# File 'lib/oxc/minifier.rb', line 8

def initialize(**options)
  @options = options.transform_keys(&:to_sym).freeze

  freeze
end

Instance Attribute Details

#optionsHash[Symbol, untyped] (readonly)

Signature:

  • Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


5
6
7
# File 'lib/oxc/minifier.rb', line 5

def options
  @options
end

Instance Method Details

#inspectString

: () -> String

Returns:

  • (String)


27
28
29
# File 'lib/oxc/minifier.rb', line 27

def inspect
  "#<#{self.class.name} #{options.inspect}>"
end

#minify(source, **overrides) ⇒ Oxc::MinifyResult Also known as: call

: (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::MinifyResult

Parameters:

  • (String)
  • filename: (String, nil)
  • lang: (String, nil)
  • source_type: (String, nil)
  • compress: (compress, nil)
  • mangle: (mangle, nil)
  • codegen: (codegen, nil)
  • sourcemap: (Boolean)
  • strict: (Boolean)

Returns:



15
16
17
# File 'lib/oxc/minifier.rb', line 15

def minify(source, **overrides)
  Oxc.minify(source, **options, **overrides)
end

#with(**overrides) ⇒ Oxc::Minifier

: (?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::Minifier

Parameters:

  • filename: (String, nil)
  • lang: (String, nil)
  • source_type: (String, nil)
  • compress: (compress, nil)
  • mangle: (mangle, nil)
  • codegen: (codegen, nil)
  • sourcemap: (Boolean)
  • strict: (Boolean)

Returns:



22
23
24
# File 'lib/oxc/minifier.rb', line 22

def with(**overrides)
  self.class.new(**options, **overrides)
end