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 +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +10 -7
- data/lib/jspm/local_modules.rb +1 -1
- data/lib/jspm/paths.rb +2 -1
- data/lib/jspm/tags.rb +1 -1
- data/lib/jspm/trace.mjs +2 -2
- data/lib/jspm/trace.rb +7 -1
- data/lib/jspm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3608db3097cfd0de48ed40b816957df33790b6ba25e2ead331237692b175209f
|
|
4
|
+
data.tar.gz: feadecec7f5fc18155a442608d768a89b0224d9a105e15b6ff9bdbdf334fcff9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbcdb2e923538ff68863b7137a6ff7386f50cc1382dd24580c8ec7b8e866fe1d66ffb8949d10d1e70fb3c7a120511a20ea4918f0bf3a9f0754e8842732a7721c
|
|
7
|
+
data.tar.gz: 40f8b42545b0609e73389d13e02aee7c7ebe6617ac3057d42e4f98d6b78ab52adf161b2c112b60ebaf42f808514a14c91286be334fef2c9ab5c817330f9af8d3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
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
|
[](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
|
data/lib/jspm/local_modules.rb
CHANGED
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, :
|
|
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[.
|
|
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 {
|
|
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(
|
|
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
|
-
|
|
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