I’m trying to build a kotlin project which is supposed to be a base library for other smaller script which may be written in kotlin or in the javascript. When I build the project with maven everything works as expected. However when I build it with npm or gradle I always get a weir results.
When compiling with npm together with webpack, the final bundle file contains all required code. However names of my functions and variables get mangled so they are no longer accessible from javascript.
Compiling with gradle is similar except it doesn’t even include my sources into a bundled js file, but only include the kotlin std lib. And if I try to load the kotlin file first (from build/kotlin-js-min/main) and then js file in build/js/mymodule.js I get an error saing “module is not defined”
I wen’t through probably all available example projects or tutorials but without success.
I posted an example project here
In gradle branch is gradle project
My js code:
<body>
<script src="test.js"></script> //file generated in bin/bundle
<script>
(function() {
let a = new test.Test(); //test - module, Test - my class, error occurrs at this line
a.test(); //test - method in class Test
})()
</script>
</body>
Thank you