class React::JSX::BabelTransformer

A {React::JSX}-compliant transformer which uses ‘Babel::Transpiler` to transform JSX.

Constants

DEFAULT_TRANSFORM_OPTIONS
DEPRECATED_OPTIONS

Public Class Methods

new(options) click to toggle source
# File lib/react/jsx/babel_transformer.rb, line 8
def initialize(options)
  if (options.keys & DEPRECATED_OPTIONS).any?
    ActiveSupport::Deprecation.warn('Setting config.react.jsx_transform_options for :harmony, :strip_types, and :asset_path keys is now deprecated and has no effect with the default Babel Transformer.'+
                                        'Please use new Babel Transformer options :whitelist, :plugin instead.')
  end

  @transform_options = DEFAULT_TRANSFORM_OPTIONS.merge(options)
end

Public Instance Methods

transform(code) click to toggle source
# File lib/react/jsx/babel_transformer.rb, line 17
def transform(code)
  Babel::Transpiler.transform(code, @transform_options)['code']
end