Can't get a javascript project to work

I've tried extensively to get a javascript project working but to no avail. Can anyone point me to a good resource please?

Peter

Unfortunately, we have no public documentation about JavaScript backend. All we have is a tiny note in blog post about M2. Can you explain what exact problem do you have?

If you don’t know how to create JS project, it’s not too difficult. Just create new IntelliJ IDEA project (or module), add kotlin file, and int editor of it you will be offered to either set up module as JVM or JS module. After that, create new run configuration of type “Kotlin (JavaScript)”.

If I load and run the kotlin-js-hello project (in IntelliJ 12.0.3) that is mentioned in the blog post I get the following output:

Kotlin: Created script file: /Users/dev-admin/Documents/Projects/Kotlin-JS/kotlin-js-hello/out/production/hello/script.kts
Kotlin: Using kotlinHome=/Users/dev-admin/Library/Application Support/IntelliJIdea12/Kotlin/kotlinc
Kotlin: Invoking in-process compiler org.jetbrains.jet.cli.jvm.K2JVMCompiler with arguments [-module, /Users/dev-admin/Documents/Projects/Kotlin-JS/kotlin-js-hello/out/production/hello/script.kts, -output, /Users/dev-admin/Documents/Projects/Kotlin-JS/kotlin-js-hello/out/production/hello, -tags, -verbose, -version, -noStdlib, -noJdkAnnotations, -noJdk]
Kotlin: Kotlin Compiler version 0.4.297
Compilation completed with 3 errors and 0 warnings in 3 sec
3 errors
0 warnings
/Users/dev-admin/Documents/Projects/Kotlin-JS/kotlin-js-hello/src/hello.kt
Kotlin: Unresolved reference: js
Kotlin: Unresolved reference: window

Kotlin: Assignment operators ambiguity: internal open fun <ERROR FUNCTION>() : [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package internal open fun <ERROR FUNCTION>() : [ERROR : <ERROR FUNCTION RETURN TYPE>] defined in root package

Also, the build should generate the file hello.js but that doesn’t happen.


If I create a new Kotlin JS project and try to run it I’m getting:

12:00:30 PM All files are up-to-date 12:00:30 PM Error running Hello-Kotlin-JS: Cannot find output dir for project Hello-Kotlin

which seems to point to an issue with the ‘out’ directory not being created. If I then ‘Edit Configurations’ and point to the project directory for the 'Generated Javascript file directory, the ‘out’ directory gets created but I still get the same error:

12:00:30 PM All files are up-to-date 12:00:30 PM Error running Hello-Kotlin-JS: Cannot find output dir for project Hello-Kotlin

Currenlty Kotlin compiler to JavaScript doesn't work in IDEA when "Use external build" mode is on. You can workaround the problem disabling it in "Settings -> Compiler -> Use external build". Also feel free to vote for the KT-3106 issue.