jspm-rails 0.3.0 → 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: 2066a105c29bf4cebd19a25c1afa9ac3bfb7530b080cd5f347ed1c69e3cd56b2
4
- data.tar.gz: 1e89f49cd667a1b7771b90b2df5a8d36918d0cdb78334fe6cdee6d831d470fcc
3
+ metadata.gz: ab55116d3501ecad41e352757989ff10f02573ca74d15653ea7a5be84b23cc56
4
+ data.tar.gz: 8dc520f68c9c7aaf479ad2957133dfa987046c185104e592d2713beed0ba9bbc
5
5
  SHA512:
6
- metadata.gz: 4253a93277d3368d3e2e34fe023aeee5ac6d74090417941e36056ea65ccffb3f9465909e036ae52a00caa3bb403ef0b3d9ee7e6de26299b0f741487baf11fa30
7
- data.tar.gz: 330b9d72f4d2b528aa4701d655cc066adf83da4fbfef4f718eb472c624d0398f52542e05ee84b97bfc3b25d4219f227e25ba2f02bc7aab9bd524cefc8ddae6ef
6
+ metadata.gz: 5eea76892af66e3824c16bfff24ef67dbb59d91320cac4169bbbb4dac0182c1d4fdb3cff4a18e6762738938e1911870c7229c7cd3829df454f36286c9fe819f9
7
+ data.tar.gz: 6e728a8c9f064f649e3f420bcc93ce78a2a8b7372f53e9d4d8ee361d4c3b1e08be560a69758113ddfedb4347669363730b237b7087509166c2f4ea5ded0e8be1
data/CHANGELOG.md CHANGED
@@ -1,10 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.0 (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)
8
+
9
+ - Fixes a `KeyError` when jspm scopes dependencies at the filesystem root.
10
+
11
+ ## 0.3.0 (2026-11-13)
4
12
 
5
13
  - Names every module in `app/javascript` in the import map, so stimulus-rails's `eagerLoadControllersFrom` finds controllers.
6
14
 
7
- ## 0.2.0 (unreleased)
15
+ ## 0.2.0 (2026-11-13)
8
16
 
9
17
  - Reads Yarn 1's `yarn.lock` as well as `package-lock.json`.
10
18
  - No longer copies npm packages' stylesheets, fonts and images. Put the directories you use on Propshaft's load path instead.
data/README.md CHANGED
@@ -68,11 +68,18 @@ bin/rails jspm:install
68
68
  git add config/importmap.json vendor/jspm
69
69
  ```
70
70
 
71
+ To have GitHub collapse those generated files in pull requests, mark them in `.gitattributes`:
72
+
73
+ ```
74
+ config/importmap.json linguist-generated
75
+ vendor/jspm/** linguist-generated
76
+ ```
77
+
71
78
  Reload the page.
72
79
 
73
80
  ## Writing your JavaScript
74
81
 
75
- **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).
76
83
 
77
84
  **Import packages by name,** as their documentation shows:
78
85
 
@@ -216,7 +223,7 @@ Not with jspm-rails, which doesn't transpile. Use jsbundling-rails.
216
223
  Safari doesn't support CSS module scripts yet, so link stylesheets with `stylesheet_link_tag`.
217
224
 
218
225
  **Can I have more than one entry point?**
219
- 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.
220
227
 
221
228
  **Can I use it alongside importmap-rails?**
222
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
@@ -56,7 +56,7 @@ module Jspm
56
56
  # jspm.io URL stays as it is.
57
57
  def localize(target)
58
58
  case target
59
- when %r{\A/.*/\z} then SCHEME
59
+ when %r{\A/(?:.*/)?\z} then SCHEME
60
60
  when %r{\A/} then modules_by_path.fetch(target).asset_name
61
61
  else target
62
62
  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.0'
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.0
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: []