Sha256: f8609898b0c9f2ae0b178bccc16efb7cf44a3a50b80d2286f1e219af90f5920a

Contents?: true

Size: 741 Bytes

Versions: 12

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require "mini_racer"
require "execjs"

require "pakyow/support/inflector"

module Pakyow
  module Assets
    class Babel
      def self.transform(content, **options)
        context.call("Babel.transform", content, camelize_keys(options))
      end

      private

      def self.context
        @context ||= ExecJS.compile(
          File.read(
            File.expand_path("../../../../src/@babel/standalone@7.4.5/babel.min.js", __FILE__)
          )
        )
      end

      def self.camelize_keys(options)
        Hash[options.map { |key, value|
          key = Support.inflector.camelize(key)
          key = key[0, 1].downcase + key[1..-1]
          [key, value]
        }]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pakyow-assets-1.0.6 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.5 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.4 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.3 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.2 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.1 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.0 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.0.rc5 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.0.rc4 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.0.rc3 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.0.rc2 lib/pakyow/assets/babel.rb
pakyow-assets-1.0.0.rc1 lib/pakyow/assets/babel.rb