How to pass object handle to javascript

I am an absolute new student to rust programming.
I have a successfully working wasm code that is used as a spellcheck. I had written that in C++ and used Emscripten to convert it to JavaScript and to web assembly. This is essentially adaptation to similar code using Hunspell... with one difference. I am keeping the whole dictionary in the code itself. I do that when I send first 'create' call from JavaScript to wasm. In wasm code I initialize a huge data structure (a very large array of vectors) and pass the handle back to JavaScript. When the user enters a word, I call 'suggest' method on this dictionary. and it uses this dictionary and finds suggestions, and sends them back to JavaScript.... This whole thing is working without any problem.
Now I am trying to do this same thing in rust. I am going through docs and mailing lists like this one to get any suggestions. I need to 'build' this dictionary in the first call (or any other way in rust). Get handle to it to JavaScript. Later when the word is written I need to call suggest method on this dictionary to get suggestions.
How should I do it? ... I have tried lazy static to create the dictionary ... but it is creating wasm almost three times bigger than what I had with Emscripten. (For 7 Mb dictionary static embedded data, I was getting about 10Mb wasm code with Emscripten ... but with rust I am getting some 28 Mb!!)
Please help.
Thanks

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.