Skip to content

Commit 959941b

Browse files
Package Componentized Ruby in npm package
1 parent cc9a19c commit 959941b

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ NPM_PACKAGES = [
2929
name: "ruby-head-wasm-wasi",
3030
ruby_version: "head",
3131
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
32-
target: "wasm32-unknown-wasip1"
32+
target: "wasm32-unknown-wasip1",
33+
enable_component_model: true,
3334
},
3435
{
3536
name: "ruby-3.3-wasm-wasi",

lib/ruby_wasm/packager/core.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ def build(executor, options)
259259

260260
def cache_key(digest)
261261
derive_build.cache_key(digest)
262+
if enabled = @packager.features.support_component_model?
263+
digest << enabled.to_s
264+
end
262265
end
263266

264267
def artifact
@@ -340,6 +343,9 @@ def name
340343
exts = specs_with_extensions.sort
341344
hash = ::Digest::MD5.new
342345
specs_with_extensions.each { |spec, _| hash << spec.full_name }
346+
if enabled = @packager.features.support_component_model?
347+
hash << enabled.to_s
348+
end
343349
exts.empty? ? base : "#{base}-#{hash.hexdigest}"
344350
end
345351
end

rakelib/packaging.rake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ namespace :npm do
7575
*build_command,
7676
"-o",
7777
File.join(dist_dir, "ruby.debug+stdlib.wasm")
78+
if pkg[:enable_component_model]
79+
component_path = File.join(dist_dir, "ruby.component.wasm")
80+
sh env.merge("RUBY_WASM_EXPERIMENTAL_COMPONENT_MODEL" => "1"),
81+
*build_command, "-o", component_path
82+
sh "npx", "jco", "transpile",
83+
"--no-wasi-shim", "--instantiation", "--valid-lifting-optimization", "--tracing",
84+
component_path, "-o", File.join(dist_dir, "component")
85+
end
7886
end
7987
sh wasi_sdk.wasm_opt,
8088
"--strip-debug",

0 commit comments

Comments
 (0)