-
Notifications
You must be signed in to change notification settings - Fork 13
Usage with webpack (create-react-app) #48
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi You are not supposed to copy the WASM file, this package consists of more code. Just add the
There is a demo project in this repo, see some example code here: https://github.com/digitalbitbox/bitbox-api-rs/blob/5681d82d9ce4f6350c5b889fe89fc2e9cd6b16bc/sandbox/src/App.tsx |
Thanks for the response and sorry, I expressed myself badly. I had done exactly what you suggest, installed the package via npm and imported it. On usage I however get the mentioned error. And when I run the build, WebPack copies the WASM file to the dist folder (under |
Is your project open source? If so, could you paste a link to a branch where you run into this issue? If not, would it be easy for you to create a minimal webpack project to reproduce? |
Thanks for the links @thisconnect, I had also tried these suggestions but they didn't work. I have now seen that these suggestions only work for older versions of create-react-app (CRA), because WebPack seems to have changed the way it loads modules (see https://v4.webpack.js.org/loaders/file-loader/). For CRA 5 I found a working example here https://github.com/ivanschuetz/wasm-cra5-rewired. Maybe you can somehow include this in your documentation 😉 Thanks for your help, @benma and @thisconnect! Closing this issue. |
@davidleomay the linked project is not using webpack it seems. The sandbox demo app in this repo is also React and builds fine, using Vite. This is part of the docs already. Is that sufficient? |
@benma the project uses How about changing the title of this issue from |
I'd appreciate if you @thisconnect or @davidleomay could make a PR for the needed changes in the docs, I don't think I get it enough to do it justice :) |
For non-CRA WebPack projects there might be easier/other solutions. I can add a dedicated section for CRA (which still seems to be the recommended way to setup a React projects). |
@davidleomay creact-react-app is not recommended anymore, it is not maintained. facebook/create-react-app#13072 https://dev.to/ag2byte/create-react-app-is-officially-dead-h7o It's also not listed on https://react.dev/. Thought the whole thing is not very well documented by React unfortunately. |
@benma, my fault, you're right, I must have looked into an outdated documentation. |
I tried to use the library in a React app and added the required WebPack config but I still get an error when using it (
wasm.bitbox02ConnectWebHID is not a function
). The WASM file is copied to thestatic/media
folder during build.Am I missing something?
The text was updated successfully, but these errors were encountered: