Bundle preloads so imports work, and live-reload the renderer in dev - #15
Merged
Conversation
…ilently breaking window.api
…tarting the whole app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes from macOS-user field feedback, both confirmed genuine in the code and fixed.
importin a preload silently brokewindow.api(fix)A preload is injected as a classic script (a
WKUserScriptand its WebKitGTK / WinCairo equivalents have no module mode), so a top-levelimportthrew aSyntaxErrorthat aborted the whole preload — silently takingwindow.apiwith it.The preload is now bundled into a self-contained IIFE before injection, inlining its imports:
common/preload-bundle.ts→ runtimemain/api/preload.ts(bundles via Bun in dev; raises a clear error instead of failing silently) +bundlePreloadAssetswired intobuild-macos/build-windows/build-linuxso a packaged app matches dev.import-using preload exposeswindow.api.bunmaska devrestarted the whole app (reopening the window) on every save (feat)The watcher now classifies each change — a TypeScript source (compiled into the main process) restarts; any other watched file is a renderer asset (page / CSS / preload) and live-reloads the window in place over the child's stdin. No more window churn for HTML/CSS edits.
main/dev-reload.ts(app-side stdin reload listener) + a reload path in the supervisor.reloadon stdin re-navigates the page with no restart.Testing
validate:windows→ 187 pass, 0 fail; type-check + lint clean.Docs
Corrected the now-inaccurate "preload is injected verbatim, keep it plain JS" across the scaffold, examples, and website: preloads are bundled, so
imports work — just keep them browser code (no Node APIs).