class Ruby2JS::ConfigurationDSL

Public Class Methods

load_from_file(config_file, options = {}) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 3
def self.load_from_file(config_file, options = {})
  new(options).tap { _1.instance_eval(File.read(config_file), config_file, 1) }
end
new(options = {}) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 7
def initialize(options = {})
  @options = options
end

Public Instance Methods

autoexports(value) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 78
def autoexports(value)
  @options[:autoexports] = value
end
autoimport(identifier = nil, file = nil, &block) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 62
def autoimport(identifier = nil, file = nil, &block)
  if block
    @options[:autoimports] = block
    return
  elsif @options[:autoimports].is_a?(Proc)
    @options[:autoimports] = {}
  end

  @options[:autoimports] ||= {}
  @options[:autoimports][identifier] = file
end
autoimport_defs(value) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 74
def autoimport_defs(value)
  @options[:defs] = value
end
cjs_modules() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 41
def cjs_modules
  @options[:module] = :cjs
end
equality_comparison() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 29
def equality_comparison
  @options[:comparison] = :equality
end
eslevel(level) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 25
def eslevel(level)
  @options[:eslevel] = level
end
esm_modules() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 37
def esm_modules
  @options[:module] = :esm
end
filter(name) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 15
def filter(name)
  @options[:filters] ||= []
  @options[:filters] << name
end
identity_comparison() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 33
def identity_comparison
  @options[:comparison] = :identity
end
include_method(method_name) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 82
def include_method(method_name)
  @options[:include] ||= []
  @options[:include] << method_name unless @options[:include].include?(method_name)
end
logical_or() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 54
def logical_or
  @options[:or] = :logical
end
nullish_or() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 58
def nullish_or
  @options[:or] = :nullish
end
preset(bool = true) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 11
def preset(bool = true)
  @options[:preset] = bool
end
private_field_ivars() click to toggle source

Only applies for ES2022+

# File lib/ruby2js/configuration_dsl.rb, line 50
def private_field_ivars
  @options[:underscored_private] = false
end
remove_filter(name) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 20
def remove_filter(name)
  @options[:disable_filters] ||= []
  @options[:disable_filters] << name
end
template_literal_tags(tags) click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 87
def template_literal_tags(tags)
  @options[:template_literal_tags] = tags
end
to_h() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 91
def to_h
  @options
end
underscored_ivars() click to toggle source
# File lib/ruby2js/configuration_dsl.rb, line 45
def underscored_ivars
  @options[:underscored_private] = true
end