Sha256: 167738fff41830d28c95cb9c299a2770c768bc8c7ea92d9eb33e4576feac0877
Contents?: true
Size: 1016 Bytes
Versions: 5
Compression:
Stored size: 1016 Bytes
Contents
# frozen_string_literal: true require 'importmap/packager' module RailsAdmin class ImportmapFormatter attr_reader :packager def initialize(path = 'confing/importmap.rails_admin.rb') @packager = Importmap::Packager.new(path) end def format imports = packager.import("rails_admin@#{RailsAdmin::Version.js}") # Use ESM compatible version to work around https://github.com/cljsjs/packages/issues/1579 imports['@popperjs/core'].gsub!('lib/index.js', 'dist/esm/popper.js') # Tidy up jQuery UI dependencies jquery_uis = imports.keys.filter { |key, _| key =~ /jquery-ui/ } imports['jquery-ui/'] = imports[jquery_uis.first].gsub(%r{(@[^/@]+)/[^@]+$}, '\1/') imports.reject! { |key, _| jquery_uis.include? key } pins = ['pin "rails_admin", preload: true', packager.pin_for('rails_admin/src/rails_admin/base', imports.delete('rails_admin'))] (pins + imports.map { |package, url| packager.pin_for(package, url) }).join("\n") end end end
Version data entries
5 entries across 5 versions & 1 rubygems