hellman
11/26/2019, 6:26 PMIlya Goncharov [JB]
11/27/2019, 7:59 AMhellman
11/27/2019, 9:50 AMhellman
11/27/2019, 9:50 AMhellman
11/27/2019, 9:51 AMsourceSets["main"].dependencies {
implementation(project(":service-worker"))
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.13.0")
}
hellman
11/27/2019, 9:52 AMservice-worker
and main
produces a JS file in build/distributions. browserRun
task works, but only includes the JS scripts from the module it runs on, not any module it depends onhellman
11/27/2019, 10:04 AMentry
configuration for the JS file in all its dependencies, and then have the output filename changed so it generates multiple files.hellman
11/27/2019, 10:05 AMentry: [
'/Users/hellman/Sources/Kotlin/kotlin-js-pwa/build/js/packages/kotlin-js-pwa-main/kotlin/kotlin-js-pwa-main.js'
],
output: {
path: '/Users/hellman/Sources/Kotlin/kotlin-js-pwa/main/build/distributions',
filename: 'main.js'
},
hellman
11/27/2019, 10:06 AMservice-worker
module as well.Ilya Goncharov [JB]
11/27/2019, 10:18 AM./gradlew build
and it is built successfully
In main/build/distribution
you can find your bundlehellman
11/27/2019, 11:33 AMmain.js
therehellman
11/27/2019, 11:33 AMservice-worker.js
hellman
11/27/2019, 11:33 AMservice-worker.js
in the outputIlya Goncharov [JB]
11/27/2019, 11:34 AMhellman
11/27/2019, 11:35 AMhellman
11/27/2019, 11:36 AMsw.js
filehellman
11/27/2019, 11:36 AMIlya Goncharov [JB]
11/27/2019, 11:37 AMwebpack.config.d
folderhellman
11/27/2019, 11:38 AMmain
, right?hellman
11/27/2019, 11:39 AMIlya Goncharov [JB]
11/27/2019, 11:39 AMconfig
variable
config.plugins.push(...)
hellman
11/27/2019, 11:39 AMwindow
. If that happens I know I’m running in a Service Workerhellman
11/27/2019, 11:40 AMhellman
11/27/2019, 11:41 AMhellman
11/27/2019, 11:41 AMIlya Goncharov [JB]
11/27/2019, 11:42 AMAnyway, should I file an issue about lack of support for Service Worker support in Kotlin/JS?You’re welcome of course! Please describe your use case, it helps us to prioritise some stuff, and what specifically problem is (do you have some compiler problems?)
hellman
11/27/2019, 11:45 AMself
is undefined, but I guess that is tricky to solve in Kotlin. If running as a normal script it will be the same as the window
object, in the case of a Service Worker it’s a ServiceWorkerGlobalScope
hellman
11/27/2019, 11:46 AMwindow
for the window stuff, I just declare self
as a ServiceWorkerGlobalScope
myself:
external val self: ServiceWorkerGlobalScope