devlog: hot-swap and cleanup
two things happened here and they’re very different vibes.
hot-swap
so previously applyUpdate() was just… reload the page. which works, obviously, but
it’s not exactly elegant. if you’re updating a css file there’s no reason to nuke the
entire page state.
now it actually tries to be smart about it. when you call applyUpdate(), it looks at
each file’s extension and attempts to swap it in-place:
- for
.jsfiles, it finds the matching<script>tag by src and replaces it with a
new one containing the updated content - for
.cssfiles, it finds the matching<link>stylesheet and swaps it with a
base64 data url version of the new css
if none of the files can be hot-swapped (like if there’s no matching dom element, or
it’s a file type it doesn’t know about), it falls back to the classic
window.location.reload(). so nothing breaks, it just tries the nice path first.
the base64 css thing is a little cursed honestly. but it works and avoids needing to
host the file anywhere. the browser just reads it inline. i might revisit this later
if it causes issues with large stylesheets but for now it’s fine.
eslint + prettier
added eslint and prettier to the Build package because the code was starting to look
inconsistent and it was bothering me. set up a flat config with typescript-eslint,
browser globals, the usual. named the prettier script make-pretty because i thought
it was funny. and idk, it’s how i do it ig
prettier immediately reformatted a bunch of stuff in updato.ts. removed some
unnecessary quote wrapping on "Accept", collapsed a few multi-line expressions that
didn’t need to be multi-line, cleaned up trailing commas. nothing behavioral, just
formatting.
also committed the lockfile. should’ve done that earlier but here we are.
todo progress
checked off hot-swap support and the linting setup. removed the version bump script
todo since that was already done in the last round. the list is getting shorter. slowly.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.