class ViewComponent::Compiler

def compile(raise_errors: false, force: false)

def compile(raise_errors: false, force: false)
  return if compiled? && !force
  return if component_class == ViewComponent::Base
  component_class.superclass.compile(raise_errors: raise_errors) if should_compile_superclass?
  if template_errors.present?
    raise TemplateError.new(template_errors) if raise_errors
    return false
  end
  if raise_errors
    component_class.validate_initialization_parameters!
    component_class.validate_collection_parameter!
  end
  if has_inline_template?
    template = component_class.inline_template
    redefinition_lock.synchronize do
      component_class.silence_redefinition_of_method("call")
      # rubocop:disable Style/EvalWithLocation
      component_class.class_eval <<-RUBY, template.path, template.lineno
      def call
        #{compiled_inline_template(template)}
      end
      RUBY
      # rubocop:enable Style/EvalWithLocation
      component_class.silence_redefinition_of_method("render_template_for")
      component_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def render_template_for(variant = nil)
        call
      end
      RUBY
    end
  else
    templates.each do |template|
      # Remove existing compiled template methods,
      # as Ruby warns when redefining a method.
      method_name = call_method_name(template[:variant])
      redefinition_lock.synchronize do
        component_class.silence_redefinition_of_method(method_name)
        # rubocop:disable Style/EvalWithLocation
        component_class.class_eval <<-RUBY, template[:path], 0
        def #{method_name}
          #{compiled_template(template[:path])}
        end
        RUBY
        # rubocop:enable Style/EvalWithLocation
      end
    end
    define_render_template_for
  end
  component_class.build_i18n_backend
  CompileCache.register(component_class)
end