I created a Kotlin/JS Gradle project with three mo...
# javascript
h
I created a Kotlin/JS Gradle project with three modules, “main”, “common” and “service-worker”. “main” is the script that my index.html loads. This will in turn install a ServiceWorker from /service-worker.js. How do I configure the main module to pick up the JS output from the module it includes as a dependency?
t
implementation(project(":service-worker"))
in gradle should be enough
h
I get an error if I configure the other modules using
kotlin.target.browser()
then:
Copy code
Build file '/Users/hellman/Sources/Kotlin/kotlin-js-pwa/service-worker/build.gradle.kts' line: 15

Could not create an instance of type org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs.
> Failed to apply plugin [class 'org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin']
   > Cannot add extension with name 'kotlinNodeJs', as there is an extension already registered with that name.
If I don’t have
kotlin.target.browser()
in the
service-worker
module, I don’t get the web pack tasks
t
well you still have to activate the kotlin/js plugin...
h
YEah., I got that. But adding the
kotlin.target.browser()
config makes the gradle script fail
Plugin is applied on all modules