{"data":{"slug":"github-xberg-io-xberg-ai-rulez-skills-wasm-constraints-403bd29248c6","title":"Diagnose WASM Build Constraints","summary":"Identify and resolve constraints for wasm32 builds, including feature limits, sync APIs, and size restrictions.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-wasm-constraints-403bd29248c6","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-ai-rulez-skills-wasm-constraints-403bd29248c6","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-wasm-constraints-403bd29248c6.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-wasm-constraints-403bd29248c6\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"The skill requires understanding of Rust and wasm-bindgen, and familiarity with the `wasm32` target and its limitations such as sync-only APIs and HTML size constraints.","instructions":"---\ntype: Playbook\ntitle: Wasm Constraints\ndescription: \"Diagnose wasm32 builds\/runtime: feature limits, sync APIs and size constraints.\"\npaths:\n  - \"crates\/xberg-wasm\/**\"\n  - \"e2e\/wasm\/**\"\nx-ai-rulez:\n  kind: skill\n  id: wasm-constraints\n  metadata:\n    name: wasm-constraints\n---\n\n# WASM Build Constraints\n\n## Overview\n\nWASM target lives in `crates\/xberg-wasm\/`, built with wasm-bindgen over sync-only internal\nAPIs. Note that `crates\/xberg-wasm\/src\/lib.rs` is Alef-generated \u2014 do not hand-edit it.\n\n## Feature Flags\n\n```toml\n# crates\/xberg\/Cargo.toml\nwasm-target = [\n    \"no-ort-target\",\n    \"excel-wasm\",\n    \"ocr-wasm\",\n    \"layout-tract\",\n    \"auto-rotate-tract\",\n    \"ner-candle-wasm\",\n]\n```\n\nRT-DETR layout detection and PP-LCNet document orientation run through the pure-Rust `tract`\nengine; weights are streamed in from JS, never fetched by Rust (`hf-hub`\/`reqwest` are\nnative-only). Deliberately **no** tree-sitter: the 371-language grammar pack pushes the\nbrowser `.wasm` past jsDelivr's 50 MB per-file cap.\n\n## Critical Constraints\n\n### 1. No Tokio Runtime\n\nAll operations must be synchronous internally. Use `#[cfg(not(feature = \"tokio-runtime\"))]`\npaths.\n\n### 2. Internal Sync Extractor Required\n\nEvery WASM-compatible built-in extractor must implement `SyncExtractor`\n(`crates\/xberg\/src\/extractors\/mod.rs`). It is `pub(crate)`, so only in-crate extractors can\nimplement it \u2014 out-of-crate plugins cannot. This is not part of the public API; public callers\nstill use `extract` \/ `extract_batch`.\n\n```rust\nimpl SyncExtractor for MyExtractor {\n    fn extract_sync(&self, content: &[u8], mime_type: &str, config: &ExtractionConfig)\n        -> Result<InternalDocument> { \/* sync implementation *\/ }\n}\n```\n\nThere is no `as_sync_extractor()` method on `DocumentExtractor` \u2014 do not write one.\n\n### 3. HTML Size Limit\n\n```rust\n\/\/ crates\/xberg\/src\/extraction\/html\/stack_management.rs\npub const MAX_HTML_SIZE_BYTES: usize = 2 * 1024 * 1024;  \/\/ 2 MB \u2014 stack constraint\n```\n\n## Build Config\n\n```toml\n# crates\/xberg-wasm\/Cargo.toml\n[lib]\ncrate-type = [\"cdylib\"]\n\n# root Cargo.toml\n[profile.release.package.xberg-wasm]\nopt-level = \"z\"   # codegen-units = 1 comes from the global [profile.release]\n```\n\n## API Pattern\n\nThe generated surface exposes `async` wasm-bindgen functions over sync internals:\n\n```rust\n#[wasm_bindgen]\npub async fn extract(input: JsValue, config: JsValue) -> Result<WasmExtractionResult, JsValue>\n```\n\nFunctions can be `async` for JS ergonomics; extraction underneath is synchronous.\n\n## Gating\n\n**Gate WASM-specific code** with `#[cfg(target_arch = \"wasm32\")]`, and use the two-arm `cfg_attr` `async_trait` form on any plugin trait impl.\n","use_cases":["Diagnose feature limits in wasm32 builds","Resolve sync API constraints for WASM compatibility","Address size limitations in HTML extraction for WASM"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/.ai-rulez\/skills\/wasm-constraints\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T13:47:27.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Diagnose WASM Build Constraints","seo_description":"Understand and resolve wasm32 build constraints like feature limits, sync APIs, and size restrictions for efficient WASM development.","seo_keywords":["wasm3, build constraints","sync API limitations","HTML size limits in WASM","wasm feature flags","WASM build diagnostics"]}}