Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
@pazfelipe

Description

@pazfelipe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions