Just a beginner writing a very simple rust program to build a lib
pub use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct SomeStruct {
}
#[wasm_bindgen]
impl SomeStruct {
#[wasm_bindgen(constructor)]
pub fn new() -> SomeStruct {
SomeStruct { }
}
pub fn print_text() {
println!("Text to Print");
}
}
index.js
import { SomeStruct } from './pkg';
document.write(print_text());
when running
npm run serve
getting
Uncaught runtime errors:
ERROR
print_text is not defined
ReferenceError: print_text is not defined
at eval (webpack:///./index.js?:7:10)
I’m new to both Rust and JS, and can’t understand exactly where I am missing
In pkg folder, I have files with following names
index.d
index.js
index_bg.js
index_bg.wasm
index_bg.wasm.d
package