-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Kotlin Web (Ktor & KotlinJS) examples (1650USD Bounty) #3611
Comments
Part of #3611 Working in the TodoMVC demo application. I'll raise a follow up PR for that.
Let me try if I can do anyone |
Hello, I'm new here. build.sc file not found. Are you in a Mill project folder? |
@c0d33ngr please see the readme.md at the root of the repo |
I did a quick overview of the things which should be done here, and it seems that the work can be sliced in a bit more granular way. The main complexity here comes actually from implementing Kotlin/JS support (similar to the Scala/JS) which is itself a quite big task, because:
So I think maybe implementing Kotlin/JS support is worth to be extracted into a different task? Making examples is easier than that. Also this raises a design question: say there is a code which should be compiled to both JVM and JS targets. How this could be done with existing Scala modules, for example? I believe |
@0xnm as written, the KotlinJS stuff (bullets 3-6) is already in separate milestones from the pure Ktor/web stuff (bullets 1-2). Bullets 3 and 6 seem pretty independent of Ktor and should be doable without any pre-requisites, and bullets 1-2 should be independent of KotlinJS. I don't mind adding more non-KotlinJS web stuff, just not sure what that would entail. In Scala-land, cross-platform Scala code is normally handled via I'm hoping the KotlinJS tooling already has a decent API/CLI, and most of the work would just be wiring it into Mill. I'm not sure how true that actually is, but as a point of reference Mill's ScalaJS support is 14 files and 1600 lines of code with another 1000 lines of tests for basically 100% coverage of ScalaJS' functionality. I'm hoping KotlinJS won't be that much more work, but I don't know The bounty amounts are pretty arbitrary TBH and are just my best guess w.r.t. the amount of work necessary. For the KTor stuff they should be pretty reasonable, since those bullets shouldn't require any special tooling background. But if we think the KotlinJS bounties aren't proportionate to the amount of work necessary, I can totally bump them up, or if someone wants a different arrangement (e.g. some payment up front to de-risk the effort ) |
Part of #3611 --------- Co-authored-by: Li Haoyi <[email protected]>
I added a very basic PR with a foundation for Kotlin/JS support in #3678, but there are many issues/missing functionality. See that PR for more details. |
Another part for #3611. This PR adds a very basic foundation for the Kotlin/JS support. The code provided allows to: * Build code with `org.jetbrains` (most likely) dependencies only * Run it with Node (no browser support) * Execute tests (using `kotlinx-test` so far), but without any test results collection/tests selector, etc. However, I think that full Kotlin/JS support **will take a lot of time**, because even if there is a Scala.JS counterpart available, the way these technologies work is very different (distribution, format, etc.) Issues I've encountered: * Kotlin 2+ is not supported, because with Kotlin 2+ jars are not published anymore and there is only `klib` file available (see https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-js/2.0.0/). When Gradle is used, it is able to fetch it using attributes declared in `.module` file, but Coursier is not able to recognize and fetch it. * Kotlin versions below 1.8.20 are not supported, because of the different set of compiler arguments. With the certain effort it is possible to go further in supporting older versions, but I'm not sure if it is needed: since Mill is somewhat experimental, probably there is no need for the users to use old Kotlin versions. * Even if some Kotlin/JS library has `jar` file published with Kotlin/JS library inside, it may be rejected by the compiler. For example, this https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-html-js/0.8.0/ has the necessary `jar` file with `.meta.js` / `.kjsm` files inside, but it is rejected by the compiler of Kotlin 1.8/1.9. Here https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-js/1.9.24/, for example, nothing is rejected, so I suppose there is an issue in the ABI/metadata version. Not sure how it can be solved (maybe by relying only on `klib`? But `klib` cannot be fetched by Coursier). * Gradle Kotlin plugin is utilizing NPM dependencies to generate `package.json` and add the necessary JS test frameworks/runners there if executed in Node environment, or even webpack for Browser environment. This is also a big chunk of work to be done. For now I've added only test binary execution, but there is no test results collection / test selector. * Kotest cannot be used, because with version 5 only `klib` is published, and `jar` of version 4 is not compatible with the 1.8/1.9 IR compiler. * ~~Kotlin/JS IR compiler has different modes: it can output either IR/Klib or can produce final JS (basically IR+linking). Kotlin Gradle plugin is using 2 passes: to generate IR and then produce final JS. I guess it is done for the better performance / better incremental support, but I, for the initial drop, rely on a single pass (IR+linking in a single compiler invocation) => **need to make `compile` task to produce only IR code and add kind of `link` task to produce executable in the future.**~~ => addressed in the 2nd commit. --------- Co-authored-by: 0xnm <[email protected]> Co-authored-by: Li Haoyi <[email protected]>
First 3 bullets (mostly) work. Further progress is blocked by #3695 |
@0xnm Now that we can resolve klib files, the subsequent two bullets should be doable if you're up for taking a crack at them, since the only thing blocking them before was accessing third party library for DOM interactions. The other limitations around The last bullet may require more work, I'm not sure how much work the gradle kotlin/kmp plugin does to support publishing. We can investigate when we get to that |
Point 4 in #3611: add a sample of Kotlin/JS frontend+ Ktor backend. --------- Co-authored-by: 0xnm <[email protected]> Co-authored-by: Li Haoyi <[email protected]>
This PR addresses task 5 from #3611 by adding and example of code sharing between JVM and JS Kotlin targets. I also simply copied `PlatformScalaModule` -> `PlatformKotlinModule`, because type aliasing won't work: doc is different (and need to extend from `KotlinModule` still). --------- Co-authored-by: 0xnm <[email protected]> Co-authored-by: Li Haoyi <[email protected]>
Thanks @0xnm, I merged the two kotlinjs/webapp examples with some minor fixes and closed out the bounty for |
For |
Yes, I would suggest to split bounty for bullets 5/6 and maybe extract bullet 6 into a new issue (to have a clean space free of previous discussions), because it will definitely require some exploration work to be done and it won't contain only sample migration. |
@0xnm sounds good. I'll split it out into a separate bounty and pay out the first bullet first |
From the maintainer Li Haoyi: I'm putting a 1650USD bounty on this issue, payable by bank transfer on a merged PR implementing this.
The goal of this ticket is to implement support for
example/kotlinlib/web
example tests for using Kotlin for web development, mirroring theexample/javalib/web
andexample/scalalib/web
, and support for KotlinJS in the spirit ofscalajslib/
. I would want the following example tests, broken down into smaller groups each with its own bounty:650USD:
example/kotlinlib/web/1-hello-ktor
"<h1>Hello, World!</h1>"
web page, in the spirit ofexample/javalib/web/2-hello-spring-boot
example/kotlinlib/web/2-todo-ktor
runBackground+curl
tests, in the spirit ofexample/javalib/web/3-todo-spring-boot
650USD:
example/kotlinlib/web/3-kotlinjs-module
(325USD)node
, in the spirit ofexample/scalalib/web/3-scalajs-module
example/kotlinlib/web/4-webapp-kotlinjs
(325USD)example/scalalib/web/4-webapp-scalajs
700USD:
example/kotlinlib/web/5-webapp-kotlinjs-shared
(350USD)example/scalalib/web/5-webapp-scalajs-shared
,example/kotlinlib/web/6-cross-platform-publishing
(350USD)How to define a library with both Kotlin-JVM and Kotlin-JS versions and publishing it to maven central. In the spirit ofexample/scalalib/web/6-cross-version-platform-publishing
Each of these examples above has a corresponding
javalib
/scalalib
equivalent, and it should generally follow the style of those equivalents (scope, testing, etc.) but translated to Kotlin (Java/Scala -> Kotlin, Scalajs -> Kotlinjs, Cask/SpringBoot -> KTor, etc.)For now the Kotlin-JS logic should live in
kotlinlib/
together with the rest of the kotlin-specific configuration.The text was updated successfully, but these errors were encountered: