MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / ensureVersionedRtImports

Function ensureVersionedRtImports

packages/vite/hmr/server/websocket.ts:580–587  ·  view source on GitHub ↗
(code: string, origin: string, ver: number)

Source from the content-addressed store, hash-verified

578// Ensure imports of the NativeScript-Vue runtime bridge '/ns/rt' are versioned to
579// bust the device HTTP loader cache whenever the HMR graph version increments.
580function ensureVersionedRtImports(code: string, origin: string, ver: number): string {
581 if (!code || !origin || !Number.isFinite(ver)) return code;
582 // Static imports: import { ... } from ".../ns/rt" (plus optional version)
583 code = code.replace(/(from\s+["'])(?:https?:\/\/[^"']+)?\/(?:\ns|ns)\/rt(?:\/[\d]+)?(["'])/g, (_m, p1, p3) => `${p1}/ns/rt/${ver}${p3}`);
584 // Dynamic imports: import(".../ns/rt") (plus optional version)
585 code = code.replace(/(import\(\s*["'])(?:https?:\/\/[^"']+)?\/(?:\@ns|ns)\/rt(?:\/[\d]+)?(["']\s*\))/g, (_m, p1, p3) => `${p1}/ns/rt/${ver}${p3}`);
586 return code;
587}
588
589// Ensure imports of @nativescript/core resolve via the unified /ns/core bridge to keep a single realm
590function ensureVersionedCoreImports(code: string, origin: string, ver: number): string {

Callers 1

configureServerFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected