← 输入框|github.com|刷新
Skip to content

fix(vite): serve a plugin module under one URL whether imported or re-exported - #11540

Merged
NathanWalker merged 2 commits into
mainfrom
fix/vite-hmr-reexport-specifiers
Oct 21, 2026
Merged

NathanWalker merged 2 commits into
mainfrom
fix/vite-hmr-reexport-specifiers

Conversation

@triniwiz

Copy link
Copy Markdown
Member

PR Checklist

What is the current behavior?

For NativeScript runtime-plugin modules, ensureNativeScriptModuleBindings swaps a static import's resolved specifier for the authored spelling, which becomes /ns/m/node_modules/<pkg>/framework-registry. Re-exports and dynamic imports keep Vite's .../framework-registry.js. The device caches modules by URL, so one module is loaded twice under two URLs: with MasonKit, the framework adapter registers in one copy of its registry while views read the other, and layout never runs.

What is the new behavior?

In the main realm, value re-exports (export … from, export * from) and string-literal dynamic imports get the same preserved specifier as static imports, and the source scan that builds the overrides includes them. Worker serves are unchanged. On a real dev server, the only change to MasonKit's served modules is that the re-export URLs now match the imports.

Tests: a case in hmr/server/websocket-source-intent.spec.ts covering import, re-export, export * and dynamic import.

Each new test fails without the change. The @nativescript/vite suite (163 files) and tsc -p tsconfig.lib.json pass on the branch.

…-exported

Under HMR the main realm serves a NativeScript plugin's modules under the
authored spelling of their imports: `import { x } from './framework-registry'`
reaches the device as `/ns/m/node_modules/<pkg>/framework-registry`. Re-exports
and dynamic imports kept Vite's resolved `.../framework-registry.js`. The
device caches modules by URL, so a module imported in one file and
re-exported from another was evaluated twice. MasonKit's entry re-exports
what its internals import, so its Vue adapter registered into one copy of
the framework registry while views read the other, and layout never ran.

Re-exports (`export * from`, `export { a } from`) and string-literal dynamic
imports now get the same specifier a static import of that module gets, and
the source scan that records the authored spellings includes them too.
Worker serves already use the resolved file for both and are unchanged.
@nx-cloud

nx-cloud Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 636da11

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 13s 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-10-15 20:43:10 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 636da11

@NathanWalker
NathanWalker merged commit 1fa08a4 into main Oct 21, 2026
10 checks passed
@NathanWalker
NathanWalker deleted the fix/vite-hmr-reexport-specifiers branch October 21, 2026 18:38
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.

2 participants