Skip to content

fix(vite): serve deps-bundle shims for barrels that re-export a bare package - #11427

Merged
NathanWalker merged 1 commit into
mainfrom
fix/vite-hmr-bare-reexport-shims
Sep 10, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/vite-hmr-bare-reexport-shims

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Under HMR every bundled node_modules file must be served as a thin shim into /ns/deps-bundle.mjs, and the shim needs the file's static export list. Export discovery gave up on export * from '<pkg>', so nativescript-vue's index (which re-exports @vue/runtime-core) was served raw on top of its bundled copy and ran init() twice. Any per-module-served Vue plugin that imports nativescript-vue then failed to boot with "Element for AbsoluteLayout already registered". Found when testing deeper with @nativescript-community/ui-collectionview.

Bare re-export targets are now resolved from the importer the way Node does (nearest node_modules ancestor, exports map including patterns, platform suffixes) and followed. Only targets that resolve nowhere still fall back to per-module serving. The app's __FOO__ defines (the Vue feature flags @vitejs/plugin-vue sets) are also passed to the deps-bundle build so bundled dep code sees the same values as bundle.mjs.

…package

Under HMR every bundled node_modules file must be served as a thin shim into
/ns/deps-bundle.mjs, and the shim needs the file's static export list. Export
discovery gave up on `export * from '<pkg>'`, so nativescript-vue's index
(which re-exports @vue/runtime-core) was served raw on top of its bundled
copy and ran `init()` twice. Any per-module-served Vue plugin that imports
`nativescript-vue` then failed to boot with "Element for AbsoluteLayout
already registered".

Bare re-export targets are now resolved from the importer the way Node does
(nearest node_modules ancestor, exports map including patterns, platform
suffixes) and followed. Only targets that resolve nowhere still fall back to
per-module serving. The app's `__FOO__` defines (the Vue feature flags
@vitejs/plugin-vue sets) are also passed to the deps-bundle build so bundled
dep code sees the same values as bundle.mjs.
@nx-cloud

nx-cloud Bot commented Sep 10, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 8f9637f

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

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


☁️ Nx Cloud last updated this comment at 2026-09-10 00:06:43 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 8f9637f

@NathanWalker
NathanWalker merged commit 9b9043a into main Sep 10, 2026
9 of 10 checks passed
@NathanWalker
NathanWalker deleted the fix/vite-hmr-bare-reexport-shims branch September 10, 2026 20:12
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.

1 participant