Hi, I'm trying to create a full stack website wit...
# javascript
l
Hi, I'm trying to create a full stack website with Kotlin/JS and Kotlin/JVM. I would like to create 1 js file for each page that I have on my website, however when building the project it merges all of the files into one js script. I was wondering if there was any way I could change that? I know that if you create submodules, it will compile 1 js file for each module, however I don't feel like this is a good solution as I would have to create one module for each page Thanks
b
Not possible at the moment
t
a
Actually, you can configure webpack to have multiple entrypoints, so every page could import its own JS file. It's a bit tricky, but a pretty standard way of doing things. You can start here: https://webpack.js.org/concepts/output/
Another way to do it would be to use a client-side router, so you could still to use one exported js file, but use different code from it depending on the current page.
b
Since kjs does not support es6, I'm not sure how webpack would split your bundle
a
@Big Chungus, how is it a question of es6? You can create multiple source entrypoint files, that only import what they need
b
No es6 -> no tree shaking, so you would be shipping an entire bundle for each page (even in the entry point is different). At that point you're better off going with a SPA
l
Thanks for the replies, i've tried to configure multiple entry points with webpack as Alex suggested however the only output files are .kjsm, and with webpack you need to use .js files for entry points, so I don't think its possible atm (unless anyone has any other ideas?) I feel like this holds kotlin/js back from being used as a viable solution for full stack web development
b
To get js outputs use binaries.library() or binaries.executable() To configure webpack use webpack.config.d folder (search around that)