rjaros / kvision

Object oriented web framework for Kotlin/JS
https://kvision.io
MIT License
1.2k stars 67 forks source link

Where is main.bundle.js? #479

Closed kolotyluk closed 1 year ago

kolotyluk commented 1 year ago

I created my first project via the IntelliJ plugin... pretty good, but I need to figure out where to give feedback...

While I was inspecting the project, I can see the file index.html contains

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>KVision Template</title>
    <script type="text/javascript" src="main.bundle.js"></script>
</head>
<body>
<div id="kvapp"></div>
</body>
</html>

This begs the question: where is main.bundle.js?

Mysteries like this are disturbing because it should be easier to reverse-engineer code...

I am guessing this file resides in the webpack server somewhere because I cannot find it anywhere in the file system.

It would be beneficial, in terms of learning, if it were easier to understand what is going on here, and see the contents of main.bundle.js.

I am guessing this might be the Kotlin program complied to JavaScript, but I am only guessing.

rjaros commented 1 year ago

Hello,

Yes, main.bundle.js is a JS file created by webpack by bundling Kotlin code compiled to JavaScript and all NPM dependencies of the project. When building your app in production mode (./gradlew browserProductionWebpack) this file will be generated in the build/distributions directory. When using development mode (./gradlew -t run) the file is created dynamically and served by the webpack dev server. You won't find it on the file system, but you can download it from http://localhost:3000/main.bundle.js when the dev server is running.

kolotyluk commented 1 year ago

Interestingly, I did try looking at main.bundle.js indirectly by viewing the page source at http://localhost:3000 and clicking the link for main.bundle.js, but it resulted in a blank page. Pasting http://localhost:3000/main.bundle.js directly into Firefox does show the file. The enduring mysteries of web browsers... Anyway, I would be happy to add some documentation for this if you can point me to where the plugin generates build.gradle.kts, or there may be better places to document this important information.

Thanks for confirming what I suspected.

So far I am impressed with the overall quality and completeness of this project. Good job.

I have tried playing with Scala/JS, but it is not as high quality or completeness.

kolotyluk commented 1 year ago

My KVision Article

rjaros commented 1 year ago

Great work! :-) I've found one inaccuracy - currently Kotlin/JS (and KVision) is compiled to pure JavaScript and there is no WASM in the bundle. WASM target in the Kotlin compiler is a new, experimental feature and I plan to work to support WASM target in KVision in the near future.

kolotyluk commented 1 year ago

Thanks... updated the article.