What you can have is for each version of the library (the JS and JVM version) have a different implementation for the class that provides access to the concrete implementation for that platform. Basically you would have 3 source roots. One for the JVM, one for JS and one shared. You want to minimize the platform specific ones, but can put classes in there that have different implementations on both platforms.
Btw. There is one issue if you do this in Intellij. It assumes that every source file is only part of one source module (it doesn't like sharing), symlinks are resolved so will not solve the problem, but automatic copying of shared code "works" as long as you take care to have intellij see it as generated (to help you not to edit it and have the edits overwritten).
Of course proper support would be better.