I am aware of JsModule for npm dependencies, however my use case is to call a JS function from my Vue project, in my KotlinJS project.
This very simple use case seems very hard to achieve.
Given a js function a(), I define it as follow:
external fun a(): String
However I have for use case the following worflow:
MyVueApp has a state, it calls a JSexported Kotlin function.
This Kotlin function call the external a().
Since a needs to access the state of the MyVueApp instance, I don’t want to duplicate VueApp into kotlinLib/node_modules. Instead I want the kotlin code to directly reference a() from a path (…/MyVueApp/path/to/a)
doing JsModule(“…path/to/a”) generate the right require.
However it only work if I manually append .default to the generated function call. Is there a way to tell KotlinJs/webpack to set it automatically?
Moreover, is there a way to have the generated kotlin work for simple exports vs export default? And to accept JsModule(“VueApp”) vs a hardcoded full path for each external function?