opal_stimulus 0.1.5 → 0.1.7
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 +11 -0
- data/README.md +2 -6
- data/lib/install/install_opal_stimulus.rb +3 -7
- data/lib/opal_stimulus/railtie.rb +9 -0
- data/lib/opal_stimulus/version.rb +1 -1
- data/lib/opal_stimulus.rb +1 -0
- data/lib/tasks/build.rake +9 -1
- metadata +36 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e71677302b86e4d6f248a98170efd0dd24478c852b53f97747bb840d071cfccf
|
4
|
+
data.tar.gz: 47241b7d3e38b2cefae139cab2f1fb8d4461cd6d591c4303c4eadf0ac84b1dbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0211e443ec8b5a3b214276882807f1f58bd56624a14f345a30a5789783ceb2aca6dd71dd7838d39b4771d89b40d1bd552a0a18a7013b502d5efa98c43b117e19
|
7
|
+
data.tar.gz: 7805082cfc93be9f1906dc4e51e1dea39c6c3872b6646c85a0990d986a27a8dd0183ef35d15ae35e8416ca42f90da46a6c3cf38a09532cb82d78e3baed8757fb
|
data/CHANGELOG.md
CHANGED
@@ -32,3 +32,14 @@
|
|
32
32
|
- Reduce installed new lines for Rails
|
33
33
|
- Skip importmap in production
|
34
34
|
- Add `bin/rails generate opal_stimulus <CONTROLLER_NAME>`, usage: `bin/rails g opal_stimulus -h`
|
35
|
+
|
36
|
+
## [0.1.6] - 2025-08-17
|
37
|
+
|
38
|
+
- Simplify installation importing `application` and `Controller` with ESM
|
39
|
+
Now `app/javascript/controllers/application.js` will be not modified,
|
40
|
+
and only compiled code will be imported inside application layout.
|
41
|
+
|
42
|
+
## [0.1.7] - 2025-08-20
|
43
|
+
|
44
|
+
- Add installation on Rails tests
|
45
|
+
- Make it production ready enhancing `assets:precompile` with `opal_stimulus:build`
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Opal Stimulus for Rails
|
2
2
|
|
3
|
-
**Opal Stimulus** is a Stimulus wrapper made with Opal (a source-to-source Ruby to JavaScript compiler) that allows you to write Stimulus controllers in Ruby instead of JavaScript (It works only with Rails).
|
3
|
+
**Opal Stimulus** is a Stimulus wrapper made with Opal (a source-to-source Ruby to JavaScript compiler) that allows you to write Stimulus controllers in Ruby instead of JavaScript (It works only with Rails >= 7.2 and < 8.0.3).
|
4
4
|
|
5
5
|
[](https://github.com/josephschito/opal_stimulus/actions/workflows/main.yml)
|
6
6
|
|
@@ -28,7 +28,7 @@ bin/dev
|
|
28
28
|
Create a new controller:
|
29
29
|
|
30
30
|
```bash
|
31
|
-
bin/rails opal_stimulus hello
|
31
|
+
bin/rails generate opal_stimulus hello
|
32
32
|
```
|
33
33
|
This command will create `app/opal/controllers/hello_controller.rb`
|
34
34
|
|
@@ -64,10 +64,6 @@ end
|
|
64
64
|
</div>
|
65
65
|
```
|
66
66
|
|
67
|
-
**Result**
|
68
|
-
|
69
|
-
https://github.com/user-attachments/assets/c51ed28c-13d2-4e06-b882-1cc997e9627b
|
70
|
-
|
71
67
|
**Notes:**
|
72
68
|
|
73
69
|
- In general any reference method is snake cased, so `container` target will produce `container_target` and not ~`containerTarget`~
|
@@ -7,7 +7,6 @@ if File.exist? APPLICATION_LAYOUT_PATH
|
|
7
7
|
insert_into_file APPLICATION_LAYOUT_PATH, after: "<%= javascript_importmap_tags %>\n" do
|
8
8
|
<<-ERB
|
9
9
|
<script type="module">
|
10
|
-
import "application"
|
11
10
|
import "<%= javascript_path("opal") %>"
|
12
11
|
</script>
|
13
12
|
ERB
|
@@ -23,13 +22,10 @@ if File.exist? APPLICATION_LAYOUT_PATH
|
|
23
22
|
say "Ensure foreman is installed"
|
24
23
|
run "gem install foreman"
|
25
24
|
end
|
26
|
-
insert_into_file Rails.root.join("app/javascript/controllers/application.js") do
|
27
|
-
<<-JS
|
28
|
-
import { Controller } from "@hotwired/stimulus";
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
manifest = Rails.root.join("app/assets/config/manifest.js")
|
27
|
+
if manifest.exist?
|
28
|
+
append_to_file manifest, "//= link opal.js"
|
33
29
|
end
|
34
30
|
append_to_file ".gitignore", "/.opal-cache\n"
|
35
31
|
append_to_file ".gitignore", "app/assets/builds/opal.js\n"
|
data/lib/opal_stimulus.rb
CHANGED
data/lib/tasks/build.rake
CHANGED
@@ -14,10 +14,15 @@ namespace :opal_stimulus do
|
|
14
14
|
def compile
|
15
15
|
puts "🔨 Compiling Opal..."
|
16
16
|
|
17
|
+
Opal::Config.esm = true
|
17
18
|
builder = Opal::Builder.new
|
18
19
|
result = builder.build("application")
|
19
20
|
output_path = Rails.root.join("app/assets/builds/opal.js")
|
20
|
-
code =
|
21
|
+
code = [
|
22
|
+
"import { application } from 'controllers/application';",
|
23
|
+
"import { Controller } from '@hotwired/stimulus';",
|
24
|
+
result.to_s
|
25
|
+
].join("\n")
|
21
26
|
|
22
27
|
if Rails.env.development?
|
23
28
|
code += "//# sourceMappingURL=/assets/opal.js.map"
|
@@ -51,3 +56,6 @@ namespace :opal_stimulus do
|
|
51
56
|
sleep
|
52
57
|
end
|
53
58
|
end
|
59
|
+
|
60
|
+
Rake::Task.define_task("assets:precompile") unless Rake::Task.task_defined?("assets:precompile")
|
61
|
+
Rake::Task["assets:precompile"].enhance(["opal_stimulus:build"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal_stimulus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Schito
|
@@ -51,6 +51,40 @@ dependencies:
|
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.1.1
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rails
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7.2'
|
61
|
+
- - "<"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 8.0.3
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '7.2'
|
71
|
+
- - "<"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 8.0.3
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: propshaft
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.2'
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.2'
|
54
88
|
description: Opal Stimulus provides a way to write Stimulus controllers in Ruby, leveraging
|
55
89
|
the Opal compiler to convert Ruby code into JavaScript. This allows developers familiar
|
56
90
|
with Ruby to use the Stimulus framework without needing to write JavaScript directly.
|
@@ -74,6 +108,7 @@ files:
|
|
74
108
|
- lib/install/dev
|
75
109
|
- lib/install/install_opal_stimulus.rb
|
76
110
|
- lib/opal_stimulus.rb
|
111
|
+
- lib/opal_stimulus/railtie.rb
|
77
112
|
- lib/opal_stimulus/stimulus_controller.rb
|
78
113
|
- lib/opal_stimulus/version.rb
|
79
114
|
- lib/tasks/build.rake
|