jspm-rails 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -7
- 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: 2066a105c29bf4cebd19a25c1afa9ac3bfb7530b080cd5f347ed1c69e3cd56b2
|
|
4
|
+
data.tar.gz: 1e89f49cd667a1b7771b90b2df5a8d36918d0cdb78334fe6cdee6d831d470fcc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4253a93277d3368d3e2e34fe023aeee5ac6d74090417941e36056ea65ccffb3f9465909e036ae52a00caa3bb403ef0b3d9ee7e6de26299b0f741487baf11fa30
|
|
7
|
+
data.tar.gz: 330b9d72f4d2b528aa4701d655cc066adf83da4fbfef4f718eb472c624d0398f52542e05ee84b97bfc3b25d4219f227e25ba2f02bc7aab9bd524cefc8ddae6ef
|
data/CHANGELOG.md
CHANGED
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
|
|
|
@@ -95,6 +89,8 @@ import 'controllers' // app/javascript/controllers/index.js
|
|
|
95
89
|
import { helper } from './helpers.js'
|
|
96
90
|
```
|
|
97
91
|
|
|
92
|
+
**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.
|
|
93
|
+
|
|
98
94
|
**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
95
|
|
|
100
96
|
```js
|
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