Kotlin/js - document.create

Hello,

I tried following this article: https://github.com/kotlin/kotlinx.html/wiki/DOM-trees
But intellij nor the compiler dont see anything like document.create

My build.gradle:
`
repositories {
mavenCentral()
jcenter()
}

dependencies {
def kotlinxHtmlVersion = “0.7.1-1.4.0-rc”

implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
// include for client-side
implementation("org.jetbrains.kotlinx:kotlinx-html-js:${kotlinxHtmlVersion}")

testImplementation "org.jetbrains.kotlin:kotlin-test-js"

}
`

Also I have a side question - I’ve split my project into two modules - java backend and kotlin/css/html front end, I can execute tasks and build the modules from terminal just fine, single tasks from within intellij also work, but I have a “dangling” grade import button when I edit the build.gradle file of the frontend module, when I click the button the import/reload (whatever intellij calls it) fails.

Hi,

I had troubles with kotlinx.html also and I think it might be better to avoid it as it is quite low level.

You may check KVision which is a rather big library and example collection for Kotlin/JS with a lot of examples.

I myself decided not to go with KVision but to migrate my previous React based stuff into a full-stack library: Zakadabar Stack with the data model and schemas defined in common code.

In those two projects you may find a lot of examples. The Stack has a sample repo which should work right after cloning, and also template project you can start to kick-off your own.

KVision also has a lot of examples and templates.

KVision is mature, the Stack is under development, take that into consideration.

What I did when I started with Kotlin / Multiplatform was that I read a lot of Ktor and Clikt gradle files.

Hope this helps.

Thank you for the recommendation of KVision, I’ll definitely look into it later.

However my problem is within gradle/dependencies or possibly outdated documentation(?).

Why is document.create not visible to the compiler and intelij? Have I added the wrong dependency?

Restarting Intellij fixed the issue. I have no idea what was wrong.

When you update your project buildscript the gradle cache can sometime end up in an inconsistent state and you get weird errors and inconsistent behaviors. What I do is run gradlew clean after I changed a buildscript, and if it still doesn’t work go into IDEA > File > Invalidate cache/restart. It usually fixes the problem, if not then it’s probably an issue with your script.