Open Rich-Harris opened 9 years ago
HMR is the way to go and that means breaking down the boundary between file system and browser. Create web sockets and send just updated contents into the browser. You can be notified of bad build AND keep working. We can stop the bundling insanity that kills cycle time.
Totally agree. I haven't delved into it much so far, other than reading a few blog posts and watching a few shiny demos, but it's clearly the direction that things are moving in. Have you experimented with any of the implementations out there?
Have you experimented with any of the implementations out there?
No, not yet. Web sockets in all modern environment (node and chrome) are dead easy though. Haven't kept up on the gobble architecture, would be cool if the nodes and transform model could just cross over the boundary and continue.
Web sockets in all modern environment (node and chrome) are dead easy though
True - question is how does the client script get injected? Is it kosher to just append a <script src='magic-gobble-client.js'>
to any HTML file that gets served?
Haven't kept up on the gobble architecture
it's a work in progress...
True - question is how does the client script get injected? Is it kosher to just append a
<script src='magic-gobble-client.js'>
to any HTML file that gets served?
If someone has a build system they can easily conditionally include it themselves. But throwing it in automagically might be fine too. There's probably some configurable hooks, or the build system doesn't go the full mile, because given the type of file you'd want to do different things. A css file can be mapped to a style tag and swapped, but a js file may, or may not, require a "reload". A ractive component could be hot-loaded (assuming we had the api for that), etc.
The livereload signal is only sent when a build completes. I think it should also be sent if the build breaks, since otherwise the only indicator you get is a) the CLI output (which might not be visible on the screen, particularly if you're working on a laptop), or b) you notice that the page doesn't seem to be reloading any more.
A related question is whether the livereload signal should be sent as soon as the build invalidates. For: nice short feedback loop. Against: a complex build might take a while, and you don't get a chance to continue using the previous build, or take a mental snapshot of the app state (tangential thought: what would it take to support figwheel/steal/webpack-style hot module replacement?) while the rebuild is happening