You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/hot-reload.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,10 @@ The Ema dev server uses websockets to keep a bi-directional connection open betw
15
15
16
16
When switching to a new route or when receiving the new HTML, Ema uses[idiomorph](https://github.com/bigskysoftware/idiomorph) to_patch_ the existing DOM tree rather than replace it in its entirety. This, in addition to use of websockets, makes it possible to support**instant** hot reload with nary a delay.
17
17
18
+
In addition to the patching the DOM, all`<script>` tags are recreated, making it possible to re-run any JavaScript code (e.g.: for[syntax highlighting][syn]) that was present in the new HTML. You can skip this behaviour on a per-`<script>`-tag basis by using the`data-ema-skip=true` custom attribute (Emanote does this for Tailwind, to prevent it from inserting[duplicate](https://github.com/srid/emanote/issues/411)`<style>` tags).
Finally, hot reload on_code_ changes are supported via[ghcid](https://github.com/ndmitchell/ghcid). The[template repo](https://github.com/srid/ema-template)'s`bin/run` script uses ghcid underneath. Any HTML DSL (like`blaze-html`) or CSS DSL automatically gets supported for hot-reload. If you choose to use a file-based HTML template language, you can enable hot-reload on template change using the[[unionmount]] library.
- Fix scrolling to page end when using pathname in anchor links (\#162)
12
12
- Add`--no-ws` to disable websocket handling in live server (\#161)
13
13
- Switch from`morphdom` to`idiomorph`
14
+
- Allow skipping recreation of any`<script>` tag during live server update by using`data-ema-skip=true` custom attribute (\#170)
14
15
15
16
##0.10.2.0 (2023-08-09)
16
17
@@ -40,7 +41,7 @@ This releases brings a significant rewrite of Ema. If you choose to upgrade your
40
41
- Represent route encoding using`Prism'` from optics-core; add`IsRoute` class to define them.
41
42
- Optional generic deriving of route prisms, so you do not have to hand-write them.
42
43
- Automatic isomorphism checks ensures that encoding and decoding are isomorphic (route prisms are lawful)
43
-
- Composable Ema apps
44
+
- Composable Ema apps
44
45
- There are two ways of composing Ema apps. Using heterogenous lists (see`Ema.Route.Lib.Multi`), or by defining a top-level route type (see`Ex04_Multi.hs`).
45
46
- Replace`LVar` with`Dynamic`.
46
47
- Ema still uses`LVar` internally (for live server updates), but on the user-side one only needs to provide a`Dynamic` which is a tuple of initial value and an updating function. The[unionmount](https://github.com/srid/unionmount/pull/1) library was changed to provide this tuple.
@@ -67,7 +68,7 @@ This releases brings a significant rewrite of Ema. If you choose to upgrade your
- Tailwind: module revamped and renamed to`Tailwind.Helper.Blaze`
70
-
-`runEma` and friends:
71
+
-`runEma` and friends:
71
72
- return the monadic's action's return value or generated files (dependent type)
72
73
- CLI: add`run` subcommand that takes`--host` and`--port` (and remove environment hacks of $HOST and $PORT)
73
74
@@ -84,12 +85,12 @@ This releases brings a significant rewrite of Ema. If you choose to upgrade your
84
85
- Do not handle target=_blank links in websocket route switch
85
86
-`Asset` type
86
87
- Introduce the`Asset` type to distinguishing between static files and generated files. The later can be one of`Html` or`Other`, allowing the live server to handle them sensibly.
87
-
-`Ema` typeclass:
88
+
-`Ema` typeclass:
88
89
- Drop`staticAssets` in favour of`allRoutes` (renamed from`staticRoutes`) returning all routes including both generated and static routes.
89
90
- Drop`Slug` and use plain`FilePath`. Route encoder and decoder deal directly with the on-disk path of the generated (or static) files.
90
91
- Make the render function (which`runEma` takes) return a`Asset LByteString` instead of`LByteString` such that it can handle all routes, and handle static files as well as generation of non-HTML content (eg: RSS)
91
92
- Allow copying static files anywhere on the filesystem
92
-
-`routeUrl`:
93
+
-`routeUrl`:
93
94
- Unicode normalize as well URI encode route URLs
94
95
- now returns relative URLs (ie. without the leading`/`)
95
96
- Use the`<base>` tag to specify an explicit prefix for relative URLs in generated HTML. This way hosting on GitHub Pages without CNAME will continue to have functional links.