kotlin-frontend-plugin icon indicating copy to clipboard operation
kotlin-frontend-plugin copied to clipboard

backend-frontend code sharing

Open bennylut opened this issue 6 years ago • 2 comments

Hi, I would like to know if there is any documentation about using this plugin for a full stack application with code that is shared between the server and client? (essentially models, validation logic, utility functions, etc.)

BTW If there is so - I would like to suggest updating the full-stack-example to include such sharing.

bennylut avatar Oct 16 '18 04:10 bennylut

Afaik there is no documentation at the moment. But only few steps are needed.

  1. Create Multiplatform project https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-a-multiplatform-project
  2. Implement your platform specific / inter-platform code
  3. Add this multiplatform project as dependency to your project with the Kotlin frontend plugin defined (on the previous multiplatform layout your dependency must point to the js part project)

Now you should be able to use the JS part of your multiplatform project within the frontend project.

wem avatar Oct 16 '18 12:10 wem

when I do this, everything works fine until I add "webpackConfigFile = "webpack.config.js" to my webpack bundle. Once I do that it fails to recognize my package structure... com.foo, foo is unrecognized

ideaBlender avatar Mar 15 '19 20:03 ideaBlender