kotlinx.html
kotlinx.html copied to clipboard
Cannot use kotlinx-html-js for NodeJS (Gradle + NPM)
build.gradle:
dependencies{
implementation 'org.jetbrains.kotlinx:kotlinx-html-js:0.6.11'
}
package.json:
"depenencies": {
"kotlinx-html": "0.6.11"
}
Generated code:
(function (_, Kotlin, $module$kotlinx_html_js) {
...
}(module.exports, require('kotlin'), require('kotlinx-html-js'));
Notice the mismatch between the NPM and the Gradle dependency name (-js
). The only version that was published with the matching name was 0.6.4
. Using latest version and removing the -js
from the generated code makes it work.
What am I missing?
Attached project (bug-kotlin-html-js.zip) is a minimal repro: npm install && gradle assemble && npm start
:
> @ start bug-kotlin-html-js
> node gen/app/index.js
module.js:515
throw err;
^
Error: Cannot find module 'kotlinx-html-js'
at Function.Module._resolveFilename (module.js:513:15)
at Function.Module._load (module.js:463:25)
at Module.require (module.js:556:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (p:\caches\svn\Examples\bug-kotlin-html-js\gen\app\index.js:28:38)
at Module._compile (module.js:612:30)
at Object.Module._extensions..js (module.js:623:10)
at Module.load (module.js:531:32)
at tryModuleLoad (module.js:494:12)
at Function.Module._load (module.js:486:3)
I have similar problem related to the kotlin-frontend-plugin
, please see: https://discuss.kotlinlang.org/t/npm-install-fails-with-kotlin-frontend-plugin-kotlinx-html-js/8663