https://kotlinlang.org logo
Title
d

dwursteisen

04/15/2023, 2:09 PM
👋 I created a Kotlin/JS project (
myProject
) using IntelliJ wizard and I added a npm dependency. When running the gradle task
browserDevelopmentRun
, the webpage is working. I can use the dependency. Everything is working as expected 👍 But if, instead of having everything in the root module of my project, I moving everything in another module of my gradle project (ie:
myProject/myJsApp
), the content of my JS file used by the browser when using the task
myJsApp:browserDevelopmentRun
is different. When it’s working, the javascript generated file start with an UMD definition (
webpackUniversalModuleDefinition
) while when it’s not working, it’s another code, which, I believe, is trying to use a loader system. My though is that in the first case, the creation of the Javascript application is working as expected while is the second case, it’s like a javascript lib that is created (but I configured
*binaries*.executable()
). I check the documentation, this slack, and also the Kotlin Youtrack without finding something about that. Is that a limitation of Kotlin/JS or is it expected? Thanks 🙂
(I’m using Kotlin 1.8.20 ; I tried Kotlin 1.7.20. The javascript is not generated in the second case.)
m

Mike Dawson

04/16/2023, 8:33 AM
I am using a multimodule design - (e.g. shared multiplatform core module, a shared data entities module, and an app-react JS only module where the executable application lives). It's definitely not a limitation from Kotlin's side. The Gradle config can definitely be tricky to understand when starting... In case it helps, you can check out our Gradle structure ( https://github.com/UstadMobile/UstadMobile/tree/dev-mvvm-primary )
d

dwursteisen

04/16/2023, 3:54 PM
Thanks! I didn’t found a big difference with what I did. (So it might be a issue on my side 😄 ) I think I might have found the issue and it’s a bit stupid. I created a module called
submodule
. In my index.html, I using the javascript file
myProject-submodule.js
That’s the mistake. Even if the file exist, it’s not the one I need to use. I spend a bit of time reading the webpack documentation. In the
webpack.config.js
, the name of the bundle is
submodule.js
So using
submodule.js
instead of `myProject-submdule.js`fix the issue. 😬 I got a bit fooled because I didn’t saw
submodule.js
on my disk.
t

turansky

04/16/2023, 4:29 PM
You can use
moduleName
property in configuration to have constant file name