Skip to content

Commit

Permalink
Update to new Importmap API (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bramjetten authored Aug 16, 2021
1 parent 57be251 commit c3d51c9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 2.2

### 2.3.2 (August 16h, 2021)
* Updated to new importmap API

### 2.3.1 (August 13th, 2021)
* Fixed bug `not present in the asset pipeline` in production

Expand Down
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
PATH
remote: .
specs:
spina (2.3.1)
spina (2.3.2)
ancestry
attr_json
babosa
bcrypt
breadcrumbs_on_rails
image_processing
importmap-rails (>= 0.1.1)
importmap-rails (~> 0.2.2)
jsonapi-serializer
kaminari
mobility (>= 1.1.3)
pg
rack-rewrite (>= 1.5.0)
rails (>= 6.0)
sass-rails
stimulus-rails (>= 0.3.0)
turbo-rails (>= 0.7.0)
stimulus-rails (~> 0.3.3)
turbo-rails (~> 0.7.2)
view_component (~> 2.32)

GEM
Expand Down Expand Up @@ -111,7 +111,7 @@ GEM
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (0.1.2)
importmap-rails (0.2.2)
rails (>= 6.0.0)
json (2.5.1)
jsonapi-serializer (2.2.0)
Expand Down Expand Up @@ -228,11 +228,11 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
stimulus-rails (0.3.2)
stimulus-rails (0.3.3)
rails (>= 6.0.0)
thor (1.1.0)
tilt (2.0.10)
turbo-rails (0.7.1)
turbo-rails (0.7.2)
rails (>= 6.0.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/spina/spina_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Spina::SpinaHelper

def spina_importmap_tags
safe_join [
javascript_inline_importmap_tag(Spina.config.importmap.paths),
javascript_inline_importmap_tag(Spina.config.importmap),
javascript_importmap_shim_tag,
javascript_include_tag("spina/libraries/trix"),
javascript_import_module_tag("application")
Expand Down
3 changes: 1 addition & 2 deletions lib/spina.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ module Spina
self.queues = ActiveSupport::InheritableOptions.new

# An importmap specifically meant for Spina
self.importmap = ActiveSupport::OrderedOptions.new
self.importmap.paths = Importmap::Paths.new
self.importmap = Importmap::Map.new

# Tailwind purging
# Spina will by default purge all unused Tailwind classes by scanning
Expand Down
10 changes: 5 additions & 5 deletions lib/spina/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class Engine < ::Rails::Engine
end

initializer "spina.importmap" do
Spina.config.importmap.paths.tap do |paths|
Spina.config.importmap.draw do
# Stimulus & Turbo
paths.asset "@hotwired/stimulus", path: "stimulus.js"
paths.asset "@hotwired/stimulus-autoloader", path: "stimulus-autoloader.js"
paths.asset "@hotwired/turbo-rails", path: "turbo.js"
pin "@hotwired/stimulus", to: "stimulus.js"
pin "@hotwired/stimulus-autoloader", to: "stimulus-autoloader.js"
pin "@hotwired/turbo-rails", to: "turbo.js"

paths.assets_in Spina::Engine.root.join("app/assets/javascripts/spina"), append_base_path: true
pin_all_from Spina::Engine.root.join("app/assets/javascripts/spina"), append_base_path: true
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/spina/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Spina
VERSION = "2.3.1"
VERSION = "2.3.2"
end
6 changes: 3 additions & 3 deletions spina.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Gem::Specification.new do |gem|
gem.add_dependency 'rack-rewrite', '>= 1.5.0'
gem.add_dependency 'attr_json'
gem.add_dependency 'view_component', '~> 2.32'
gem.add_dependency 'importmap-rails', '>= 0.1.1'
gem.add_dependency 'turbo-rails', '>= 0.7.0'
gem.add_dependency 'stimulus-rails', '>= 0.3.0'
gem.add_dependency 'importmap-rails', '~> 0.2.2'
gem.add_dependency 'turbo-rails', '~> 0.7.2'
gem.add_dependency 'stimulus-rails', '~> 0.3.3'
gem.add_dependency 'babosa'
gem.add_dependency 'jsonapi-serializer'
end

0 comments on commit c3d51c9

Please sign in to comment.