homura-runtime 0.2.24 → 0.2.25

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: 0e4fc42870cef61572354025f9091524f2b65d91f93910cb3470acd4038472e7
4
- data.tar.gz: b8fafbfe977f2bfa1cbaf42f16f0b2849a3f9f3b0f12525eb2f9809497fa38e2
3
+ metadata.gz: aa815fa7e02b0f798dd69003008576f264eb3a0e2532805a729fee6f4a5aca6b
4
+ data.tar.gz: e8af4871e543adc2ef6c6d8751272111c102987345ea6526ad1fa0e6e2192db8
5
5
  SHA512:
6
- metadata.gz: 3aabb8d2b5678419c57247f834bba6ae02d4de928b154529acf026011cb23c8b08cab01fd95a59b98c74e749b64e86a3f6f4749b6305ab143af54bf5cbc16852
7
- data.tar.gz: 8b71e4b7a2a297aa463b5d68734ca8dc6d88adab156d4bbc9b33e20f7caa58b1fd188c9a4a208fcce83c3df9a57aa2eaf5d18673f4d36cd4d962932dd59a0b97
6
+ metadata.gz: c6f04b2b77f82131dd45148ff7d8467e0093ed005f49269ab2a2a37ab96ad957e6abd264c302331d37a4a95ac84885d9eef3882e51422fec7f6ed2f30aca25b1
7
+ data.tar.gz: ff80cbfcbc5b699eed8c7f79c1da2b40aab678163185b0471ec269c7fe55db06d14515aaa22ece20bbff019ff754bc38d398c3a812ea33a2df3716fbea395716
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.25 (2026-04-29)
4
+
5
+ - `BuildSupport`: factor `opal_gem_paths` out of the path:-only
6
+ `path_gemfile_entries`. The new method also picks up
7
+ RubyGems-installed gems that opt in via
8
+ `spec.metadata['homura.auto_await'] = 'true'`. Without this, a
9
+ RubyGems-installed pure-Ruby gem (e.g. `sinatra-inertia >= 0.1.1`)
10
+ was missing from both the Opal load path and the auto-await pass,
11
+ so `require 'sinatra/inertia'` failed during `homura build`.
12
+ - `homura-build` iterates `opal_gem_paths` instead of the old
13
+ path:-only list, so any opted-in gem (path: or RubyGems) gets the
14
+ same auto-await rewrite.
15
+
3
16
  ## 0.2.24 (2026-04-29)
4
17
 
5
18
  - `BuildSupport.standalone_load_paths`: auto-discover `path:`-resolved
data/exe/homura-build CHANGED
@@ -275,13 +275,14 @@ else
275
275
  warn 'homura build: no app/ directory or top-level app.rb — skipping auto-await'
276
276
  end
277
277
 
278
- # Also run auto-await over any `path:`-resolved gems declared in the
279
- # consumer's Gemfile (e.g. `sinatra-inertia`). The transformed copies
280
- # are written to `build/auto_await/gem_<basename>/<original-relative>`,
281
- # and `standalone_load_paths` puts those directories ahead of the
282
- # untransformed gem `lib/` so `require 'sinatra/inertia'` resolves to
283
- # the rewritten file.
284
- CloudflareWorkers::BuildSupport.path_gemfile_entries(root).each do |gem_path|
278
+ # Also run auto-await over every gem we ship to Opal:
279
+ # `path:`-resolved gems in the consumer Gemfile *and* RubyGems-
280
+ # installed gems that opt in via
281
+ # `spec.metadata['homura.auto_await'] = 'true'`. Both go to
282
+ # `build/auto_await/gem_<basename>/<sub>` and
283
+ # `standalone_load_paths` puts those rewritten copies ahead of the
284
+ # gem's untransformed `lib/`.
285
+ CloudflareWorkers::BuildSupport.opal_gem_paths(root).each do |gem_path|
285
286
  %w[lib].each do |sub|
286
287
  src = gem_path.join(sub)
287
288
  next unless src.directory?
@@ -86,18 +86,19 @@ module CloudflareWorkers
86
86
  end
87
87
  end
88
88
 
89
- # Pick up any other `path:`-resolved gems declared in the consumer's
90
- # Gemfile (e.g. `sinatra-inertia`). This keeps the build pipeline
91
- # extensible: users can drop a pure-Ruby gem under `gems/foo`, list
92
- # it as `gem 'foo', path: '../../gems/foo'`, and Opal will find its
93
- # `lib/` automatically — no homura-runtime change required.
89
+ # Pick up any other gems that should ship in the Workers bundle:
94
90
  #
95
- # We prefer the auto-await-transformed copy under
96
- # `build/auto_await/gem_<basename>/lib` if present (homura-build
97
- # writes one for every path: gem before invoking Opal), so that
98
- # async chains inside the gem get `__await__` inserted just like
99
- # consumer app code.
100
- path_gemfile_entries(root).each do |gem_path|
91
+ # * `path:`-resolved gems in the consumer's Gemfile (monorepo
92
+ # dev mode), and
93
+ # * RubyGems-installed gems that opt in via
94
+ # `spec.metadata['homura.auto_await'] = 'true'`.
95
+ #
96
+ # Both go through the same auto-await pass during `homura-build`,
97
+ # and we prefer the rewritten copy under
98
+ # `build/auto_await/gem_<basename>/lib` if present so async chains
99
+ # inside gem code get `__await__` inserted just like consumer
100
+ # app code.
101
+ opal_gem_paths(root, loaded_specs: loaded_specs).each do |gem_path|
101
102
  basename = gem_path.basename.to_s
102
103
  rewritten_lib = root.join('build', 'auto_await', "gem_#{basename}", 'lib')
103
104
  load_paths << rewritten_lib.to_s if rewritten_lib.directory?
@@ -133,6 +134,31 @@ module CloudflareWorkers
133
134
  vend if vend.directory?
134
135
  end
135
136
 
137
+ # Returns the union of `path_gemfile_entries(project_root)` and any
138
+ # bundled gems that opt in to the Opal pipeline via
139
+ # `spec.metadata['homura.auto_await']`. This is the single source
140
+ # of truth for both `standalone_load_paths` and the auto-await pass
141
+ # that `homura-build` runs. Returns `Pathname` objects pointing at
142
+ # each gem's root directory.
143
+ def opal_gem_paths(project_root, loaded_specs: Gem.loaded_specs)
144
+ wired = [RUNTIME_GEM_NAME, SINATRA_GEM_NAME, SEQUEL_D1_GEM_NAME]
145
+ out = []
146
+ out.concat(path_gemfile_entries(project_root))
147
+
148
+ loaded_specs.each_value do |spec|
149
+ next if wired.include?(spec.name)
150
+ meta = spec.metadata
151
+ next unless meta.is_a?(Hash)
152
+ flag = meta['homura.auto_await']
153
+ next unless flag == 'true' || flag == true
154
+ next if spec.full_gem_path.nil?
155
+ gem_path = Pathname(spec.full_gem_path)
156
+ out << gem_path if gem_path.directory?
157
+ end
158
+
159
+ out.uniq
160
+ end
161
+
136
162
  # Returns absolute Pathnames for every `path:`-declared gem in the
137
163
  # project's Gemfile that should ship in the Workers bundle.
138
164
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudflareWorkers
4
- VERSION = '0.2.24'
4
+ VERSION = '0.2.25'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homura-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.24
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuhiro Homma