When building the JVM everything works, but for the JS it expects the module bitvector:
if (typeof bitvector === 'undefined') {
throw new Error("Error loading module 'common'. Its dependency 'bitvector' was not found. Please, check whether 'bitvector' is loaded prior to 'common'.");
}
I know it is part of the JAR file of net.onedaybeard.bitvector:bitvector-js:0.1.4 but what do I need to do to transfer the dependencies to the node_modules of my own library?
I think this should be obtained by doing a Gradle task, but unsure of how to do this.
EDIT
Just when I posted this I saw in build/js/packages_imported/bitvector/0.1.4 the JS files. However, I donāt know if it is the correct way to get it from there?
The dependency management on K/JS multiplatform is a bit messy, you have two possible ways, either use the nodejs plugin to create a task that will install the dependencies or use a plain old gradle task that will take your dependencies from maven and copy them in the folder manually.
I usually do the first one but you might end up doing the second if your dep is not on the NPM registry.
Option 2 looks a bit like this, assuming your JS module name is ājsDafaultā:
task copyDepIntoModules(type: Copy, dependsOn: [configurations.jsDefault]){
outputs.upToDateWhen {false}
from {
configurations.jsDefault.filter{ it.path.contains("theDependencyToCopy") }.collect { zipTree(it) }
}
into "theDirectoryOfYourNodeProject/node_modules"
}
This task will extract the given dependency from the maven dependencies and copy it to the directory of your choosing. Itās not the most elegant way of doing it but I struggled a lot with it and didnāt find the motivation to enhance it.