Skip to content

fix: reject unsupported wasm targets at the package boundary - #24

Merged
oboard merged 1 commit into
mainfrom
fix/remove-wasm-stubs
Aug 21, 2026
Merged

fix: reject unsupported wasm targets at the package boundary#24
oboard merged 1 commit into
mainfrom
fix/remove-wasm-stubs

Conversation

@oboard

@oboard oboard commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Problem

At main@c545db2, the README states Mocket supports the JS and native backends, but moon.pkg still selects mocket.wasm.mbt and serve.mbt for wasm/wasm-gc. As a result, server code using Mocket::listen type-checks for those targets and then traps at runtime:

moon check <package> --target wasm    # succeeds
moon run <package> --target wasm
# RuntimeError: unreachable
#   at @oboard/mocket.listen_ffi
#   at @oboard/mocket.Mocket::listen

Fix

Two complementary changes:

  1. Delete mocket.wasm.mbt — the file that contained panic stubs (serve_ffi, listen_ffi, and all ws_* stubs that always panic). Remove its target entries from moon.pkg.

  2. Declare the package's actual backend support at the top level of moon.pkg:

supported_targets = "+js+native"

This makes moon check/moon build reject wasm and wasm-gc consumers at the package boundary, matching the README and avoiding runtime-only panic stubs.

The cors and static_file sub-packages depend on oboard/mocket and are likewise js/native-only, so they now declare supported_targets explicitly (this also removes the "does not declare supported_targets" warnings they would otherwise emit once the parent package declares its targets).

Files changed

File Change
mocket.wasm.mbt deleted (43 lines of panic stubs)
moon.pkg Removed wasm target entries; added supported_targets = "+js+native"
cors/moon.pkg Added supported_targets = "+js+native"
static_file/moon.pkg Added supported_targets = "+js+native"

Verification

  • moon check --target wasm on a wasm consumer that calls Mocket::listenfails at build time:
    Selected backend 'wasm' is incompatible with the dependency graph. '...' requires 'oboard/mocket' which supports [js, native].
    
  • moon check --target wasm-gc → same rejection
  • moon check --target js and --target native → pass cleanly
  • moon check --target all → finishes with no warnings

🤖 Generated with Claude Code

Delete mocket.wasm.mbt (panic stubs for serve_ffi/listen_ffi) and remove
its target entries from moon.pkg. Declare supported_targets = "+js+native"
at the package boundary so wasm/wasm-gc consumers are rejected at build
time instead of trapping at runtime.

Also declare supported_targets on cors and static_file sub-packages to
keep the dependency graph consistent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oboard
oboard merged commit b9a2555 into main Aug 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant