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

fix(vite): route unvendored plugin-patterned deps through /ns/m HTTP - #11459

Merged
NathanWalker merged 2 commits into
NativeScript:mainfrom
aleclarson:fix/vite-unvendored-plugin-deps
Sep 29, 2026
Merged

NathanWalker merged 2 commits into
NativeScript:mainfrom
aleclarson:fix/vite-unvendored-plugin-deps

Conversation

@aleclarson

Copy link
Copy Markdown
Contributor

Closes #11458.

Summary

In dev sessions, plugin-patterned specifiers absent from the vendor manifest — a package's own transitive plugin dependency under pnpm's isolated linker, an NS_VENDOR_EXCLUDEd package, or a flavor vendor.exclude entry — were rewritten to synchronous __nsVendorRequire calls against a registry with no entry, resolving to the __nsMissing stub (X is not a constructor downstream). The designed per-module HTTP fallback already serves these modules via Vite's importer-aware resolution (including .pnpm realpaths).

  • resolveVendorRouting (websocket-module-specifiers.ts): the isLikelyNativeScriptRuntimePluginSpecifier fast paths now require manifest membership when a manifest is active.
  • ensureNativeScriptModuleBindings (websocket-module-bindings.ts): canonical is dropped when the active manifest doesn't contain it, and the isLikelyNativeScriptPluginSpecifier force-canonical branch requires resolveVendorSpecifier when a manifest is active.

Both gates preserve legacy behavior while no manifest exists (unit tests, early boot).

Verified in a pnpm nodeLinker: isolated workspace: an unvendored transitive @nativescript-community/ui-image import in a leaf package now emits import { Img } from "/ns/m/node_modules/.pnpm/@nativescript-community+ui-image@4.6.20/node_modules/@nativescript-community/ui-image/index.ios.js", which serves real transformed code.

Test plan

  • npx nx run vite:test — all specs pass except typescript-optional.spec.ts, which fails identically on main in this checkout (environmental).
  • New regression spec: resolveVendorRouting returns null for a plugin-patterned package absent from the manifest (websocket-vendor-routing.spec.ts).
  • New regression spec: ensureNativeScriptModuleBindings keeps an unvendored plugin import unbound (websocket-vendor-bindings.spec.ts).
  • e2e: ns run against a pnpm-linked wrapper package — verified manually, not covered by apps/automated.

Plugin-patterned specifiers (@nativescript/*, @nativescript-community/*,
nativescript-*) absent from the vendor manifest — e.g. a package's own
transitive dependency under pnpm's isolated linker, NS_VENDOR_EXCLUDE'd
packages, or flavor vendor.exclude entries — were rewritten to synchronous
__nsVendorRequire calls against a registry with no entry, resolving to the
__nsMissing stub. The designed per-module HTTP fallback already serves these
(via Vite's importer-aware resolution, including .pnpm realpaths).

resolveVendorRouting's plugin fast paths and
ensureNativeScriptModuleBindings' force-canonical now require vendor
manifest membership when a manifest is active, leaving unvendored plugin
imports as HTTP imports. Behavior is unchanged while no manifest exists
(unit tests, early boot).

Refs NativeScript#11458
@nx-cloud

nx-cloud Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit aa2a1ee

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 47s 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-29 21:29:43 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: aa2a1ee

@NathanWalker NathanWalker self-assigned this Sep 27, 2026
aleclarson added a commit to octane-xplat/octane-xplat that referenced this pull request Sep 27, 2026
…er /ns/m

Vendor routing assumed plugin-patterned specifiers were always vendored:
unvendored transitive deps (plugin-bearing leaf packages under pnpm's
isolated linker, e.g. @octane-xplat/gif → @nativescript-community/ui-image)
rewrote to sync __nsVendorRequire calls against a registry with no entry,
resolving to the __nsMissing stub. With a manifest active, plugin-patterned
ids now require manifest membership — unvendored ones keep their bare/HTTP
form and resolve per-module via Vite's importer-aware resolution (verified:
the leaf emits a real /ns/m URL into .pnpm and it serves 200).

Upstream: NativeScript/NativeScript#11459. Drop the patch when a release
carries the fix.
…embership

Matches resolveVendorRouting's check so vendored plugins keep their existing
binding behavior; only packages absent from the manifest fall back to HTTP.
nativescript-oss pushed a commit to aleclarson/nativescript that referenced this pull request Sep 29, 2026
- guard the workspace fallback against escaping its node_modules dir
- probe pnpm's hoisted virtual store for deps of published packages
- probe only the active platform suffix so iOS never picks .android.js
- fix the spec's unterminated string literals
- drop the resolveVendorRouting change duplicated from NativeScript#11459
@NathanWalker
NathanWalker merged commit 491f0f0 into NativeScript:main Sep 29, 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.

fix(vite): unvendored plugin-patterned deps rewrite to __nsVendorRequire stubs instead of the /ns/m HTTP fallback

2 participants