Sha256: adf88a5299ca3412079ad1a25273feb66a7825c5c5009a160d43313dfeab3a28

Contents?: true

Size: 961 Bytes

Versions: 10

Compression:

Stored size: 961 Bytes

Contents

create_file Rails.root.join('config/initializers/ruby2js.rb').to_s,
  <<~CONFIG
    require 'ruby2js/filter/esm'
    require 'ruby2js/filter/functions'
    require 'ruby2js/filter/stimulus'

    Ruby2JS::SprocketsTransformer.options = {
      autoexports: :default,
      eslevel: 2020
    }

    require 'stimulus/importmap_helper'

    module Stimulus::ImportmapHelper
      def find_javascript_files_in_tree(path)
         exts = {'.js' => '.js', '.jsm' => '.jsm'}.merge(
           Sprockets.mime_exts.map {|key, value|
             next unless Sprockets.transformers[value]["application/javascript"]
             [key, '.js']
           }.compact.to_h)

         Dir[path.join('**/*')].map {|file|
           file_ext, web_ext = Sprockets::PathUtils.match_path_extname(file, exts)
           next unless file_ext

           next unless File.file? file

           Pathname.new(file.chomp(file_ext) + web_ext)
         }.compact
      end
    end
  CONFIG

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby2js-4.1.6 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.1.5 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.1.4 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.1.3 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.1.2 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.1.1 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.1.0 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.0.5 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.0.4 lib/tasks/install/stimulus-sprockets.rb
ruby2js-4.0.3 lib/tasks/install/stimulus-sprockets.rb