Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into config-accept
Browse files Browse the repository at this point in the history
  • Loading branch information
mtgrosser committed May 4, 2022
2 parents e25a358 + 4d02a20 commit 6bfe004
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 Basecamp
Copyright (c) 2022 Basecamp

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ There's [native support for import maps in Chrome/Edge 89+](https://caniuse.com/

Importmap for Rails is automatically included in Rails 7+ for new applications, but you can also install it manually in existing applications:

1. Add `importmap-rails` to your Gemfile with `gem 'importmap-rails'`
2. Run `./bin/bundle install`
3. Run `./bin/rails importmap:install`
1. Run `./bin/bundle add importmap-rails`
2. Run `./bin/rails importmap:install`

Note: In order to use JavaScript from Rails frameworks like Action Cable, Action Text, and Active Storage, you must be running Rails 7.0+. This was the first version that shipped with ESM compatible builds of these libraries.

Expand Down Expand Up @@ -251,7 +250,7 @@ Import your module on the specific page. Note: you'll likely want to use a `cont
<% end %>
```

**Important**: The `javacript_import_module_tag` should come after your `javascript_importmap_tags`
**Important**: The `javascript_import_module_tag` should come after your `javascript_importmap_tags`

```erb
<%= javascript_importmap_tags %>
Expand Down
9 changes: 5 additions & 4 deletions test/packager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def code() "200" end
end

test "failed request with mock" do
response = Class.new do
def code() "500" end
end.new

Net::HTTP.stub(:post, proc { raise "Unexpected Error" }) do
assert_raises(Importmap::Packager::HTTPError) do
@packager.import("[email protected]")
Expand All @@ -54,4 +50,9 @@ def code() "500" end
test "pin_for" do
assert_equal %(pin "react", to: "https://cdn/react"), @packager.pin_for("react", "https://cdn/react")
end

test "vendored_pin_for" do
assert_equal %(pin "react" # @17.0.2), @packager.vendored_pin_for("react", "https://cdn/[email protected]")
assert_equal %(pin "javascript/react", to: "javascript--react.js" # @17.0.2), @packager.vendored_pin_for("javascript/react", "https://cdn/[email protected]")
end
end

0 comments on commit 6bfe004

Please sign in to comment.