-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate importmap from the application #163
Conversation
This will prevent the application assets from polluting the host apps assets.
@rosa What do you think about this? |
I think this might be fixed by #175. |
It is not. The assets will still be part of you normal application included in the importmap. There is no reason that they should be, since MissionControl::Jobs are an "embedded application" into your main one. |
Ah ok, got it. How/where would you store the assets then? With #175, the assets are still included in the importmap, but only loaded (and preloaded) in the Mission Control views. |
The same way, they are just part of a separate importmap which is configured like shown in the PR description. Same way as ActiveAdmin. Then it wont show up in your applications own importmap and maybe break things. |
Sorry for the delay here! I've been busy with other stuff and neglecting this gem, but I'm back now and in full focus, so I'll be catching up with all PRs and issues. This looks great to me, going to do a couple of tests to be completely sure, but it makes perfect sense. Thank you so much, @henrikbjorn 🙏 |
@@ -9,7 +9,7 @@ | |||
<meta name="turbo-cache-control" content="no-cache"> | |||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.1/css/bulma.min.css"> | |||
<%= stylesheet_link_tag "mission_control/jobs/application", "data-turbo-track": "reload" %> | |||
<%= javascript_importmap_tags "application-mcj" %> | |||
<%= javascript_importmap_tags "application", importmap: MissionControl::Jobs.importmap %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe passing a custom importmap here (rails/importmap-rails#187) wasn't available from version < 2, perhaps with this change, we should require that version 🤔 Like:
diff --git a/Gemfile.lock b/Gemfile.lock
index 185a970..5560422 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -29,7 +29,7 @@ PATH
remote: .
specs:
mission_control-jobs (0.3.3)
- importmap-rails
+ importmap-rails (~> 2.0)
irb (~> 1.13)
rails (>= 7.1)
stimulus-rails
diff --git a/mission_control-jobs.gemspec b/mission_control-jobs.gemspec
index fc03152..07240ba 100644
--- a/mission_control-jobs.gemspec
+++ b/mission_control-jobs.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
end
spec.add_dependency "rails", ">= 7.1"
- spec.add_dependency "importmap-rails"
+ spec.add_dependency "importmap-rails", "~> 2.0"
spec.add_dependency "turbo-rails"
spec.add_dependency "stimulus-rails"
spec.add_dependency "irb", "~> 1.13"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry, I don't know how I looked this up 😅 It was added in version 1.2.1, which is kind of old, but perhaps it's worth making that explicit for older apps 🤔
diff --git a/mission_control-jobs.gemspec b/mission_control-jobs.gemspec
index fc03152..76e081e 100644
--- a/mission_control-jobs.gemspec
+++ b/mission_control-jobs.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
end
spec.add_dependency "rails", ">= 7.1"
- spec.add_dependency "importmap-rails"
+ spec.add_dependency "importmap-rails", ">= 1.2.1"
spec.add_dependency "turbo-rails"
spec.add_dependency "stimulus-rails"
spec.add_dependency "irb", "~> 1.13"
@@ -9,7 +9,7 @@ | |||
<meta name="turbo-cache-control" content="no-cache"> | |||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.1/css/bulma.min.css"> | |||
<%= stylesheet_link_tag "mission_control/jobs/application", "data-turbo-track": "reload" %> | |||
<%= javascript_importmap_tags "application-mcj" %> | |||
<%= javascript_importmap_tags "application", importmap: MissionControl::Jobs.importmap %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe passing a custom importmap
here (rails/importmap-rails#187) wasn't available from version < 2, perhaps with this change, we should require that version 🤔 Like:
diff --git a/Gemfile.lock b/Gemfile.lock
index 185a970..5560422 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -29,7 +29,7 @@ PATH
remote: .
specs:
mission_control-jobs (0.3.3)
- importmap-rails
+ importmap-rails (~> 2.0)
irb (~> 1.13)
rails (>= 7.1)
stimulus-rails
diff --git a/mission_control-jobs.gemspec b/mission_control-jobs.gemspec
index fc03152..07240ba 100644
--- a/mission_control-jobs.gemspec
+++ b/mission_control-jobs.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
end
spec.add_dependency "rails", ">= 7.1"
- spec.add_dependency "importmap-rails"
+ spec.add_dependency "importmap-rails", "~> 2.0"
spec.add_dependency "turbo-rails"
spec.add_dependency "stimulus-rails"
spec.add_dependency "irb", "~> 1.13"
Follow up to #163, which uses support for passing a custom importmap to the `javascript_importmap_tags` helper.
This is based upon the importmap usage seen in ActiveAdmin.
This gem essentially provides a complete Application and as such it makes sense to have the importmap separate from the application it is embedded into.
There is a 0% chance of the javascript included here to be used outside of the gem itself.
It is still possible to extend the importmap if that is needed.