trunk
trunk copied to clipboard
Add Hot-Reload Configuration Options
Add a [server.reload]
sub-table or a [reload]
table for various hot-reloading options such as delay time and configuration for behavior around save events. Utilize the options internally for desired behavior.
What problem does this solve or what need does it fill?
- Reduces the number of times projects get rebuilt and served. Projects often get rebuilt and served before a full thought can be expressed. This causes resources to be used unnecessarily. Builds can stack up quickly which can lead to extensive waiting for larger projects. This is especially true for release builds
- Organizes the hot-reloading options into a single location within the toml
What solution would you like?
- [ ] Add section to
Trunk.toml
for hot-reloading options- [ ] Choose if this will be a sub-table
[server.reload]
or a standalone table[reload]
- Consider that this also rebuilds the project so there is merit to it being a standalone table
- [ ] A delay time for rebuilding after keyboard input has stopped
- [ ] Choose Integer or Float
- [ ] Choose default dealy: 3500 ms?
- [ ] Override default delay time if set in the
Trunk.toml
- [ ] Ensure delay time begins after keyboard input has paused and resets if it resumes before that interval has elapsed
- [ ] Add rebuilding and serving save options
- [ ] Parse relevant key-value pairs
- [ ] Create tests for variants
- [ ] Decide if mixed syntax is allowed
- [ ] Choose if this will be a sub-table
Trunk.toml
[watch]
# Paths to watch. The `build.target`'s parent folder is watched by default
watch = []
# Paths to ignore.
ignore = []
[[serve]]
# The address to serve on.
address = "127.0.0.1"
# The port to serve on.
port = 8080
# Open a browser tab once the initial build is complete.
open = false
# no_autoreload = false # This line is a double negative, unecessary thinking necessary. Move to nested table below
[serve.reload] # This could just be [reload]
automatic = true # Alternative "hot = true" or "auto = true".
delay = 10000 # In milliseconds
# ---------------------------------------------------------------------------------------------------
# Save Alternatives. See Considerations in Comment Below
# ---------------------------------------------------------------------------------------------------
on_save_only = true # Always or never: rebuilds and serves on save events. Delay applied, default or otherwise
# or
on_save = {enable = true, exclusive = true} # Rebuild and serve only on save events
What alternative(s) have you considered?
Turning off hot-reloading, only watching specific files. These don't address the underlying issue.
Save Option Alternatives, Variations, and Testing Considerations for Trunk.toml
Save Alternative 1:
on_save_only = true # Always or never: rebuilds and serves on save events. Delay applied, default or otherwise
Save Alternative 2:
Variation 1: Inline Table
# Variation 1.1:
on_save = {enable = true} # With `exclusive = false` being the default, rebuild and serve on save events *and* also whenever the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 1.2:
on_save = {exclusive = true} # With `enable = true` being the default, rebuild and serve on save events, but do rebuild and refresh otherwise.
# -----
# Variation 1.3:
on_save = {enable = true, exclusive = true} # Rebuild and serve only on save events
# -----
# Variation 1.4:
on_save = {enable = true, exclusive = false} # Rebuild and serve on save events *and* also whenever the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 1.5:
on_save = {enable = false} # Do *not* rebuild and serve on any save event. `exclusive` is not defined by the user, default is ignored.
# -----
# Variation 1.6:
on_save = {exclusive = false} # if `on_save.enable = true` is made the default, then this should work on save events *and* also whenever the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 1.7:
on_save = {enable = false, exclusive = true} # Do *not* rebuild and serve on any save event. `exclusive` value is ignored
# -----
# Variation 1.8:
on_save = {enable = false, exclusive = false} # Do *not* rebuild and serve on any save event. `exclusive` value is ignored
Variation 2: Dotted Keys:
# Variation 2.1:
on_save.enable = true # With `exclusive = false` being the default, rebuild and serve on save events *and* also whenever the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 2.2:
on_save.exclusive = true # With `enable = true` being the default, build and serve on save events, but do rebuild and refresh otherwise.
# -----
# Variation 2.3:
on_save.enable = true # Enable rebuilding and serving on save events
on_save.exclusive = true # Restrict rebuilding and serving to only occur on save events
# -----
# Variation 2.4:
on_save.enable = true # Enable rebuilding and serving on save events
on_save.exclusive = false # Also rebuild and serve when the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 2.5:
on_save.enable = false # Do *not* rebuild and serve on any save event. `exclusive` is not defined by the user, default is ignored.
# -----
# Variation 2.6:
on_save.exclusive = false # if `on_save.enable = true` is made the default, then this should work on save events *and* also whenever the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 2.7
on_save.enable = false # Do *not* rebuild and serve on any save event
on_save.exclusive = true # Should be ignored
# -----
# Variation 2.8
on_save.enable = false # Do *not* rebuild and serve on any save event
on_save.exclusive = false # Should be ignored
Variation 3 and 4: Mixed Syntax (Discouraged)
# Variation 3.1:
on_save = {enable = true} # Enable rebuilding and serving on save events
on_save.exclusive = true # Restrict rebuilding and serving to only occur on save events
# --------------------
# Variation 3.2:
on_save = {enable = true} # Enable rebuilding and serving on save events
on_save.exclusive = false # Also rebuild and serve when the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 3.3:
on_save = {enable = false} # Do *not* rebuild and serve on any save event
on_save.exclusive = true # Should be ignored
# -----
# Variation 3.4:
on_save = {enable = false} # Do *not* rebuild and serve on any save event
on_save.exclusive = false # Should be ignored
# --------------------
# Variation 4.1:
on_save.enable = true # Enable rebuilding and serving on save events
on_save = {exclusive = true} # Restrict rebuilding and serving to only occur on save events
# -----
# Variation 4.2:
on_save.enable = true # Enable rebuilding and serving on save events
on_save = {exclusive = false} # Also rebuild and serve when the delay duration, default or otherwise, has elapsed after typing has ceased
# -----
# Variation 4.3:
on_save.enable = false # Do *not* rebuild and serve on any save event
on_save = {exclusive = true} # Should be ignored
# -----
# Variation 4.4:
on_save.enable = false # Do *not* rebuild and serve on any save event
on_save = {exclusive = false} # Should be ignored
Discussion
-
Save Alternative 1 is easy to reason about, but doesn't offer the same level of control as Save Alternative 2
-
Both Alternatives could be implemented where Alternative 1:
on_save_only = true
simply enforces Alternative 2:on_save.exclusive = true
/on_save ={exclusive = true}
by overriding them. This would lock the logic to usingon_save
options internally. It may confuse users to have both Alternatives available. -
Variations 3 and 4 should be discouraged. Could produce error to enforce a standard.
Excellent write-up. Generally I agree, but I'm afraid the maintainer group doesn't have the bandwidth to implement this right now. PRs are welcome though. :)
I made things more clear in my previous posts. I'll try to set aside some time to make some effort towards this, but I'm heavily focused on other things at the moment. There are some questions that would benefit from discussion. I added some decisions as tasks. I'll add more if I think of them.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.