Skip to content

fix(expo-app): patch hoisted deps and add libsodium-wrappers ESM shim#467

Merged
leeroybrun merged 1 commit intoslopus:mainfrom
happier-dev:slopus/pr/fix-libsodium-wrappers-web
Jan 24, 2026
Merged

fix(expo-app): patch hoisted deps and add libsodium-wrappers ESM shim#467
leeroybrun merged 1 commit intoslopus:mainfrom
happier-dev:slopus/pr/fix-libsodium-wrappers-web

Conversation

@leeroybrun
Copy link
Copy Markdown
Collaborator

Expo web builds can fail at runtime with:
"Unable to resolve module ./libsodium.mjs from .../libsodium-wrappers.mjs"

Root cause:

  • In Yarn workspace installs, libsodium-wrappers is typically hoisted to the repo root.
  • Upstream postinstall runs patch-package from expo-app/, so patches cannot apply to hoisted deps.
  • libsodium-wrappers@0.7.16's ESM wrapper imports ./libsodium.mjs, but that file is not shipped.

Fix:

  • Add expo-app/patches/libsodium-wrappers+0.7.16.patch to provide the missing ESM shim: dist/modules-esm/libsodium.mjs -> export { default } from "libsodium";
  • Replace the naive postinstall with expo-app/tools/postinstall.mjs that:
    • resolves real paths (works when executed via symlinked workspace paths)
    • runs patch-package from the repo root with --patch-dir expo-app/patches so hoisted deps are patched
    • keeps the existing setup-skia-web public step

This makes the Expo web UI build and load again with the monorepo

Expo web builds can fail at runtime with:
  "Unable to resolve module ./libsodium.mjs from .../libsodium-wrappers.mjs"

Root cause:
- In Yarn workspace installs, libsodium-wrappers is typically hoisted to the repo root.
- Upstream postinstall runs `patch-package` from `expo-app/`, so patches cannot apply to hoisted deps.
- libsodium-wrappers@0.7.16's ESM wrapper imports `./libsodium.mjs`, but that file is not shipped.

Fix:
- Add `expo-app/patches/libsodium-wrappers+0.7.16.patch` to provide the missing ESM shim:
  `dist/modules-esm/libsodium.mjs` -> `export { default } from "libsodium";`
- Replace the naive postinstall with `expo-app/tools/postinstall.mjs` that:
  - resolves real paths (works when executed via symlinked workspace paths)
  - runs patch-package from the repo root with `--patch-dir expo-app/patches` so hoisted deps are patched
  - keeps the existing `setup-skia-web public` step

This makes the Expo web UI load reliably in clean environments (including Linux VMs).
@leeroybrun leeroybrun marked this pull request as ready for review January 24, 2026 17:56
@leeroybrun leeroybrun merged commit 320f60a into slopus:main Jan 24, 2026
1 check failed
JoeLuker pushed a commit to JoeLuker/happy that referenced this pull request Feb 1, 2026
…-wrappers-web

fix(expo-app): patch hoisted deps and add libsodium-wrappers ESM shim
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.

1 participant