I made a demo that shows how to use webworkers in ...
# javascript
e
I made a demo that shows how to use webworkers in Kotlin/JS: https://github.com/ethanmdavidson/KotlinJSWebWorkerDemo It involves building multiple .js files, which is also something I've seen people asking about. Check it out and let me know what you think!
🔥 2
t
1. 🔥 2.
kotlinx-html
0.7.3
available in maven central 3. Do you use
webpack-loader
? I use such configuration (different for production and dev) 4. I don’t “dependecies” between targets. Is it possible?
e
1 & 2: Thanks! 3: No, I've never messed around with webpack at all, but I think you should be able to add any configuration to both worker and client. btw is this example also using webworkers? 4. Yes, it's possible to share dependencies between targets by adding it to a common ancestor. I've updated the demo to show this by having commonMain depend on kotlinx-serialization, which allows client and worker to pass objects back and forth.
t
3: No, I’ve never messed around with webpack at all, but I think you should be able to add any configuration to both worker and client.
I use Gradle plugins (KFC plugins) for automatic webpack configuration. Loader will be applied automatically, if you build application
btw is this example also using webworkers?
Yes, it’s playground for related Gradle plugin
Worker target also require some API restrictions. Feel free to vote for separate target.