Skip to content

Commit

Permalink
Dummy app: Depend on turbo-rails through importmap (hotwired#231)
Browse files Browse the repository at this point in the history
* Depend on `importmap-rails` in dummy app

When running tests against a dummy Rails application, use
[importmap-rails][].

The contents of this commit were generated by following the
[Installation][] instructions.

[importmap-rails]: https://github.com/rails/importmap-rails/tree/v0.5.1
[Installation]: https://github.com/rails/importmap-rails/tree/v0.5.1#installation

* Depend on `turbo-rails` through importmap

The contents of this commit were generated by following the
[Installation](./README.md#installation) instructions.

* Depend on `@rails/actioncable` through importmap

Replace the `package.json` development dependency with an importmap
entry.

* Remove Webpacker JavaScript entrypoints

Removes Webpacker-specific helpers from the Application layout in favor
of the importmap-generated helpers.
  • Loading branch information
seanpdoyle authored Sep 10, 2021
1 parent 4e26813 commit 8df11f5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ gem 'rake'
gem 'byebug'
gem 'puma'

group :development, :test do
gem 'importmap-rails'
end

group :test do
gem 'capybara'
gem 'rexml'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ GEM
activesupport (>= 5.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
importmap-rails (0.5.1)
rails (>= 6.0.0)
loofah (2.12.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down Expand Up @@ -168,6 +170,7 @@ PLATFORMS
DEPENDENCIES
byebug
capybara
importmap-rails
puma
rake
rexml
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
2 changes: 2 additions & 0 deletions test/dummy/app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
Empty file.
2 changes: 1 addition & 1 deletion test/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<%= stylesheet_link_tag 'application', media: 'all' %>
<%= yield :head %>
<%= javascript_include_tag "turbo", type: "module" %>
<%= javascript_importmap_tags %>
</head>

<body>
Expand Down
4 changes: 4 additions & 0 deletions test/dummy/bin/importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require_relative "../config/application"
require "importmap/commands"
8 changes: 8 additions & 0 deletions test/dummy/config/importmap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use direct uploads for Active Storage (remember to import "@rails/activestorage" in your application.js)
# pin "@rails/activestorage", to: "activestorage.esm.js"

# Use node modules from a JavaScript CDN by running ./bin/importmap

pin "application"
pin "@hotwired/turbo-rails", to: "turbo.js"
pin "@rails/actioncable", to: "actioncable.esm.js"

0 comments on commit 8df11f5

Please sign in to comment.