Is there somewhere an example of multi-module proj...
# javascript
v
Is there somewhere an example of multi-module project with new gradle plugin? I'm trying to migrate from kotlin-frontend-plugin and can't get everything done.
t
i
This one contain Kotlin/JS client and mpp shared module. https://github.com/Kotlin/kotlin-full-stack-application-demo
r
Also creating a new multiplatform project via IntelliJ gives an example which is quite up-to-date with the newest versions
v
Thanks, I'll try it)
I've checked these projects and didn't find what I've meant. I have a project with one main module which only imports some definitions from several submodules and defines main function where app loads and some external libraries are required. Also main module has to start devServer. I've tried to start devServer and after many interations of editing webpack configs stuck up with this error: "Module not found: Error: Can't resolve 'some_module' in '/some/path'". I opened generated webpack config and didn't find there in modules section included submodules. Old kotlin-frontend-plugin added to webpack's config.resolve.modules those modules. I've tried to add these modules manually but it didn't help. Also I don't understand how to configure subprojects properly: if I don't specify section target { browser() } it don't work but if I do it generates run tasks and sometimes webpack configs for those subprojects. With old kotlin-frontend-plugin we need to apply it only on root project but with new plugin it seems working not like that. Maybe it not gradle plugin's problem but my problems with webpack. Please could you point me where I'm wrong and in which direction to look for? Also just now tried to start devServer and I can't because default port already taken by other process. Changes in devServer property of webpackTask: devServer = KotlinWebpackConfig.DevServer(port = 8088, contentBase = listOf("$buildDir/processedResources/Js/main")) have no effect. Isn't it a serialization problem?
i
You need to declare in each module
Copy code
kotlin {
   target {
     browser()
   }
}
In this case, in root
build
folder, npm project will be initialised. You are right, that run and webpack tasks are created for all subprojects. It is fixed in going
1.4-Mx
versions For example in
1.4-M2
,
runTask
and
webpackTask
are only generated only if you set
binaries.executable()
for particular subproject. You can read more https://kotlinlang.org/docs/reference/js-project-setup.html
v
Thanks for clarification) I've tried 1.4-M1 and 1.4-M2 but had some problems with these versions. 1.4-M2 wasn't downloaded and also I have version conflicts with kotlin-dsl plugin so I decided to try new plugin with latest 1.3.72 release.
I've solved problem with sevServer. Just defined devServer property in runTask, not webpackTask. But it seemed to work previously with webpackTask.
i
webpackTask
settings about
browserWebpack
which run
webpack
runTask
settings about
browserRun
which run
wrbpack-dev-server
v
And what about webpack config? How can I tell it which modules exists? Is new plugin responsible for that or should I do it on my own?
i
If you need to declare custom webpack configurations, you can do it in
webpack.config.d
like in frontend plugin But by default, if you don’t change output directory for compile tasks, it should work out-of-box