I found PNPM really good to use. I ended up making a few tweaks. The full set of changes were as follows:
vetkd_utils/Cargo.toml: unchanged from yours
vetkd_utils/package.json:
{
"name": "vetkd-utils",
"private": true,
"scripts": {
"build": "wasm-pack build --target web --release"
},
"module": "pkg/vetkd_utils.js",
"types": "pkg/vetkd_utils.d.ts",
"main": "src/lib.rs" [added this line]
}
vetkd_utils/src/lib.rs:
#[no_mangle]
pub use ic_vetkd_utils::*;
package.json (main) - added:
"dependencies": {
"vetkd-utils": "workspace:*",
...
}
webpack.config.js - added:
module.exports = {
experiments: {
asyncWebAssembly: true,
},
optimization: {
module: {
rules: [
{ test: /\.rs$/, use: [
{loader: 'wasm-loader'},
{loader: 'rust-native-wasm-loader', options: {release: true}}
]},
{ test: /\.wasm$/, type: "webassembly/async",},
]
},
...
}
This made the project deployable, but I then started getting
Uncaught runtime errors:
ERROR
vetkd_utils__WEBPACK_IMPORTED_MODULE_3__.TransportSecretKey is not a constructor
get_aes_256_gcm_key@http://localhost:8080/index.js:24970:15
The line referred to here was
const tsk = TransportSecretKey(seed);
.
Changing it to
const tsk = vetkd_utils.TransportSecretKey(seed);
.
gave
vetkd_utils__WEBPACK_IMPORTED_MODULE_3__.TransportSecretKey is undefined
.
I couldn’t see the problem from looking at the Rust source code. If this worked well for you without making all these changes then I figured it must be an error (or errors) within the numerous small changes I’ve made to the provided code as I’ve been working on this. I can share this whole version of the project if you like but for now I’ve put this aside and am using the vetkd components from examples/motoko/vetkd. Once I have it working it fully I might try switching your method back in.