Repository navigation
feat(windows): apply webpack HMR updates without restarting the app - #6174
Merged
Merged
Conversation
tryRefreshApplication returned false for webpack, so every change restarted the app even though the hot-update files were already in bin\app. After a sync, the CLI now writes an ns-livesync marker into the app's LocalState. The debug host watches for it and calls global.__onLiveSync(), which runs webpack's hot update (NativeScript/windows#32). The CLI only does this when the host has written ns-livesync-ready, so older hosts still restart. shouldRestart now also restarts on a full sync, as Android and iOS do. That is how the CLI recovers when a hot update fails.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
With webpack,
tryRefreshApplicationreturnedfalse, so every change restarted the app, even though the hot-update files had already been copied into the running app'sbin\app. On Android and iOS the runtime callsglobal.__onLiveSync()after a sync, and webpack's HMR runtime applies the update from there.Changes
WindowsApplicationManager.signalLiveSync(appId)writes anns-livesyncmarker into the app's LocalState. The debug host watches for it and calls__onLiveSync()on the UI thread (NativeScript/windows#32). It returnsfalseunless the host has writtenns-livesync-ready. EXE targets and hosts without the watcher therefore keep restarting, so a newer CLI with an older runtime behaves as today.WindowsDeviceLiveSyncService:tryRefreshApplication: no HMR or app not running → restart, as before. Vite →true, as before. Webpack →signalLiveSync.shouldRestartalso returnstrueon a full sync, as Android and iOS do. When a hot update fails, the run controller re-syncs withisFullSyncand refreshes again. Without this the app would keep running the stale code.Testing
End to end on Windows 11 (Debug, x64): a TypeScript app on webpack 5.99.7, core and
@nativescript/webpackbuilt from NativeScript/NativeScriptfeat/windows, the runtime template from NativeScript/windows#32 and a currentnativescript.dll:app.cssedit: "Refreshing application", no restart. The app logged[HMR] success | Successfully applied update.with the same PID.app.tsedit (not hot-acceptable): the app logged[HMR] failure | A module has not been accepted., then the CLI restarted it (new PID).Unit tests: the livesync (29) and prepare-controller tests pass. The full suite has the same 17 pre-existing failures with and without this change.
Not covered by unit tests: there are no specs for the Windows device services yet.