seems to be <https://github.com/Kotlin/kotlin-fron...
# javascript
a
a
Does setting moduleKind to commonjs resolve your issue?
a
In application module - no. I am trying to change module kind in the mpp module I use as dependency
Nope, still does not work. Maybe I have to set module kind explicitly in all modules...
a
Well, you could take a look at the generated
.js
files and check that they are indeed commonjs modules. If some one them are compiled to plain that could very well be the cause
a
OK, I will try to use
umd
everyehere then. Since library I use uses
umd
a
Yeah,
umd
should work as well
a
I am unfamiliar with JS ecosystem, so I am trying to use umd because it is more recent. But it is confusing as hell.
a
Basically
umd
detects at run time how modules should actually look like and uses then correct mechanism.
a
Yeah, I've read about it
Nope, still does not work. I can try a clean build of course
The generated js look different for kotlin-stdlib and my modules, so something seems to be amiss with module system.
g
Could you put both into gists so that we can take a look?
a
And here is the global project configuration: https://github.com/altavir/dataforge-core/blob/dev/build.gradle.kts
g
how about the actual generated JS? What I'm wondering is if your generated JS bundle can't resolve the kotlin library because it doesn't have the correct path to it
a
You need the bundle or
kotin.js
from kotlin-js-min\main\? I checked bundle, it does have
kotlin.js
, so I do not think that the problem is with paths.
g
So the kotlin stdlib and your code is all in one js file?
or one bundle
a
I use bundled js to test my build from html. So it contains not only stdlib, but also all of the libraries
As for stdlib, I believe (and maybe I am wrong) that it resides in generated
kotlin.js
and then bundled with webpack bundle.
g
it does reside in kotlin.js, but we need to know if kotlin.js is getting bundled with your code or if it is trying to resolve it from the external kotlin.js file
a
kotlin.js is bundled. At least I see it inside the
main.bundle.js
.
Copy code
/***/ "./kotlin.js":
/*!*******************!*\
  !*** ./kotlin.js ***!
  \*******************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
etc
I can send the bundle, but it weights 2 Mb
g
ok that looks correct, just for sh*ts and giggles, if you havent already, could you try running it in an incognito tab
a
ammm.. ok
Yep, the same:
Copy code
Error loading module 'dataforge-context'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'dataforge-context'.
g
could you scroll to the bottom of the kotlin.js included in your bundle, and copy and paste the last 10 or so lines, including the exports part
a
Ok, in 20 minutes
g
go ahead and send the bundle, that will be easier
or dropbox/google drive link
a
Ok, so I've tried assembling the
dev
branch of your project, and here is what
dataforge-meta/build/classes/kotlin/js/main/dataforge-meta.js
starts with:
Copy code
if (typeof kotlin === 'undefined') {
  throw new Error("Error loading module 'dataforge-meta'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'dataforge-meta'.");
}
this['dataforge-meta'] = function (_, Kotlin) {
...
This is clearly
plain
module kind, which is not recognized by webpack (it won't know what it depends on). It seems that the
vis
depends on
io
, which depends on
meta
, so that
.js
file will be loaded by webpack. So it seems that you are indeed compiling some modules to
plain
, which causes webpack to miss some dependencies. Unfortunately I don't have jdk11 installed, so I cannot assemble the
vis
module directly. 😃
a
You can just comment vis-fx in settings and it will work
OK, I am back. Seems like the source of problem is undrestood, now I need to understand how to configure root build.gradle.kts to make it work.
Seems to be part of my gradle script was not working properly.
I had to move mpp configuration into
afterevaluate
block and now it is working
a
G 🎉