Skip to content

HMR only works when editing the initial screen set in app.ts; other screens do not update #1099

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

Open
pazfelipe opened this issue May 30, 2025 · 2 comments

Comments

@pazfelipe
Copy link

HMR (Hot Module Replacement) is only working when changes are made to the component that is directly set in app.ts. If I navigate to another screen (e.g., using $navigateTo()), and make edits to that screen’s file, changes are not reflected unless I manually edit the initial screen to force a reload.


🔁 Steps to reproduce

  1. Create a new project:
ns create test --template @nativescript-vue/template-blank@latest
  1. Create the file ./src/pages/auth/sign-in.vue with this content:
<template>
  <Page actionBarHidden="true">
    <StackLayout class="p-4 bg-slate-50">
      <Button
        text="Back"
        @tap="$navigateBack()"
      />
      <Label text="Sign In" />
    </StackLayout>
  </Page>
</template>
  1. Create the file ./src/pages/Home.vue with this content:
<template>
  <Frame>
    <Page actionBarHidden="true">
      <StackLayout>
        <Button
          text="Sign In"
          @tap="$navigateTo(SignIn)"
        />
      </StackLayout>
    </Page>
  </Frame>
</template>

<script lang="ts" setup>
import SignIn from "./auth/sign-in.vue";
</script>
  1. Make sure Home.vue is the root component used in app.ts.
import { createApp } from 'nativescript-vue';
import Home from './pages/Home.vue';

createApp(Home).start();

✅ How to test

  • Run the app
  • Tap the Sign In button to navigate to the sign-in.vue screen
  • While staying on the SignIn screen, make any change in sign-in.vue (e.g., text, layout, etc.)
  • Nothing happens.
  • Now, edit Home.vue (e.g., add a space) — the app reloads and goes back to the initial screen
  • Navigate to Sign In again — you’ll now see the updated version

💻 My environment

  • macOS Sequoia 15.5 (M2 Pro)
  • Happens on both iOS and Android
  • NativeScript Vue 3 with $navigateTo() +

🔧 Expected behavior

HMR should reflect changes in any active screen component, regardless of whether it is the initial component set in app.ts.

@vallemar
Copy link
Contributor

vallemar commented May 30, 2025

Hi @pazfelipe. I've been doing some research, and it seems that for some reason @vue/runtime-core has stopped calling this method on hot reload. I'll try to dig deeper and see which version of vue it stopped working on

@MrSnoozles
Copy link
Contributor

MrSnoozles commented Jun 1, 2025

@pazfelipe HMR used to be working almost perfectly with 3.0.0-rc.2 as far as I remember. You could try downgrading to that version. There haven't been that many changes since RC2. With 3.0.0-rc.3 the dependencies have been bumped, I guess that's where it stopped working. (@vue/runtime-core has been updated from ^3.4.23 to ^3.5.13. If vallemar's research is right that's probably why it stopped working)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants