Skip to content

Feat: FastSync - partially workaround for current HMR issues #922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

minhnhut
Copy link

Hi,
This PR is my attempt to workaround for HMR issues on current NS-Vue projects.
Took advantages of replacePage in PR NativeScript/NativeScript#9460 (Thanks to @rigor789).

I am using this workaround in some production projects. It is not perfect, but far better than manually navigate away from current Page then re-open Page everytime when I made some changes. Quick feedback for developers, dramatically increase team's productivity.

Demo: https://1drv.ms/v/s!AhQCuPihXuRXgYUX5ND8b_ozUJxjCA?e=jyXjjv

How to use:

  • Simply set Vue.config.fastSync = true (default is false)
  • Run app on device
  • Navigate to a Page
  • Change Page's source code: template, script or style
  • See changes applied
  • Caution: Keep fastSync set to false when building release, as it may not be stable if let running in production

What works:

  • Current Page will be replaced with new source code right after livesync completed
  • Works on <template> and <script>
  • Works with Typescript and Javascript project
  • Very fast reload, instead of restart whole application like --no-hmr do

What doesn't work

  • A very first page - main page, which rendered with Application $start() will not be fast synced. Only work on pages that user navigated to after that. => Recommend: Add a dummy Page when app start, then navigate away from it
  • Page's state is not preserved. Vuex's state not affected. => Fine for me, it would be a mess if keep state preserved anyway, not sure about others?
  • Not work with Modal
  • Only reload current displayed page, previous Page in navigation stack is not reload

Fixes:

Fatme and others added 30 commits March 18, 2019 14:13
…vue#413)

* add registerElement to NativeScriptVueConstructor

Fix:  `property 'registerElement' does not exist on type 'NativeScriptVueConstructor'.`

Currently, the function type is defined but was not included in the constructor.

* updated in contrast to nativescript-vue#409

updated to the latest master changes
…ipt-vue#444)

* fix (hmr): Fix navigation trigger on iOS when HMR reloads app if <script> is changed. See nativescript-vue#388

* fix (hmr): Better way to know if the HMR is reloaded. See nativescript-vue#388

* fix (hmr): Fix the Android version for the HMR issue. See nativescript-vue#388

* chore (hmr): Remove comment.

* chore (hmr): Move comment.
In case `--bundle` is not passed, the `before-checkForChanges` hook should stop the execution. However, in case `--bundle` is passed, it should allow the process to continue. Currently, even when `--bundle` is passed, the hook breaks the execution with error that you need to pass `--bundle`. The problem is that the hook checks the flag based on CLI's internal representation of the flag, but the internal structure has been changed since the PR that added this functionality has been added. Fix the hook to have correct check for bundle flag.
…oes not work with {N}-5.2 but works with {N}-5.3

This reverts commit 595d2a0.
rigor789 and others added 28 commits November 24, 2020 13:35
…nativescript-vue#811)

fixes nativescript-vue#809

* chore: remove unnecessary check from appendChild

* fix: remove node before appending if already a child

* fix: set nextSibling of prevSibling upon insertion (fixed)

* test: add test case for nativescript-vue#809
…escript-vue#773)

Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1. **This update includes a security fix.**
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](mikaelbr/node-notifier@v8.0.0...v8.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](npm/ini@v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ue#770)

Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](npm/ini@v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ript-vue#783)

Bumps [socket.io](https://github.com/socketio/socket.io) from 2.3.0 to 2.4.1.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/2.4.1/CHANGELOG.md)
- [Commits](socketio/socket.io@2.3.0...2.4.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.