jspm-rails 0.2.0 → 0.3.1

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: 647327a342d54b7e908d058985494a887120aebb49c07e6f220af7b843252ea7
4
- data.tar.gz: 8595959e6a8e642ef2fb5c419274401afdad6b0caad89d32ab846ccda49da646
3
+ metadata.gz: 3608db3097cfd0de48ed40b816957df33790b6ba25e2ead331237692b175209f
4
+ data.tar.gz: feadecec7f5fc18155a442608d768a89b0224d9a105e15b6ff9bdbdf334fcff9
5
5
  SHA512:
6
- metadata.gz: 5fdfb17f58799c9cf1755352615eb27a01b48a3bd219b2dcac1ecdd2a1e93090e678b6ef77691095fe58fecb079ffac5bf03e211d1913e59d66181f151793e96
7
- data.tar.gz: d4490661eaaa59ef3ba76ade81c6659e4db588e4ea692a9bd6d74c17c4f3619b272e9710110c2adca8228b17245b38d3879b113544004e0928ea546a89a1d5b1
6
+ metadata.gz: dbcdb2e923538ff68863b7137a6ff7386f50cc1382dd24580c8ec7b8e866fe1d66ffb8949d10d1e70fb3c7a120511a20ea4918f0bf3a9f0754e8842732a7721c
7
+ data.tar.gz: 40f8b42545b0609e73389d13e02aee7c7ebe6617ac3057d42e4f98d6b78ab52adf161b2c112b60ebaf42f808514a14c91286be334fef2c9ab5c817330f9af8d3
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## 0.2.0 (unreleased)
3
+ ## 0.3.1 (unreleased)
4
+
5
+ - Fixes a `KeyError` when jspm scopes dependencies at the filesystem root.
6
+
7
+ ## 0.3.0 (2026-11-13)
8
+
9
+ - Names every module in `app/javascript` in the import map, so stimulus-rails's `eagerLoadControllersFrom` finds controllers.
10
+
11
+ ## 0.2.0 (2026-11-13)
4
12
 
5
13
  - Reads Yarn 1's `yarn.lock` as well as `package-lock.json`.
6
14
  - No longer copies npm packages' stylesheets, fonts and images. Put the directories you use on Propshaft's load path instead.
data/README.md CHANGED
@@ -1,10 +1,4 @@
1
- ```
2
- _ _ _
3
- (_) ___ _ __ _ __ _ _ __ _ (_)| | ___
4
- | |(_-<| '_ \| ' \ ___ | '_|/ _` || || |(_-<
5
- _/ |/__/| .__/|_|_|_||___||_| \__,_||_||_|/__/
6
- |__/ |_|
7
- ```
1
+ <p align="center"><img src="docs/banner.svg" alt="jspm-rails" width="576"></p>
8
2
 
9
3
  [![CI](https://github.com/ClayShentrup/jspm-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/ClayShentrup/jspm-rails/actions/workflows/ci.yml)
10
4
 
@@ -74,6 +68,13 @@ bin/rails jspm:install
74
68
  git add config/importmap.json vendor/jspm
75
69
  ```
76
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
+
77
78
  Reload the page.
78
79
 
79
80
  ## Writing your JavaScript
@@ -95,6 +96,8 @@ import 'controllers' // app/javascript/controllers/index.js
95
96
  import { helper } from './helpers.js'
96
97
  ```
97
98
 
99
+ **Every module in `app/javascript` is in the import map by name,** even ones nothing imports directly, as importmap-rails's `pin_all_from` names them. So stimulus-rails's `eagerLoadControllersFrom("controllers", application)` and `lazyLoadControllersFrom` work unchanged.
100
+
98
101
  **Import modules that gems ship the same way.** Every engine's `app/assets` directories are on Propshaft's load path, so a gem's modules are importable by asset name with no setup:
99
102
 
100
103
  ```js
@@ -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/paths.rb CHANGED
@@ -12,7 +12,8 @@ module Jspm
12
12
  ENTRY_PATH = "#{LOCAL}#{ENTRY}".freeze
13
13
  IMPORT_MAP = 'config/importmap.json'
14
14
  VENDOR = 'vendor/jspm'
15
- public_constant :CDN, :ENTRY, :ENTRY_PATH, :IMPORT_MAP, :LOCAL, :VENDOR
15
+ public_constant :CDN, :ENTRY, :ENTRY_PATH, :IMPORT_MAP, :VENDOR
16
+ private_constant :LOCAL
16
17
 
17
18
  def self.logical(url)
18
19
  return url.delete_prefix('https://').sub('/npm:', '/npm/') if url.start_with?(CDN)
data/lib/jspm/tags.rb CHANGED
@@ -9,7 +9,7 @@ module Jspm
9
9
  # imports name its siblings undigested. So the rendered map also sends each
10
10
  # undigested module URL to its digested one.
11
11
  class Tags
12
- MODULE_EXTENSIONS = %w[.css .js .mjs].freeze
12
+ MODULE_EXTENSIONS = %w[.js .mjs].freeze
13
13
  private_constant :MODULE_EXTENSIONS
14
14
 
15
15
  def self.call(view:)
data/lib/jspm/trace.mjs CHANGED
@@ -8,7 +8,7 @@ import { readFileSync } from 'node:fs';
8
8
  import { createRequire } from 'node:module';
9
9
  import { fileURLToPath, pathToFileURL } from 'node:url';
10
10
 
11
- const { entry, inputMap, resolutions, root } = JSON.parse(readFileSync(0, 'utf8'));
11
+ const { entries, inputMap, resolutions, root } = JSON.parse(readFileSync(0, 'utf8'));
12
12
  const rootUrl = pathToFileURL(`${root}/`);
13
13
  const generatorPath = createRequire(rootUrl).resolve('@jspm/generator');
14
14
  const { Generator } = await import(pathToFileURL(generatorPath));
@@ -37,7 +37,7 @@ const generator = new Generator({
37
37
  resolutions,
38
38
  });
39
39
 
40
- const { dynamicDeps, staticDeps } = await generator.link(entry);
40
+ const { dynamicDeps, staticDeps } = await generator.link(entries);
41
41
  const map = generator.getMap();
42
42
 
43
43
  process.stdout.write(
data/lib/jspm/trace.rb CHANGED
@@ -21,8 +21,14 @@ module Jspm
21
21
  # A package the app installed beats a gem's file of the same name, such
22
22
  # as actiontext's trix.js, so the app and its packages share one copy.
23
23
  pins = local_modules.pins.reject { |name, _path| resolutions.key?(name) }
24
+ # Every app module is traced and named in the map, as importmap-rails
25
+ # pins them, so code can import one by a name it computes, the way
26
+ # stimulus-rails's eagerLoadControllersFrom does.
27
+ app_dir = root.join('app/javascript').to_s
28
+ app_modules = pins.select { |_name, path| path.start_with?(app_dir) }
29
+ .keys
24
30
  input = JSON.generate(
25
- entry: Paths::ENTRY_PATH,
31
+ entries: [Paths::ENTRY_PATH, *app_modules],
26
32
  inputMap: { imports: locked_versions(root).merge(pins), scopes: {} },
27
33
  resolutions:,
28
34
  root: root.to_s
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.2.0'
4
+ VERSION = '0.3.1'
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.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clay Shentrup