Skip to content

fix(vite): serve a symlinked nativescript-vue as library code in HMR - #11430

Merged
NathanWalker merged 1 commit into
NativeScript:mainfrom
rigor789:fix/vite-hmr-symlinked-runtime
Sep 14, 2026
Merged

NathanWalker merged 1 commit into
NativeScript:mainfrom
rigor789:fix/vite-hmr-symlinked-runtime

Conversation

@rigor789

Copy link
Copy Markdown
Member

PR Checklist

What is the current behavior?

With nativescript-vue installed as a symlink (file:../path or npm link), ns debug ios fails at boot with _defineComponent is not a function. websocket-ns-m.ts classified the served /ns/m/node_modules/nativescript-vue request from resolvedCandidate || spec; the resolved candidate of a symlinked package is its real path, which has no node_modules/ segment, so the module counted as app source and processCodeForDevice ran the app-only passes on it, injecting import { $navigateTo, $navigateBack } from "/ns/rt". The bridge then evaluated as a dependency of nativescript-vue, before the vendor registry had the package, and __ensure() cached {} for the rest of the session.

What is the new behavior?

  • classifyServedRequest(spec, resolvedId) classifies a request as library code when either the spec or the resolved id is under node_modules/ (or a workspace core/vite path). websocket-ns-m.ts uses it for the isNodeMod gate.
  • __ensure() in the /ns/rt bridge no longer caches a miss, so a later call sees the registration, and warns once ([ns-rt] nativescript-vue is not registered in the vendor registry yet…) so the failure is diagnosable.

Verified against the repro in nativescript-vue/nativescript-vue#1160: with a real directory the served module is clean; with the symlink the served module carried the bridge import.

Fixes #11429 (part 2; the rolldown alias problem in part 1 is a separate PR).

npx vitest run in packages/vite: the only failures are the pre-existing typescript-optional.spec.ts cases, which need a built package.

A served package request was classified from its resolved id alone. A
symlinked package (file: or npm link) resolves to a real path without a
node_modules segment, so it was treated as app source and received the
app-only passes, including an injected import of the /ns/rt bridge. The
bridge then evaluated before nativescript-vue was registered, cached an
empty object and left every binding undefined.

Classify from the request spec as well, and stop caching a registry
miss in __ensure() so a later lookup can succeed; warn once instead of
failing later with "X is not a function".

Fixes NativeScript#11429
@nx-cloud

nx-cloud Bot commented Sep 14, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit f7aa964

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 54s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-14 10:32:26 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11430
npm i https://pkg.pr.new/@nativescript/vite@11430
npm i https://pkg.pr.new/@nativescript/webpack@11430

commit: f7aa964

@NathanWalker
NathanWalker merged commit 3ed2ff7 into NativeScript:main Sep 14, 2026
7 checks passed
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.

vite: Vue flavor fails to build under rolldown and HMR breaks with a symlinked nativescript-vue

2 participants