# How to import local JS functions into Kotlin JS?

**URL:** <https://discuss.kotlinlang.org/t/how-to-import-local-js-functions-into-kotlin-js/23602>\
**Category:** JavaScript\
**Created:** [December 6, 2021, 3:15pm UTC](https://discuss.kotlinlang.org/t/how-to-import-local-js-functions-into-kotlin-js/23602 "2021-12-06T15:15:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LifeIsStrange](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@LifeIsStrange](https://discuss.kotlinlang.org/u/LifeIsStrange)\
**Post date:** [December 6, 2021, 3:15pm UTC](https://discuss.kotlinlang.org/t/how-to-import-local-js-functions-into-kotlin-js/23602/1 "2021-12-06T15:15:44Z")

</div>

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:

@JsModule(“VueApp”)  
@JsNonModule  
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?
