I managed to make it work with KVision application...
# javascript
r
I managed to make it work with KVision applications, and I really wonder why HRM is not enabled by default? It makes app reload cycle at least twice as fast compared to the default configuration!
1
b
Can you share a brief summary how?
i
Do you make some changes in your code for HMR with saving of state? Or do you just enable
hot
option?
r
Copy code
config.devServer.hot = true;
in
webpack.config.d
I had to make some changes in KVision, because the
module.hot
had to come from the application and not the library
but to enable HMR only this one option is required
b
@Ilya Goncharov [JB], shouldn't that be default option for devRun?
r
it could be at least defined in
KotlinWebpackConfig.DevServer
class, and documented somewhere
i
So, usually feature of hmr is good option on module which contain hmr code in runtime Usually, using of HMR in module without implementation of HMR interface should be without some changed in dev server (at least it was when I tested it on my project) That’s why this option was not enabled by default in plugin
b
Would be nice to have it on devRunTask, then as a configuration option
i
Yes, for now setting
devServer
is terribly, it should be dsl-like, but now it requires to create new instance And yes, as for me it should represent all options of webpack dev server setting 🙂
👍 2
r
There are probably not many options as useful as
hot
:-)
t
Library, plugins, rules, entry are useful too :)
r
I remember feeling slower reload cycle after migration from
kotlin-frontend-plugin
to the new plugin ... now I know why! :-)
😂 2
i
I’ll investigate it, if there will no problems in different cases, I think it can be made hot by default
r
If something is wrong with HMR configuration webpack just falls back to live reload.
But it prints some warnings to the console, so at least we know there is something that can be fixed.
i
Personally for me, interesting why it faster even without any HMR code in your module
r
I was misunderstood
I have HMR code in KVision for years.
But the functions to pass state between reloads are optional.
and I personally don't use them
but today a user filled an issue about this not working
and I've started to investigate
i
Ohhh, so after adding
hot
there was nothing changed in experience, but then you fixed issues related with hmr code in KVision, and it works again, and it helps you to improve performance. Exactly HMR code in your library improve performance, not the just enabling of
hot
mode?
🧌 1
r
I don't think we can treat those two things separately :-)
If
hot
would be enabled by default, I would have fixed those errors months ago. And a lot of development time would be spared :)
I just didn't realize HMR was lost 🙂 I was sure it's just about reloading browser after code changes.
I've never used webpack nor hmr without Kotlin/JS :-)
i
Ok, thanks, I see point! So honestly I know about HMR, but I thought it should be kinda optional, if user wants to use and write code to persist state. And yes, this option should be in dsl 🙂