Kotlin / kotlin-fullstack-sample

Kotlin Full-stack Application Example
https://kotlinlang.org
Apache License 2.0
1.21k stars 169 forks source link

Add example of sharing code between both frontend and backend #32

Open Zomis opened 6 years ago

Zomis commented 6 years ago

Add some common module, or common code somewhere, that both frontend and backend has a dependency on.

I have read these two discussions: https://discuss.kotlinlang.org/t/kotlin-to-javascript-and-kotlin-to-jvm-servlets-in-one-project/2600 https://discuss.kotlinlang.org/t/compiling-kotlin-to-both-java-and-javascript-from-the-same-module/1944

The second one contained a link to a project which modifies the main.kotlin.srcDirs by adding project(':').file('src/main/kotlin'), this however lead me to an issue with compiler errors in IntelliJ, which can be seen here: https://github.com/C06A/KUrlet/issues/1

So a clear example of how to actually share code between JS and JVM is appreciated.

yole commented 6 years ago

See https://github.com/jetbrains/kotlinconf-app and https://github.com/yole/kxhtml-isomorphic for other example projects that demo this.