codegen: drop generate_wasm + emit single wasm-compat types.rs #114

Merged
timur merged 1 commit from drop-wasm-emission into development 2026-05-21 12:39:43 +00:00
Owner

Per the maintainer: there should be no separate WASM types file. The generated types.rs is wasm-compatible by construction; OSIS storage impls live in a sibling cfg-gated file. No generate_wasm flag, no opt-in dance, no dead-weight second file ever.

Architecture

Before:

generated/types.rs        # uses hero_rpc_osis::* + #[derive(OsisObject)]
generated/types_wasm.rs   # parallel self-contained version, opt-in

After:

generated/types.rs        # ONLY uses serde + herolib_sid + herolib_otoml
                          # (wasm-compatible — no hero_rpc_osis imports)
generated/osis_impl.rs    # #![cfg(not(target_arch = "wasm32"))]
                          # manual `impl OsisObject for X` per root object

herolib_sid and herolib_otoml are themselves wasm-compatible (no tokio / I/O / native-only deps), so the type definitions compile cleanly to wasm32. The OSIS storage trait machinery only lives in the cfg-gated sibling, so it disappears on wasm32 builds.

Changes

  • Remove OschemaBuildConfig::generate_wasm field + with_wasm() setter.
  • Remove Generator::generate_wasm field + wasm() setter.
  • Remove the builder wiring (if config.generate_wasm).
  • Remove crate::generate::wasm_build_script (long unused per its own module docstring).
  • Drop the dual-emission path in generate/rust_types.rs: write only types.rs (now wasm-compat), plus the new osis_impl.rs.
  • Drop the pub mod types_wasm; + pub use generated::types_wasm::*; cfg branches from both the generated barrel and the scaffolded parent mod.rs.
  • Add crate::rust::generate_osis_impl_block(&Schema) — emits the manual impl OsisObject block (same shape #[derive(OsisObject)] would expand to). Honours @index markers. Returns None when the schema has no root objects.
  • Update rust_struct.rs::generate_rust_structs to: import OTOML built-ins from herolib_otoml (not hero_rpc_osis::otoml::*); drop #[derive(OsisObject)] from the struct definition.
  • Update build/layout.rs::generate_domain_mod_flat to emit a single mod types; pub use types::*; block (no cfg-gates).
  • Scaffolder Cargo.toml template adds herolib_otoml to the core crate's dependencies.
  • recipe_server's src/recipes/mod.rs + crates/hero_recipes/Cargo.toml + build.rs updated in-tree to match.
  • Stale crates/osis/examples/basic/code/src/core/app/mod.rs cfg-routing cleaned up.
  • Walkthrough demo's leftover .with_wasm() comment removed.

Test plan

  • 138/138 generator lib tests pass.
  • Full cargo test --workspace --lib passes (302 lib tests across the workspace).
  • cargo build --manifest-path examples/recipe_server/Cargo.toml completes clean — every workspace member compiles.
  • cargo run --example 01_walkthrough completes all six steps; demo dir has one types.rs plus cfg-gated osis_impl.rs, no types_wasm.rs anywhere.
Per the maintainer: there should be no separate WASM types file. The generated `types.rs` is wasm-compatible *by construction*; OSIS storage impls live in a sibling cfg-gated file. No `generate_wasm` flag, no opt-in dance, no dead-weight second file ever. ## Architecture **Before:** ``` generated/types.rs # uses hero_rpc_osis::* + #[derive(OsisObject)] generated/types_wasm.rs # parallel self-contained version, opt-in ``` **After:** ``` generated/types.rs # ONLY uses serde + herolib_sid + herolib_otoml # (wasm-compatible — no hero_rpc_osis imports) generated/osis_impl.rs # #![cfg(not(target_arch = "wasm32"))] # manual `impl OsisObject for X` per root object ``` `herolib_sid` and `herolib_otoml` are themselves wasm-compatible (no tokio / I/O / native-only deps), so the type definitions compile cleanly to wasm32. The OSIS storage trait machinery only lives in the cfg-gated sibling, so it disappears on wasm32 builds. ## Changes - Remove `OschemaBuildConfig::generate_wasm` field + `with_wasm()` setter. - Remove `Generator::generate_wasm` field + `wasm()` setter. - Remove the builder wiring (`if config.generate_wasm`). - Remove `crate::generate::wasm_build_script` (long unused per its own module docstring). - Drop the dual-emission path in `generate/rust_types.rs`: write only `types.rs` (now wasm-compat), plus the new `osis_impl.rs`. - Drop the `pub mod types_wasm;` + `pub use generated::types_wasm::*;` cfg branches from both the generated barrel and the scaffolded parent `mod.rs`. - Add `crate::rust::generate_osis_impl_block(&Schema)` — emits the manual `impl OsisObject` block (same shape `#[derive(OsisObject)]` would expand to). Honours `@index` markers. Returns `None` when the schema has no root objects. - Update `rust_struct.rs::generate_rust_structs` to: import OTOML built-ins from `herolib_otoml` (not `hero_rpc_osis::otoml::*`); drop `#[derive(OsisObject)]` from the struct definition. - Update `build/layout.rs::generate_domain_mod_flat` to emit a single `mod types; pub use types::*;` block (no cfg-gates). - Scaffolder Cargo.toml template adds `herolib_otoml` to the core crate's dependencies. - recipe_server's `src/recipes/mod.rs` + `crates/hero_recipes/Cargo.toml` + `build.rs` updated in-tree to match. - Stale `crates/osis/examples/basic/code/src/core/app/mod.rs` cfg-routing cleaned up. - Walkthrough demo's leftover `.with_wasm()` comment removed. ## Test plan - [x] 138/138 generator lib tests pass. - [x] Full `cargo test --workspace --lib` passes (302 lib tests across the workspace). - [x] `cargo build --manifest-path examples/recipe_server/Cargo.toml` completes clean — every workspace member compiles. - [x] `cargo run --example 01_walkthrough` completes all six steps; demo dir has one `types.rs` plus cfg-gated `osis_impl.rs`, no `types_wasm.rs` anywhere.
codegen: drop generate_wasm + emit single wasm-compat types.rs
Some checks failed
Test / test (push) Failing after 2m14s
Test / test (pull_request) Failing after 2m14s
e46f73f42b
Per the maintainer: there should be no separate WASM types file. The
generated `types.rs` is wasm-compatible *by construction*; OSIS storage
impls live in a sibling cfg-gated file. No `generate_wasm` flag, no
opt-in dance, no dead-weight second file ever.

## Architecture

Before:

  generated/types.rs        # uses hero_rpc_osis::* + #[derive(OsisObject)]
  generated/types_wasm.rs   # parallel self-contained version, opt-in

After:

  generated/types.rs        # ONLY uses serde + herolib_sid + herolib_otoml
                            # (wasm-compatible — no hero_rpc_osis imports)
  generated/osis_impl.rs    # `#![cfg(not(target_arch = "wasm32"))]`
                            # manual `impl OsisObject for X` per root object

`herolib_sid` and `herolib_otoml` are themselves wasm-compatible (no
tokio / I/O / native-only deps), so the type definitions compile cleanly
to wasm32. The OSIS storage trait machinery only lives in the cfg-gated
sibling, so it disappears on wasm32 builds.

## Changes

- Remove `OschemaBuildConfig::generate_wasm` field + `with_wasm()` setter.
- Remove `Generator::generate_wasm` field + `wasm()` setter.
- Remove the builder wiring (`if config.generate_wasm`).
- Remove `crate::generate::wasm_build_script` (long unused per its own
  module docstring).
- Drop the dual-emission path in `generate/rust_types.rs`: write only
  `types.rs` (now wasm-compat), plus the new `osis_impl.rs`.
- Drop the `pub mod types_wasm;` + `pub use generated::types_wasm::*;`
  cfg branches from both the generated barrel and the scaffolded parent
  `mod.rs`.
- Add `crate::rust::generate_osis_impl_block(&Schema)` — emits the
  manual `impl OsisObject` block (same shape `#[derive(OsisObject)]`
  expanded to). Honours `@index` markers via `indexed_fields()` and
  `indexed_field_names()`. Returns `None` when the schema has no root
  objects (no file to write).
- Update `rust_struct.rs::generate_rust_structs` to:
  - Import OTOML built-ins from `herolib_otoml` (not `hero_rpc_osis::otoml::*`).
  - Drop `#[derive(OsisObject)]` from the struct definition.
- Update `build/layout.rs::generate_domain_mod_flat` to emit a single
  `mod types; pub use types::*;` block (no cfg-gates).
- Scaffolder Cargo.toml template adds `herolib_otoml` to the core crate's
  dependencies (it's referenced directly in the emitted `types.rs`).
- Recipe server's `src/recipes/mod.rs` + `crates/hero_recipes/Cargo.toml`
  + `build.rs` updated in-tree to match the new layout.
- Stale `crates/osis/examples/basic/code/src/core/app/mod.rs` cfg-routing
  cleaned up.
- Walkthrough demo's leftover `.with_wasm()` comment removed.

## Tests

- One generator unit test (`test_otoml_types`) had an `assert!(contains
  "hero_rpc_osis::otoml::"`)` — updated to `herolib_otoml::`.
- 138/138 generator lib tests pass.
- Full `cargo test --workspace --lib` passes (302 lib tests across the
  workspace).
- `cargo build --manifest-path examples/recipe_server/Cargo.toml`
  completes clean — every workspace member compiles.
- `cargo run --example 01_walkthrough` still completes all six steps;
  the demo dir contains a single `types.rs` plus the cfg-gated
  `osis_impl.rs`, no `types_wasm.rs` anywhere.
timur merged commit 2aeee22636 into development 2026-05-21 12:39:43 +00:00
timur deleted branch drop-wasm-emission 2026-05-21 12:39:44 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_rpc!114
No description provided.