jspm-rails 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3608db3097cfd0de48ed40b816957df33790b6ba25e2ead331237692b175209f
4
- data.tar.gz: feadecec7f5fc18155a442608d768a89b0224d9a105e15b6ff9bdbdf334fcff9
3
+ metadata.gz: ab55116d3501ecad41e352757989ff10f02573ca74d15653ea7a5be84b23cc56
4
+ data.tar.gz: 8dc520f68c9c7aaf479ad2957133dfa987046c185104e592d2713beed0ba9bbc
5
5
  SHA512:
6
- metadata.gz: dbcdb2e923538ff68863b7137a6ff7386f50cc1382dd24580c8ec7b8e866fe1d66ffb8949d10d1e70fb3c7a120511a20ea4918f0bf3a9f0754e8842732a7721c
7
- data.tar.gz: 40f8b42545b0609e73389d13e02aee7c7ebe6617ac3057d42e4f98d6b78ab52adf161b2c112b60ebaf42f808514a14c91286be334fef2c9ab5c817330f9af8d3
6
+ metadata.gz: 5eea76892af66e3824c16bfff24ef67dbb59d91320cac4169bbbb4dac0182c1d4fdb3cff4a18e6762738938e1911870c7229c7cd3829df454f36286c9fe819f9
7
+ data.tar.gz: 6e728a8c9f064f649e3f420bcc93ce78a2a8b7372f53e9d4d8ee361d4c3b1e08be560a69758113ddfedb4347669363730b237b7087509166c2f4ea5ded0e8be1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.1 (unreleased)
3
+ ## 0.4.0 (unreleased)
4
+
5
+ - `javascript_jspm_entry_tags('admin')` loads another module in `app/javascript` as the entry.
6
+
7
+ ## 0.3.1 (2026-11-13)
4
8
 
5
9
  - Fixes a `KeyError` when jspm scopes dependencies at the filesystem root.
6
10
 
data/README.md CHANGED
@@ -79,7 +79,7 @@ Reload the page.
79
79
 
80
80
  ## Writing your JavaScript
81
81
 
82
- **The entry point is `app/javascript/application.js`.** `javascript_jspm_tags` loads it as a module, and the install traces everything it imports.
82
+ **The entry point is `app/javascript/application.js`.** `javascript_jspm_tags` loads it as a module, and the install traces everything it imports. For a layout that needs a different entry, see the [FAQ](#faq).
83
83
 
84
84
  **Import packages by name,** as their documentation shows:
85
85
 
@@ -223,7 +223,7 @@ Not with jspm-rails, which doesn't transpile. Use jsbundling-rails.
223
223
  Safari doesn't support CSS module scripts yet, so link stylesheets with `stylesheet_link_tag`.
224
224
 
225
225
  **Can I have more than one entry point?**
226
- Not yet. Import everything from `application.js`, dynamically for code only some pages need.
226
+ Yes. A layout whose pages need different code loads `app/javascript/admin.js` with `javascript_jspm_entry_tags('admin')`. The install traces every module in `app/javascript`, so any of them can be an entry.
227
227
 
228
228
  **Can I use it alongside importmap-rails?**
229
229
  Use one or the other. Both render the page's import map.
data/lib/jspm/helper.rb CHANGED
@@ -4,7 +4,13 @@ module Jspm
4
4
  # View helpers for apps whose JavaScript jspm-rails installs.
5
5
  module Helper
6
6
  def javascript_jspm_tags
7
- Tags.call(view: self)
7
+ javascript_jspm_entry_tags('application')
8
+ end
9
+
10
+ # Loads app/javascript/<entry>.js instead of application.js, for a layout
11
+ # whose pages need different code.
12
+ def javascript_jspm_entry_tags(entry)
13
+ Tags.call(entry:, view: self)
8
14
  end
9
15
  end
10
16
  end
data/lib/jspm/tags.rb CHANGED
@@ -12,11 +12,12 @@ module Jspm
12
12
  MODULE_EXTENSIONS = %w[.js .mjs].freeze
13
13
  private_constant :MODULE_EXTENSIONS
14
14
 
15
- def self.call(view:)
15
+ def self.call(entry:, view:)
16
16
  import_map = JSON.parse(Rails.root.join(Paths::IMPORT_MAP).read)
17
17
  load_path = Rails.application.assets.load_path
18
- entry_url = view.asset_path(Paths::ENTRY)
19
- digested_entry = load_path.find(Paths::ENTRY).digested_path.to_s
18
+ entry_path = "#{entry}.js"
19
+ entry_url = view.asset_path(entry_path)
20
+ digested_entry = load_path.find(entry_path).digested_path.to_s
20
21
  prefix = entry_url.delete_suffix(digested_entry)
21
22
  new(entry_url:, import_map:, load_path:, prefix:, view:).call
22
23
  end
data/lib/jspm/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jspm
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  public_constant :VERSION
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jspm-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clay Shentrup
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 4.0.16
86
+ rubygems_version: 4.0.20
87
87
  specification_version: 4
88
88
  summary: Import maps for Rails, built by jspm
89
89
  test_files: []