Skip to content

fix: remove unused ubrn WASM scaffolding - #727

Open
bl0nnn wants to merge 2 commits into
zkmopro:mainfrom
bl0nnn:fix-rn-stale-wasm
Open

fix: remove unused ubrn WASM scaffolding#727
bl0nnn wants to merge 2 commits into
zkmopro:mainfrom
bl0nnn:fix-rn-stale-wasm

Conversation

@bl0nnn

@bl0nnn bl0nnn commented Aug 31, 2026

Copy link
Copy Markdown

Summary

npm install/run android's prepare: bob build step fails after rebuilding and updating the react-native app bindings because of a stale rn-web template index.web.ts that tries to import missing src/generated/wasm-bindgen/ which is never a target in Mopro (ubrn web build never runs).

This only happens if we build Noir rn android targets since the solution you guys adopted on zig linker dropping the .symtab is to run ubrn generate all <lib>.so --flavor jsi on an NDK linked android lib to extract UniFFI metadata. This solution works fine but generate all with no specified platform will still render both JSI and WASM templates, --flavor jsi only tells ubrn how the UniFFI TS/C++ from the .so is written.

This problem was already cited and semi-solved in cli/src/create/react_native.rs

/// The downloaded `zkmopro/react-native-app` scaffold ships a static
/// `src/index.web.ts` (for optional web/wasm support) that imports from
/// `./generated/wasm-bindgen/index.js` and `index_bg.wasm`. `mopro build` never
/// generates that `generated/wasm-bindgen` directory — React Native builds only
/// target iOS/Android — so the file is always a dangling reference. Since
/// `copy_dir` only overwrites files present in the built bindings dir, it can't
/// remove this pre-existing one; left in place, it breaks `npm install`'s
/// `prepare: bob build` step (`tsc` fails to resolve the missing module).
fn remove_stale_web_entrypoint(mopro_module_dir: &std::path::Path) -> Result<()> {
    let index_web_ts = mopro_module_dir.join("src").join("index.web.ts");
    if index_web_ts.exists() {
        fs::remove_file(&index_web_ts)?;
    }
    Ok(())
}

But this solution is temporary and only covers the template creation step by correctly removing index.web.ts (it also still leaves other junk like the wasm crate in rust_modules dir). Once we update the bindings of the app, index.web.ts and the warm crate will appear again in the app bindings dir, leading to the same error we discussed until now.

Fix

To properly and definitely fix this I simply added a public helper in mopro-ffi/src/app_config/react_native.rs to be shared by both react_native_noir.rs and create/react_native.rs. To manage the removal of all the wasm glue, both index.web.ts and rust_modules/wasm, this helper gets called after the noir rn android build during mopro build and after the copying of the bindings in rn template during mopro create

note: I put the helper in mopro-ffi's react_native.rs file since it is how create and build share rn dir cleanup.

Summary by CodeRabbit

  • Bug Fixes
    • React Native Noir builds now automatically remove unrequested WebAssembly stubs from generated bindings.
    • React Native project creation now cleans up unused web entry points and WebAssembly modules.
    • Generated React Native bindings are now more consistent across build and project creation workflows.
    • Prevents unnecessary web-related files from being included in React Native projects.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 435c682f-2590-48d6-b957-d1b301f0979f

📥 Commits

Reviewing files that changed from the base of the PR and between b2f39a7 and 04f6aa8.

📒 Files selected for processing (2)
  • cli/src/create/react_native.rs
  • mopro-ffi/src/app_config/react_native.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • mopro-ffi/src/app_config/react_native.rs
  • cli/src/create/react_native.rs

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a shared React Native cleanup helper. The create flow uses it instead of local web entrypoint cleanup. The Noir build flow calls it after React Native bindings generation.

Changes

React Native cleanup

Layer / File(s) Summary
Shared scaffolding cleanup helper
mopro-ffi/src/app_config/react_native.rs
Adds remove_unrequested_wasm_stubs, which removes src/index.web.ts and rust_modules/wasm/ when present.
Create and build workflow integration
cli/src/create/react_native.rs, cli/src/build/react_native_noir.rs
The create and Noir build flows invoke the shared helper. The create flow removes its local cleanup helper.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 04f6a

The change removes stale web/WASM artifacts that can break React Native installation and build preparation; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removing unused ubrn WASM scaffolding from React Native builds and template creation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@moven0831 moven0831 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, the PR looks good to me. It's ready to be merged once the cargo fmt is fixed.

Thanks for the contribution!

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.

2 participants