TX032

Yoga's WebAssembly failed to load

Console

Text.js error TX032: Could not load Yoga's WebAssembly from … (…).

Why this happens

initYoga() loads Yoga's WebAssembly from a .wasm file in Text.js apps (text dev, text build), in builds that set the @textjs/wasm-asset resolve condition, and when you pass initYoga({ wasm }). The request failed, returned an error status, or what came back wasn't valid WebAssembly. The error names the URL and the Content-Type the server sent. The usual causes are a server that answers the .wasm URL with an HTML fallback page, and a Content Security Policy without 'wasm-unsafe-eval' in script-src.

How to fix it

Make the URL from the error return the file, with Content-Type: application/wasm so it compiles while it downloads. A rewrite that serves index.html for unknown paths has to skip /assets/. Allow WebAssembly in your Content Security Policy:

Content-Security-Policy: script-src 'self' 'wasm-unsafe-eval'; connect-src 'self'

If you mount the console yourself and serve the file from somewhere else, call initYoga() with its URL, its bytes or a compiled WebAssembly.Module before createConsoleRoot(). Only the first call loads Yoga:

import { initYoga } from "@textjs/core";await initYoga({ wasm: "/yoga.wasm" });

See WebAssembly.