bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
86 stars 55 forks source link

After bumping ReactNative project from 1.1.6 to 2.0.0 builds for Android fail #91

Closed Overtorment closed 1 year ago

Overtorment commented 1 year ago
warning: the transform cache was reset.
                    Welcome to Metro!
              Fast - Scalable - Integrated

error Unable to resolve module ./secp256k1.wasm from /home/ghost/Documents/BlueWallet/node_modules/tiny-secp256k1/lib/wasm_loader.browser.js: ./secp256k1.wasm could not be found within the project or in these directories:
Error: Unable to resolve module ./secp256k1.wasm from /home/ghost/Documents/BlueWallet/node_modules/tiny-secp256k1/lib/wasm_loader.browser.js: ./secp256k1.wasm could not be found within the project or in these directories:
  node_modules
  node_modules

If you are sure the module exists, try these steps:
If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
 4. Remove the cache: rm -rf /tmp/metro-*
> 1 | // Suppress TS2792: Cannot find module './secp256k1.wasm'.
> 1 | // Suppress TS2792: Cannot find module './secp256k1.wasm'.
    |                                         ^
    |                                         ^
  2 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  2 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  3 | // @ts-ignore
  3 | // @ts-ignore
  4 | import * as wasm from "./secp256k1.wasm";
  4 | import * as wasm from "./secp256k1.wasm";.
    at ModuleResolver.resolveDependency (/home/ghost/Documents/BlueWallet/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:129:15)
    at DependencyGraph.resolveDependency (/home/ghost/Documents/BlueWallet/node_modules/metro/src/node-haste/DependencyGraph.js:288:43)
    at Object.resolve (/home/ghost/Documents/BlueWallet/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/home/ghost/Documents/BlueWallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /home/ghost/Documents/BlueWallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/home/ghost/Documents/BlueWallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/home/ghost/Documents/BlueWallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async addDependency (/home/ghost/Documents/BlueWallet/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
info Run CLI with --verbose flag for more details.

> Task :app:bundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

image

I looked through closed issues, and saw mentions of webpack & asyncWebAssembly for ReactNative, but iirc RN switched its bundler to Metro some time ago.

Relevant PR: https://github.com/BlueWallet/BlueWallet/pull/5048

Overtorment commented 1 year ago

ok i bumped to 2.2.1 and the error is

error While trying to resolve module `tiny-secp256k1` from file `/home/ghost/Documents/BlueWallet/class/wallets/segwit-bech32-wallet.js`, the package `/home/ghost/Documents/BlueWallet/node_modules/tiny-secp256k1/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/home/ghost/Documents/BlueWallet/node_modules/tiny-secp256k1/lib/cjs/index.cjs`. Indeed, none of these files exist:

  * /home/ghost/Documents/BlueWallet/node_modules/tiny-secp256k1/lib/cjs/index.cjs(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

and i think i saw a solution for that in one of the closed issues. lemme go throught them and i will get back to you...

junderw commented 1 year ago

Does react Native support WASM?

junderw commented 1 year ago

Or is this Android only?

iOS builds? I wonder why... React Native supports WASM only with iOS builds?...? That doesn't make much sense...

Overtorment commented 1 year ago

yeah i didnt look, apparently both builds failed. i applied a fix from https://github.com/facebook/metro/issues/815#issuecomment-1117607661 now it builds, but build crashes immediately after launch

Overtorment commented 1 year ago

RN doesnt support wasm afaik

junderw commented 1 year ago

Yeah, just stay on the old libraries for now.