Skip to content

feat(windows): apply webpack HMR updates without restarting the app - #6174

Merged
triniwiz merged 2 commits into
feat/windowsfrom
feat/windows-webpack-hmr
Oct 23, 2026
Merged

triniwiz merged 2 commits into
feat/windowsfrom
feat/windows-webpack-hmr

Conversation

@triniwiz

Copy link
Copy Markdown
Member

With webpack, tryRefreshApplication returned false, so every change restarted the app, even though the hot-update files had already been copied into the running app's bin\app. On Android and iOS the runtime calls global.__onLiveSync() after a sync, and webpack's HMR runtime applies the update from there.

Changes

WindowsApplicationManager.signalLiveSync(appId) writes an ns-livesync marker into the app's LocalState. The debug host watches for it and calls __onLiveSync() on the UI thread (NativeScript/windows#32). It returns false unless the host has written ns-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.
  • shouldRestart also returns true on a full sync, as Android and iOS do. When a hot update fails, the run controller re-syncs with isFullSync and 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/webpack built from NativeScript/NativeScript feat/windows, the runtime template from NativeScript/windows#32 and a current nativescript.dll:

  • app.css edit: "Refreshing application", no restart. The app logged [HMR] success | Successfully applied update. with the same PID.
  • app.ts edit (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.

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.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 00741222-dfd0-4034-94ca-edd750813de8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@triniwiz
triniwiz merged commit a1e8001 into feat/windows Oct 23, 2026
9 checks passed
@triniwiz
triniwiz deleted the feat/windows-webpack-hmr branch October 23, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant