[JS] Using Yoga npm version 3.1.0 with Expo/React Native #1738
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Report
I created a Javascript library that uses Yoga and I'm trying to use it in an Expo project, and I see multiple errors related to the Yoga npm package.
Environment:
Windows 11
Running the Android app, although this shouldn't matter
Expo version: "~51.0.28"
React Native version: "0.74.5"
Yoga version: "3.1.0"
Issues and Steps to Reproduce
npx create-expo-app
npm install yoga-layout
import { loadYoga } from "yoga-layout/load";
expo start
Encountered problems
config.resolver.unstable_enablePackageExports = true;
"jsEngine": "jsc"
in app.json and I now get this error: The package at "node_modules\yoga-layout\dist\binaries\yoga-wasm-base64-esm.js" attempted to import the Node standard library module "url". It failed because the native React runtime does not include the Node standard library.Are there any ideas to solve this or any interest in making the npm package work with Expo/React Native? I'm wondering if I should give up on supporting React Native with my Javascript library.
Apart from all the toolchain/esm/emcripten environment detection bits, RN doesn’t support WebAssembly, and we’re no longer distributed asm.js binaries. Asm.js yoga against Hermes was attempted before, but from some earlier bug report I’m having trouble finding, its performance and memory characteristics made it unusable.
This is annoying for making a cross platform library that works everywhere, but for isolated cases where you want to expose Yoga as a JavaScript API, C++ turbo modules could be used to hook a native version of Yoga.
Ah, well I guess that's definitely not going to work. Thanks Nick, I'll close the issue.