dmjio / miso

:ramen: A tasty Haskell front-end framework
https://haskell-miso.org
BSD 3-Clause "New" or "Revised" License
2.18k stars 133 forks source link

Using miso without isomorphic feature, but with optimizations - possible? #716

Closed pmiddend closed 1 year ago

pmiddend commented 1 year ago

Describe the bug I'm not ready to go "full isomorphic" with miso yet, so I thought I'd at least replace my unoptimized all.js (5MiB in size) with one that's optimized by Closure Compiler, as seen in the miso-haskell.org example. This indeed produces a smaller .js file, but it doesn't seem to work with runmain.js (gives an error about a missing function).

Before I delve deeper here - is this supposed to work? Or do I have to use the isomorphic feature in conjunction with the closure compiler?

dmjio commented 1 year ago

@pmiddend yes, those two features should be totally independent of each other. By default the isomorphic features should be disabled and only enabled when using the miso function. startApp by default does not attempt to copy the existing DOM into the virtual DOM. I think if you do choose to use the miso function, it will fallback to a complete redraw if the original DOM can't be copied into the virtual DOM (not structurally equivalent).

If you're going to use runmain.js, I think you'll need to include the other .js files as well (rts.js, etc.). Whereas, if you use all.js you can safely pass that to the closure compiler no problem.

pmiddend commented 1 year ago

Ah, so I can indeed remove runmain.js if I use all.js (closure-compiled or not).

That clears things up, thanks for the quick response and thanks for miso!