(code: string, origin: string, ver: number)
| 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. |
| 580 | function 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 |
| 590 | function ensureVersionedCoreImports(code: string, origin: string, ver: number): string { |
no test coverage detected