I don't thinnk expect/actual helps here. The goal of expect/actual is to use
different code on different platforms. But, from what I understand, OP is trying to use the same code.
What I would do is move all the complex code into its own module:
main-code/ β js, JVM
complex-core/ β js, WASM, JVM
The complex module would be compiled for the JVM, JS and WASM. Then, when creating a JVM app, you import the complex module as a normal dependency. However, when creating the JS website, you import the complex module's WASM output as an additional import, like you would import an NPM library.
As a bonus, you can also compile the complex code to JS as a fallback in case the user's browser doesn't support WASM