Harzu / wasm-rsa

rsa library with webAssembly rust implementation - https://harzu.github.io/wasm-rsa/
MIT License
17 stars 0 forks source link

Can not resolve dependency './rsa_lib_bg' - Issue with using Parcel #13

Open harunoz opened 3 years ago

harunoz commented 3 years ago

Hello I am trying to use wasm-rsa on my web application. I am using parcel to use this module.

app.js

import RSASetup from 'wasm-rsa'

// First peer
const rsaPeerOne = RSASetup()
const privateKeys = rsaPeerOne.generateRSAPrivate(1024)
const signature = rsaPeerOne.signMessage('Hello')

// Second peer
const rsaPeerTwo = RSASetup()
const publicKeys = rsaPeerTwo.createRSAPublic(privateN, privateE)
const verify = rsaPeerTwo.verify('Hello', signature)

if (verify) {
  console.log('verify success')
}
else{
    console.log('a');
}

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Parcel Demo 01</title>
</head>
<body>
    <div id="message"></div>
    <script src="./app.js" type="text/javascript" ></script>
    <button id="but">Click</button>
</body>

</html>

Problem

When I run the parcel index.html command I am getting following error:

Server running at http://localhost:63418 - configured port 1234 could not be used.
🚨  /Users/harunoz/Desktop/testRsa/node_modules/wasm-rsa/wasm/browser/rsa_lib.js:2:22: Cannot resolve dependency './rsa_lib_bg' at '/Users/harunoz/Desktop/testRsa/node_modules/wasm-rsa/wasm/browser/rsa_lib_bg'
  1 | /* tslint:disable */
> 2 | import * as wasm from './rsa_lib_bg';
    |                      ^
  3 | 
  4 | let cachedTextEncoder = new TextEncoder('utf-8');

How can I build this with parcel?

Thanks for your help!

Harzu commented 3 years ago

@harunoz Hello =) I'm sorry. I didn't notice the issue right away

When i researched build a wasm module with any build managers. I couldn't build a lib with the parcel and rollup builders. If you want help me to resolve the problem, let me know please. I will be grateful any help.

I going to try build again. if i succeed then i going to write example