How to make one js module depend on other js modul...
# javascript
l
How to make one js module depend on other js module? Should I use kotlin-frontend-plugin ? I am getting
Kotlin.defineModule is not a function
. Both is commonjs
a
That is more likely a configuration problem. Kotlin.defineModule is marker function, which doesn't really do anything. It is only used at compile time as a hint for the inliner.
Are you using DCE by any chance?
Sometimes this happens when you use DCE'd kotlin.js with a development module.
So if you are I would suggest switching is off, clearing the caches and trying again. If it works you could take from there and figure out how to apply it correctly.
l
I used it in child module. Switch off helps
Now I have
Can't locate default serializer for class class
(this is kotlin serialization) But... switching of dce is not nice)
a
I am not suggesting switching it on entirely. Just make sure that it's output is not used for development. You are only supposed to run it once on the whole application. DCE results are not supposed to be used as a library or a runtime dependency - it cuts out too much. The only set of files guaranteed to work together after DCE pass is the set of files it produces. You can bundle those with webpack, process with uglify, etc.
j
It would be great if the examples in the frontend repo were updated to show this. I'm also struggling with this problem in development. I can see the DCE's web.js doesn't have this function call, but the one webpack is using for development in does.
So the problem looks like webpack.config.js points at the DCE'd libraries no matter what and I don't know if there's a way to override those paths to the un-DCE'd versions only for the dev server.