diff --git a/MIT-LICENSE b/MIT-LICENSE index 64e2003..031c4e5 100644 --- a/MIT-LICENSE +++ b/MIT-LICENSE @@ -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 diff --git a/README.md b/README.md index 593e1dd..6d5f98d 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 %> diff --git a/test/packager_test.rb b/test/packager_test.rb index 5266396..29ce7f6 100644 --- a/test/packager_test.rb +++ b/test/packager_test.rb @@ -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("missing-package-that-doesnt-exist@17.0.2") @@ -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/react@17.0.2") + assert_equal %(pin "javascript/react", to: "javascript--react.js" # @17.0.2), @packager.vendored_pin_for("javascript/react", "https://cdn/react@17.0.2") + end end