Open aurmartin opened 1 week ago
Describe the bug The random module does not work with react-native expo.
I have followed the instructions in the README.md (installed isomorphic-webcrypto and enabled unstable_enablePackageExports).
The isomorphic-webcrypto module isn't resolved correctly.
Error message: TypeError: Cannot read property 'ensureSecure' of undefined, js engine: hermes
TypeError: Cannot read property 'ensureSecure' of undefined, js engine: hermes
Stacktrace:
To Reproduce
npx create-expo-app@latest
import * as random from 'lib0/random'
random.rand()
npx expo start
Expected behavior Lib0 random module works with react-native expo.
Environment Information
Additional context A workaround I have found is to hack the metro resolver:
// Learn more https://docs.expo.io/guides/customizing-metro const { getDefaultConfig } = require("expo/metro-config"); /** @type {import('expo/metro-config').MetroConfig} */ const defaultConfig = getDefaultConfig(__dirname); console.warn("THERE") const config = defaultConfig; config.resolver.unstable_enablePackageExports = true; config.resolver.resolveRequest = (context, moduleName, platform) => { if (platform !== "web" && moduleName === "isomorphic-webcrypto") { return { filePath: __dirname + "/node_modules/isomorphic-webcrypto/src/react-native.js", type: "sourceFile", }; } return context.resolveRequest(context, moduleName, platform); }; module.exports = config;
I also opened a PR with a fix for this issue: https://github.com/dmonad/lib0/pull/94
Describe the bug The random module does not work with react-native expo.
I have followed the instructions in the README.md (installed isomorphic-webcrypto and enabled unstable_enablePackageExports).
The isomorphic-webcrypto module isn't resolved correctly.
Error message:
TypeError: Cannot read property 'ensureSecure' of undefined, js engine: hermes
Stacktrace:
To Reproduce
npx create-expo-app@latest
import * as random from 'lib0/random'
and userandom.rand()
npx expo start
Expected behavior Lib0 random module works with react-native expo.
Environment Information
Additional context A workaround I have found is to hack the metro resolver: