@nativescript/vite 8.0.0-alpha.15 → 8.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configuration/base.js +20 -1
- package/configuration/base.js.map +1 -1
- package/configuration/solid.js +25 -19
- package/configuration/solid.js.map +1 -1
- package/helpers/ns-core-url.d.ts +8 -3
- package/helpers/ns-core-url.js +9 -8
- package/helpers/ns-core-url.js.map +1 -1
- package/helpers/solid-jsx-deps.d.ts +15 -0
- package/helpers/solid-jsx-deps.js +178 -0
- package/helpers/solid-jsx-deps.js.map +1 -0
- package/hmr/client/index.js +43 -6
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/entry-runtime.d.ts +1 -1
- package/hmr/entry-runtime.js +26 -8
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/helpers/ast-normalizer.js +9 -2
- package/hmr/helpers/ast-normalizer.js.map +1 -1
- package/hmr/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +2 -6
- package/hmr/server/core-sanitize.js +9 -28
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/import-map.js +22 -5
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/ns-rt-bridge.d.ts +51 -0
- package/hmr/server/ns-rt-bridge.js +131 -0
- package/hmr/server/ns-rt-bridge.js.map +1 -0
- package/hmr/server/websocket-core-bridge.d.ts +37 -10
- package/hmr/server/websocket-core-bridge.js +26 -56
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-ns-m-finalize.js +4 -2
- package/hmr/server/websocket-ns-m-finalize.js.map +1 -1
- package/hmr/server/websocket-served-module-helpers.js +2 -2
- package/hmr/server/websocket-served-module-helpers.js.map +1 -1
- package/hmr/server/websocket-vue-sfc.d.ts +0 -1
- package/hmr/server/websocket-vue-sfc.js +0 -16
- package/hmr/server/websocket-vue-sfc.js.map +1 -1
- package/hmr/server/websocket.d.ts +1 -1
- package/hmr/server/websocket.js +110 -211
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +1 -1
- package/hmr/shared/runtime/boot-placeholder-ui.js +1 -1
- package/hmr/shared/runtime/boot-progress.d.ts +1 -1
- package/hmr/shared/runtime/boot-progress.js +1 -1
- package/hmr/shared/runtime/root-placeholder.js +96 -56
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/vendor/manifest.js +55 -0
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/package.json +1 -1
- package/hmr/server/websocket-runtime-compat.d.ts +0 -19
- package/hmr/server/websocket-runtime-compat.js +0 -287
- package/hmr/server/websocket-runtime-compat.js.map +0 -1
package/hmr/server/websocket.js
CHANGED
|
@@ -18,6 +18,7 @@ import * as path from 'path';
|
|
|
18
18
|
import { createHash } from 'crypto';
|
|
19
19
|
import * as PAT from './constants.js';
|
|
20
20
|
import { getVendorManifest, resolveVendorSpecifier } from '../shared/vendor/registry.js';
|
|
21
|
+
import { buildNsRtBridgeModule, discoverNsvBridgeExports } from './ns-rt-bridge.js';
|
|
21
22
|
import { getMonorepoWorkspaceRoot, getPackageJson, getProjectFilePath, getProjectRootPath } from '../../helpers/project.js';
|
|
22
23
|
import { loadPrebuiltVendorManifest } from '../shared/vendor/manifest-loader.js';
|
|
23
24
|
import '../vendor-bootstrap.js';
|
|
@@ -43,13 +44,13 @@ import { classifyBootRoute, classifyHmrUpdateKind, createColdBootRequestCounter,
|
|
|
43
44
|
import { createHmrPendingMessage } from './websocket-hmr-pending.js';
|
|
44
45
|
import { extractVitePrebundleId, filterExistingNodeModulesTransformCandidates, getBlockedDeviceNodeModulesReason, getFlattenedManifestMap, isCoreGlobalsReference, isEsmFrameworkPackageSpecifier, isLikelyNativeScriptPluginSpecifier, isLikelyNativeScriptRuntimePluginSpecifier, isNativeScriptCoreModule, isNativeScriptPluginModule, normalizeNativeScriptCoreSpecifier, normalizeNodeModulesSpecifier, resolveCandidateFilePath, resolveInternalRuntimePluginBareSpecifier, resolveNodeModulesPackageBoundary, resolveVendorFromCandidate, resolveVendorRouting, rewriteFsAbsoluteToNsM, shouldPreserveBareRuntimePluginSubpathImport, stripDecoratedServePrefixes, tryReadRawExplicitJavaScriptModule, viteDepsPathToBareSpecifier, } from './websocket-module-specifiers.js';
|
|
45
46
|
import { ensureNativeScriptModuleBindings, getProcessCodeResolvedSpecifierOverrides } from './websocket-module-bindings.js';
|
|
46
|
-
import { collectStaticExportNamesFromFile, collectStaticExportOriginsFromFile,
|
|
47
|
+
import { collectStaticExportNamesFromFile, collectStaticExportOriginsFromFile, extractDirectExportedNames, normalizeCoreExportOriginsForRuntime, parseCoreBridgeRequest, resolveRuntimeCoreModulePath } from './websocket-core-bridge.js';
|
|
47
48
|
import { createSharedTransformRequestRunner } from './shared-transform-request.js';
|
|
48
49
|
import { formatNsMHmrServeTag, getNumericServeVersionTag, rewriteNsMImportPathForHmr } from './websocket-ns-m-paths.js';
|
|
49
50
|
import { ensureDynamicHmrImportHelper } from './websocket-served-module-helpers.js';
|
|
50
51
|
export { ensureNativeScriptModuleBindings, getProcessCodeResolvedSpecifierOverrides } from './websocket-module-bindings.js';
|
|
51
52
|
export { stripDecoratedServePrefixes, tryReadRawExplicitJavaScriptModule } from './websocket-module-specifiers.js';
|
|
52
|
-
export { collectStaticExportNamesFromFile, collectStaticExportOriginsFromFile,
|
|
53
|
+
export { collectStaticExportNamesFromFile, collectStaticExportOriginsFromFile, normalizeCoreExportOriginsForRuntime, parseCoreBridgeRequest } from './websocket-core-bridge.js';
|
|
53
54
|
export { rewriteAngularEntryRegisterOnly } from './websocket-angular-entry.js';
|
|
54
55
|
// Re-export the canonical URL rewriter from `websocket-ns-m-paths.js` so the
|
|
55
56
|
// existing test suites (which import from `./websocket.js`) keep working
|
|
@@ -458,8 +459,7 @@ function stripViteDynamicImportVirtual(code) {
|
|
|
458
459
|
// is install-once-per-isolate, dedupes per-URL (so semver's ~30 deep
|
|
459
460
|
// imports produce ~30 lines on the first boot and 0 on subsequent
|
|
460
461
|
// boots within the same isolate), and uses `console.warn` so the
|
|
461
|
-
// message reads as advisory
|
|
462
|
-
// LATEST-05-07-2026-HMR_ANGULAR_DEBUG_SESSION.md). Forensic detail
|
|
462
|
+
// message reads as advisory. Forensic detail
|
|
463
463
|
// (stack) lives on `globalThis.__NS_REQUIRE_GUARD_LAST__` for
|
|
464
464
|
// post-mortem inspection. Set `globalThis.__NS_REQUIRE_GUARD_VERBOSE__`
|
|
465
465
|
// to `true` before any module loads to restore per-call logging.
|
|
@@ -1209,6 +1209,22 @@ function processCodeForDevice(code, isVitePreBundled, preserveVendorImports = fa
|
|
|
1209
1209
|
// Running the normalizer on libraries like tslib injects harmful destructures
|
|
1210
1210
|
// (e.g., `const { SuppressedError } = __ns_rt_ns_1`) that shadow globals.
|
|
1211
1211
|
if (!isNodeModule) {
|
|
1212
|
+
// CRITICAL ORDERING: canonicalise any bare `@nativescript/core[/sub]`
|
|
1213
|
+
// specifiers to `/ns/core[/sub]` BEFORE the AST normaliser sees them.
|
|
1214
|
+
// `astNormalizeModuleImportsAndHelpers` defensively rewrites bare
|
|
1215
|
+
// `@nativescript/core` imports and emits a one-shot
|
|
1216
|
+
// `[ast-normalizer] unexpected @nativescript/core spec` warning —
|
|
1217
|
+
// the warning means the upstream rewriter regressed. For Vue SFC
|
|
1218
|
+
// `<script>` blocks the bare specifier flows through Vite's
|
|
1219
|
+
// transform pipeline without a per-statement source-string rewrite
|
|
1220
|
+
// (Vite's resolver only edits the module graph, not the emitted
|
|
1221
|
+
// code), so the only upstream rewriter that can canonicalise these
|
|
1222
|
+
// in dev mode is this regex sweep. Running it here keeps the AST
|
|
1223
|
+
// normaliser purely a tripwire instead of an active rewriter.
|
|
1224
|
+
try {
|
|
1225
|
+
result = sanitizeStrayCoreReferences(result);
|
|
1226
|
+
}
|
|
1227
|
+
catch { }
|
|
1212
1228
|
try {
|
|
1213
1229
|
result = astNormalizeModuleImportsAndHelpers(result);
|
|
1214
1230
|
}
|
|
@@ -1413,8 +1429,7 @@ function processCodeForDevice(code, isVitePreBundled, preserveVendorImports = fa
|
|
|
1413
1429
|
const vendorCoreRE1 = /globalThis\.__nsVendor\s*\(\s*["']@nativescript\/core["']\s*\)/g;
|
|
1414
1430
|
const vendorCoreRE2 = /__nsVendor\s*\(\s*["']@nativescript\/core["']\s*\)/g;
|
|
1415
1431
|
if (vendorCoreRE1.test(result) || vendorCoreRE2.test(result)) {
|
|
1416
|
-
|
|
1417
|
-
const hasImport = /import\s+__ns_core_bridge\s+from\s+["'][^"']*\/(?:\@ns|ns)\/core(?:\/[\d]+)?(?:\?p=[^"']+)?["']\s*;?/.test(result) || /(^|\n)\s*import\s+__ns_core_bridge\s+from\s+["']\/(?:\@ns|ns)\/core["']\s*;?/m.test(result);
|
|
1432
|
+
const hasImport = /import\s+__ns_core_bridge\s+from\s+["'][^"']*\/(?:\@ns|ns)\/core(?:\/[^"']+)?["']\s*;?/.test(result) || /(^|\n)\s*import\s+__ns_core_bridge\s+from\s+["']\/(?:\@ns|ns)\/core["']\s*;?/m.test(result);
|
|
1418
1433
|
if (!hasImport) {
|
|
1419
1434
|
result = `import __ns_core_bridge from "/ns/core";\n` + result;
|
|
1420
1435
|
}
|
|
@@ -1428,7 +1443,7 @@ function processCodeForDevice(code, isVitePreBundled, preserveVendorImports = fa
|
|
|
1428
1443
|
const reqCoreRE1 = /(^|[^.\w$])require\(\s*["']@nativescript\/core([^"'\n]*)["']\s*\)/g;
|
|
1429
1444
|
const reqCoreRE2 = /(?:globalThis|window|self)\.require\(\s*["']@nativescript\/core([^"'\n]*)["']\s*\)/g;
|
|
1430
1445
|
if (reqCoreRE1.test(result) || reqCoreRE2.test(result)) {
|
|
1431
|
-
const hasImport = /import\s+__ns_core_bridge\s+from\s+["'][^"']*\/(?:\@ns|ns)\/core(?:\/[
|
|
1446
|
+
const hasImport = /import\s+__ns_core_bridge\s+from\s+["'][^"']*\/(?:\@ns|ns)\/core(?:\/[^"']+)?["']\s*;?/.test(result) || /(^|\n)\s*import\s+__ns_core_bridge\s+from\s+["']\/(?:\@ns|ns)\/core["']\s*;?/m.test(result);
|
|
1432
1447
|
if (!hasImport) {
|
|
1433
1448
|
result = `import __ns_core_bridge from "/ns/core";\n` + result;
|
|
1434
1449
|
}
|
|
@@ -1458,7 +1473,7 @@ function processCodeForDevice(code, isVitePreBundled, preserveVendorImports = fa
|
|
|
1458
1473
|
return m.length === 2 ? `${m[0].trim()}: ${m[1].trim()}` : seg;
|
|
1459
1474
|
})
|
|
1460
1475
|
.join(', ');
|
|
1461
|
-
const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[
|
|
1476
|
+
const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
|
|
1462
1477
|
result = result.replace(reNamed, (_full, pfx, specList, src) => {
|
|
1463
1478
|
// Deep subpath URLs serve actual ESM with real named exports — skip.
|
|
1464
1479
|
if (isDeepCoreSubpath(src))
|
|
@@ -1468,7 +1483,7 @@ function processCodeForDevice(code, isVitePreBundled, preserveVendorImports = fa
|
|
|
1468
1483
|
const decl = `const { ${toDestructureCore(specList)} } = ${tmp};`;
|
|
1469
1484
|
return `${pfx}import ${tmp} from ${JSON.stringify(src)};\n${decl}\n`;
|
|
1470
1485
|
});
|
|
1471
|
-
const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[
|
|
1486
|
+
const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
|
|
1472
1487
|
result = result.replace(reMixed, (_full, pfx, defName, specList, src) => {
|
|
1473
1488
|
if (isDeepCoreSubpath(src))
|
|
1474
1489
|
return _full;
|
|
@@ -1713,7 +1728,10 @@ function assertNoOptimizedArtifacts(code, contextLabel) {
|
|
|
1713
1728
|
}
|
|
1714
1729
|
}
|
|
1715
1730
|
// Ensure there are no lingering named imports from the unified core bridge.
|
|
1716
|
-
// Converts named imports from
|
|
1731
|
+
// Converts named imports from `/ns/core[/<sub>]` into default import +
|
|
1732
|
+
// destructuring. The package-main bridge serves a shape-shifted module whose
|
|
1733
|
+
// named exports come from `__ns_core_bridge.default` rather than ESM named
|
|
1734
|
+
// exports, so a named-import binding would be `undefined` at evaluation.
|
|
1717
1735
|
function ensureDestructureCoreImports(code) {
|
|
1718
1736
|
try {
|
|
1719
1737
|
let result = code;
|
|
@@ -1727,8 +1745,8 @@ function ensureDestructureCoreImports(code) {
|
|
|
1727
1745
|
return m.length === 2 ? `${m[0].trim()}: ${m[1].trim()}` : seg;
|
|
1728
1746
|
})
|
|
1729
1747
|
.join(', ');
|
|
1730
|
-
// import { A, B } from '/ns/core[
|
|
1731
|
-
const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[
|
|
1748
|
+
// import { A, B } from '/ns/core[/<sub>]'
|
|
1749
|
+
const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
|
|
1732
1750
|
result = result.replace(reNamed, (_full, pfx, specList, src) => {
|
|
1733
1751
|
// Deep subpath URLs serve actual ESM with real named exports — skip.
|
|
1734
1752
|
if (isDeepCoreSubpath(src))
|
|
@@ -1738,8 +1756,8 @@ function ensureDestructureCoreImports(code) {
|
|
|
1738
1756
|
const decl = `const { ${toDestructure(specList)} } = ${tmp};`;
|
|
1739
1757
|
return `${pfx}import ${tmp} from ${JSON.stringify(src)};\n${decl}\n`;
|
|
1740
1758
|
});
|
|
1741
|
-
// import Default, { A, B } from '/ns/core[
|
|
1742
|
-
const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[
|
|
1759
|
+
// import Default, { A, B } from '/ns/core[/<sub>]'
|
|
1760
|
+
const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
|
|
1743
1761
|
result = result.replace(reMixed, (_full, pfx, defName, specList, src) => {
|
|
1744
1762
|
if (isDeepCoreSubpath(src))
|
|
1745
1763
|
return _full;
|
|
@@ -1856,6 +1874,27 @@ function dedupeRtNamedImportsAgainstDestructures(code) {
|
|
|
1856
1874
|
*/
|
|
1857
1875
|
export function rewriteImports(code, importerPath, sfcFileMap, depFileMap, projectRoot, verbose = false, outputDirOverrideRel, httpOrigin, resolveVendorAsHttp = false) {
|
|
1858
1876
|
let result = code;
|
|
1877
|
+
// Pre-normalize concatenated imports onto their own lines.
|
|
1878
|
+
//
|
|
1879
|
+
// Babel's `genCode(ast, { retainLines: true })` in
|
|
1880
|
+
// `astNormalizeModuleImportsAndHelpers` (which runs before us in the SFC
|
|
1881
|
+
// asm pipeline, and in several other hot paths) can emit multiple
|
|
1882
|
+
// statements on a single line, e.g.:
|
|
1883
|
+
// `} = __ns_rt_ns_1;import { $goTo } from "../utils";import PageWrapper from ...;`
|
|
1884
|
+
//
|
|
1885
|
+
// IMPORT_PATTERN_1/_2/_3/SIDE_EFFECT all anchor on `(?:^|\n)\s*import`,
|
|
1886
|
+
// so any import past the first one on a single line is silently dropped
|
|
1887
|
+
// by the rewriter. Downstream that leaves bare relative specifiers like
|
|
1888
|
+
// `../utils` to be resolved by the iOS HTTP ESM loader, which interprets
|
|
1889
|
+
// them relative to the `/ns/asm/0?path=...` URL and 404s on the
|
|
1890
|
+
// resulting `/ns/utils`. Splitting `;import` onto its own line makes the
|
|
1891
|
+
// existing patterns match every import, restoring the rewrite contract.
|
|
1892
|
+
//
|
|
1893
|
+
// Mirrors the same normalization already performed in
|
|
1894
|
+
// `core-sanitize.ts::normalizeStrayCoreStringLiterals` (`;\s*import` →
|
|
1895
|
+
// `;\nimport`) but applied universally at the rewriter entry point so
|
|
1896
|
+
// every caller benefits without having to opt in.
|
|
1897
|
+
result = result.replace(/;\s*import\s+/g, ';\nimport ');
|
|
1859
1898
|
const httpOriginSafe = httpOrigin;
|
|
1860
1899
|
const mixedRuntimePluginHttpRootPackages = collectMixedRuntimePluginHttpRootPackages(result, projectRoot);
|
|
1861
1900
|
const isDynamicImportPrefix = (prefix) => /import\(\s*["']?$/.test(prefix.trimStart());
|
|
@@ -1873,13 +1912,14 @@ export function rewriteImports(code, importerPath, sfcFileMap, depFileMap, proje
|
|
|
1873
1912
|
try {
|
|
1874
1913
|
let coreAliasIdx = 0;
|
|
1875
1914
|
const mkAlias = () => `__NSC${coreAliasIdx++}`;
|
|
1876
|
-
// Use the canonical PATH form `/ns/core/<sub
|
|
1877
|
-
//
|
|
1878
|
-
//
|
|
1879
|
-
//
|
|
1880
|
-
//
|
|
1881
|
-
//
|
|
1882
|
-
// the same
|
|
1915
|
+
// Use the canonical PATH form `/ns/core/<sub>`. The iOS HTTP ESM
|
|
1916
|
+
// loader caches module records by URL string — every emitter
|
|
1917
|
+
// (`buildCoreUrl()` / `buildCoreUrlPath()`, the runtime import map,
|
|
1918
|
+
// vendor `require()` shims, app-side rewrites, the cold-boot
|
|
1919
|
+
// preload in `entry-runtime.ts`) MUST produce the same byte
|
|
1920
|
+
// string for the same logical core subpath. A divergence creates
|
|
1921
|
+
// two distinct V8 module records for the same source. Each gets
|
|
1922
|
+
// its own class
|
|
1883
1923
|
// identities (TextBase, View, etc.), and side-effect patches
|
|
1884
1924
|
// applied to one (e.g. @nativescript-community/text's
|
|
1885
1925
|
// `TextBase.prototype.setTextDecorationAndTransform` override
|
|
@@ -2248,6 +2288,40 @@ export function rewriteImports(code, importerPath, sfcFileMap, depFileMap, proje
|
|
|
2248
2288
|
return `${prefix}./${depFile}${suffix}`;
|
|
2249
2289
|
}
|
|
2250
2290
|
}
|
|
2291
|
+
// ── Bare specifier vendor routing ────────────────────────────
|
|
2292
|
+
// Bare specifiers like `pinia`, `dayjs`, `lodash` never reach
|
|
2293
|
+
// the `nodeModulesSpecifier` branch above because
|
|
2294
|
+
// `normalizeNodeModulesSpecifier` keys on a literal
|
|
2295
|
+
// `/node_modules/` segment in the path. Without this check
|
|
2296
|
+
// they'd fall straight into the HTTP fallback below and get
|
|
2297
|
+
// rewritten to `/ns/m/node_modules/<spec>`, which serves the
|
|
2298
|
+
// package source over HTTP and bypasses the device-side import
|
|
2299
|
+
// map's `<pkg>` → `ns-vendor://<pkg>` entry. For CJS/UMD
|
|
2300
|
+
// packages (e.g. Pinia) the bare HTTP path doesn't expose the
|
|
2301
|
+
// full named-exports surface (only the default export round-
|
|
2302
|
+
// trips), so consumers like
|
|
2303
|
+
// `import { defineStore } from "pinia"` blow up at instantiate
|
|
2304
|
+
// time with `SyntaxError: ... does not provide an export named
|
|
2305
|
+
// 'defineStore'`. Preserving the bare spec lets the vendor
|
|
2306
|
+
// bridge serve it from the prebuilt `bundle.mjs`, which already
|
|
2307
|
+
// re-exports the full CJS surface. Subpath imports
|
|
2308
|
+
// (`pinia/plugins/foo`) intentionally fall through to the
|
|
2309
|
+
// HTTP fallback — `resolveVendorRouting` returns
|
|
2310
|
+
// `{ route: 'http' }` for non-main-entry subpaths even when the
|
|
2311
|
+
// root package is in the manifest, mirroring the
|
|
2312
|
+
// `nodeModulesSpecifier` branch.
|
|
2313
|
+
if (spec && !spec.startsWith('/') && !spec.startsWith('./') && !spec.startsWith('../') && !/^https?:\/\//i.test(spec) && !spec.startsWith('ns-vendor:') && !spec.startsWith('@nativescript/core')) {
|
|
2314
|
+
const bareNpmRe = /^(?:@[A-Za-z0-9][\w.-]*\/)?[A-Za-z0-9][\w.-]*(?:\/[\w.\-/]+)?$/;
|
|
2315
|
+
if (bareNpmRe.test(spec)) {
|
|
2316
|
+
const bareVendorRouting = resolveVendorRouting(spec, projectRoot);
|
|
2317
|
+
if (bareVendorRouting?.route === 'vendor') {
|
|
2318
|
+
if (verbose) {
|
|
2319
|
+
console.log(`[rewrite] bare vendor import: ${spec} → ${bareVendorRouting.bareSpec}`);
|
|
2320
|
+
}
|
|
2321
|
+
return `${prefix}${bareVendorRouting.bareSpec}${suffix}`;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2251
2325
|
// Bare npm package specifier fallback — route to /ns/m/node_modules/.
|
|
2252
2326
|
// This catches specifiers like `source-map-js/lib/source-map-generator.js`
|
|
2253
2327
|
// emitted by helpers such as the CommonJS compat transform, which Vite
|
|
@@ -3143,7 +3217,6 @@ function createHmrWebSocketPlugin(opts) {
|
|
|
3143
3217
|
const origin = getServerOrigin(server);
|
|
3144
3218
|
code = ensureVersionedRtImports(code, origin, graphVersion);
|
|
3145
3219
|
code = ACTIVE_STRATEGY.ensureVersionedImports(code, origin, graphVersion);
|
|
3146
|
-
code = ensureVersionedCoreImports(code, origin, graphVersion);
|
|
3147
3220
|
}
|
|
3148
3221
|
catch { }
|
|
3149
3222
|
// Compute rel .mjs output path
|
|
@@ -3200,7 +3273,6 @@ function createHmrWebSocketPlugin(opts) {
|
|
|
3200
3273
|
try {
|
|
3201
3274
|
depCode = ensureVersionedRtImports(depCode, getServerOrigin(server), graphVersion);
|
|
3202
3275
|
depCode = ACTIVE_STRATEGY.ensureVersionedImports(depCode, getServerOrigin(server), graphVersion);
|
|
3203
|
-
depCode = ensureVersionedCoreImports(depCode, getServerOrigin(server), graphVersion);
|
|
3204
3276
|
}
|
|
3205
3277
|
catch { }
|
|
3206
3278
|
let depRel = depResolved.replace(/^\//, '').replace(/\.(tsx?|jsx?)$/i, '.mjs');
|
|
@@ -3928,7 +4000,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
3928
4000
|
const verNum = 0;
|
|
3929
4001
|
code = ensureVersionedRtImports(code, getServerOrigin(server), verNum);
|
|
3930
4002
|
code = ACTIVE_STRATEGY.ensureVersionedImports(code, getServerOrigin(server), verNum);
|
|
3931
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), verNum);
|
|
3932
4003
|
}
|
|
3933
4004
|
catch { }
|
|
3934
4005
|
// `/ns/m` URL finalize step.
|
|
@@ -4140,162 +4211,15 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
4140
4211
|
res.setHeader('Expires', '0');
|
|
4141
4212
|
const rtVerSeg = urlObj.pathname.replace(/^\/ns\/rt\/?/, '');
|
|
4142
4213
|
const rtVer = /^[0-9]+$/.test(rtVerSeg) ? rtVerSeg : String(graphVersion || 0);
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
`const __RT_REALM_TAG = (globalThis.__NS_RT_REALM__ ||= Math.random().toString(36).slice(2));\n` +
|
|
4153
|
-
// One-shot evaluation marker to confirm the bridge is executed on
|
|
4154
|
-
// device. Gated on __NS_ENV_VERBOSE__ so it stays silent unless
|
|
4155
|
-
// the developer opts in via NS_VITE_VERBOSE / VITE_DEBUG_LOGS.
|
|
4156
|
-
`try { if (!(globalThis.__NS_RT_ONCE__ && globalThis.__NS_RT_ONCE__.eval)) { (globalThis.__NS_RT_ONCE__ ||= {}).eval = true; if (globalThis.__NS_ENV_VERBOSE__) console.log('[ns-rt] evaluated', { rtRealm: __RT_REALM_TAG }); } } catch {}\n` +
|
|
4157
|
-
`function __ensure(){\n` +
|
|
4158
|
-
` if (__cached_rt) return __cached_rt;\n` +
|
|
4159
|
-
` let vm = null;\n` +
|
|
4160
|
-
` try { vm = reg && reg.has && reg.has('nativescript-vue') ? reg.get('nativescript-vue') : (typeof req==='function' ? req('nativescript-vue') : null); } catch {}\n` +
|
|
4161
|
-
` if (!vm) { try { vm = reg && reg.has && reg.has('vue') ? reg.get('vue') : (typeof req==='function' ? req('vue') : null); } catch {} }\n` +
|
|
4162
|
-
` const rt = (vm && (vm.default ?? vm)) || {};\n` +
|
|
4163
|
-
` __cached_vm = vm;\n` +
|
|
4164
|
-
` __cached_rt = rt;\n` +
|
|
4165
|
-
` return rt;\n` +
|
|
4166
|
-
`}\n` +
|
|
4167
|
-
`// Soft-globals for @nativescript/core when missing (dev-only safety)\n` +
|
|
4168
|
-
`try {\n` +
|
|
4169
|
-
` const dev = typeof __DEV__ !== 'undefined' ? __DEV__ : true;\n` +
|
|
4170
|
-
` if (dev) {\n` +
|
|
4171
|
-
` const ns = (__ns_core_bridge && (__ns_core_bridge.__esModule && __ns_core_bridge.default ? __ns_core_bridge.default : (__ns_core_bridge.default || __ns_core_bridge))) || __ns_core_bridge || {};\n` +
|
|
4172
|
-
` if (ns) {\n` +
|
|
4173
|
-
` if (!g.Frame && ns.Frame) g.Frame = ns.Frame;\n` +
|
|
4174
|
-
` if (!g.Page && ns.Page) g.Page = ns.Page;\n` +
|
|
4175
|
-
` if (!g.Application && (ns.Application||ns.app||ns.application)) g.Application = (ns.Application||ns.app||ns.application);\n` +
|
|
4176
|
-
` }\n` +
|
|
4177
|
-
` }\n` +
|
|
4178
|
-
`} catch {}\n` +
|
|
4179
|
-
`const __get = (k) => { const rt = __ensure(); const v = rt && rt[k]; if (typeof v !== 'function' && v === undefined) { throw new Error('[ns-rt] missing export '+k); } return v; };\n` +
|
|
4180
|
-
`export const __realm = __RT_REALM_TAG;\n` +
|
|
4181
|
-
`export const defineComponent = (...a) => (__get('defineComponent'))(...a);\n` +
|
|
4182
|
-
`export const resolveComponent = (...a) => (__ensure().resolveComponent)(...a);\n` +
|
|
4183
|
-
`export const createVNode = (...a) => (__ensure().createVNode)(...a);\n` +
|
|
4184
|
-
`export const createTextVNode = (...a) => (__ensure().createTextVNode)(...a);\n` +
|
|
4185
|
-
`export const createCommentVNode = (...a) => (__ensure().createCommentVNode)(...a);\n` +
|
|
4186
|
-
`export const Fragment = (__ensure().Fragment);\n` +
|
|
4187
|
-
`export const Teleport = (__ensure().Teleport);\n` +
|
|
4188
|
-
`export const Transition = (__ensure().Transition);\n` +
|
|
4189
|
-
`export const TransitionGroup = (__ensure().TransitionGroup);\n` +
|
|
4190
|
-
`export const KeepAlive = (__ensure().KeepAlive);\n` +
|
|
4191
|
-
`export const Suspense = (__ensure().Suspense);\n` +
|
|
4192
|
-
`export const withCtx = (...a) => (__ensure().withCtx)(...a);\n` +
|
|
4193
|
-
`export const openBlock = (...a) => (__ensure().openBlock)(...a);\n` +
|
|
4194
|
-
`export const createBlock = (...a) => (__ensure().createBlock)(...a);\n` +
|
|
4195
|
-
`export const createElementVNode = (...a) => (__ensure().createElementVNode)(...a);\n` +
|
|
4196
|
-
`export const createElementBlock = (...a) => (__ensure().createElementBlock)(...a);\n` +
|
|
4197
|
-
`export const renderSlot = (...a) => (__ensure().renderSlot)(...a);\n` +
|
|
4198
|
-
`export const mergeProps = (...a) => (__ensure().mergeProps)(...a);\n` +
|
|
4199
|
-
`export const toHandlers = (...a) => (__ensure().toHandlers)(...a);\n` +
|
|
4200
|
-
`export const renderList = (...a) => (__ensure().renderList)(...a);\n` +
|
|
4201
|
-
`export const normalizeProps = (...a) => (__ensure().normalizeProps)(...a);\n` +
|
|
4202
|
-
`export const guardReactiveProps = (...a) => (__ensure().guardReactiveProps)(...a);\n` +
|
|
4203
|
-
`export const normalizeClass = (...a) => (__ensure().normalizeClass)(...a);\n` +
|
|
4204
|
-
`export const normalizeStyle = (...a) => (__ensure().normalizeStyle)(...a);\n` +
|
|
4205
|
-
`export const toDisplayString = (...a) => (__ensure().toDisplayString)(...a);\n` +
|
|
4206
|
-
`export const withDirectives = (...a) => (__ensure().withDirectives)(...a);\n` +
|
|
4207
|
-
`export const resolveDirective = (...a) => (__ensure().resolveDirective)(...a);\n` +
|
|
4208
|
-
`export const withModifiers = (...a) => (__ensure().withModifiers)(...a);\n` +
|
|
4209
|
-
`export const withKeys = (...a) => (__ensure().withKeys)(...a);\n` +
|
|
4210
|
-
`export const resolveDynamicComponent = (...a) => (__ensure().resolveDynamicComponent)(...a);\n` +
|
|
4211
|
-
`export const isVNode = (...a) => (__ensure().isVNode)(...a);\n` +
|
|
4212
|
-
`export const cloneVNode = (...a) => (__ensure().cloneVNode)(...a);\n` +
|
|
4213
|
-
`export const isRef = (...a) => (__ensure().isRef)(...a);\n` +
|
|
4214
|
-
`export const ref = (...a) => (__ensure().ref)(...a);\n` +
|
|
4215
|
-
`export const shallowRef = (...a) => (__ensure().shallowRef)(...a);\n` +
|
|
4216
|
-
`export const unref = (...a) => (__ensure().unref)(...a);\n` +
|
|
4217
|
-
`export const computed = (...a) => (__ensure().computed)(...a);\n` +
|
|
4218
|
-
`export const reactive = (...a) => (__ensure().reactive)(...a);\n` +
|
|
4219
|
-
`export const readonly = (...a) => (__ensure().readonly)(...a);\n` +
|
|
4220
|
-
`export const isReactive = (...a) => (__ensure().isReactive)(...a);\n` +
|
|
4221
|
-
`export const isReadonly = (...a) => (__ensure().isReadonly)(...a);\n` +
|
|
4222
|
-
`export const toRaw = (...a) => (__ensure().toRaw)(...a);\n` +
|
|
4223
|
-
`export const markRaw = (...a) => (__ensure().markRaw)(...a);\n` +
|
|
4224
|
-
`export const shallowReactive = (...a) => (__ensure().shallowReactive)(...a);\n` +
|
|
4225
|
-
`export const shallowReadonly = (...a) => (__ensure().shallowReadonly)(...a);\n` +
|
|
4226
|
-
`export const watch = (...a) => (__ensure().watch)(...a);\n` +
|
|
4227
|
-
`export const watchEffect = (...a) => (__ensure().watchEffect)(...a);\n` +
|
|
4228
|
-
`export const watchPostEffect = (...a) => (__ensure().watchPostEffect)(...a);\n` +
|
|
4229
|
-
`export const watchSyncEffect = (...a) => (__ensure().watchSyncEffect)(...a);\n` +
|
|
4230
|
-
`export const onBeforeMount = (...a) => (__ensure().onBeforeMount)(...a);\n` +
|
|
4231
|
-
`export const onMounted = (...a) => (__ensure().onMounted)(...a);\n` +
|
|
4232
|
-
`export const onBeforeUpdate = (...a) => (__ensure().onBeforeUpdate)(...a);\n` +
|
|
4233
|
-
`export const onUpdated = (...a) => (__ensure().onUpdated)(...a);\n` +
|
|
4234
|
-
`export const onBeforeUnmount = (...a) => (__ensure().onBeforeUnmount)(...a);\n` +
|
|
4235
|
-
`export const onUnmounted = (...a) => (__ensure().onUnmounted)(...a);\n` +
|
|
4236
|
-
`export const onActivated = (...a) => (__ensure().onActivated)(...a);\n` +
|
|
4237
|
-
`export const onDeactivated = (...a) => (__ensure().onDeactivated)(...a);\n` +
|
|
4238
|
-
`export const onErrorCaptured = (...a) => (__ensure().onErrorCaptured)(...a);\n` +
|
|
4239
|
-
`export const onRenderTracked = (...a) => (__ensure().onRenderTracked)(...a);\n` +
|
|
4240
|
-
`export const onRenderTriggered = (...a) => (__ensure().onRenderTriggered)(...a);\n` +
|
|
4241
|
-
`export const nextTick = (...a) => (__ensure().nextTick)(...a);\n` +
|
|
4242
|
-
`export const h = (...a) => (__ensure().h)(...a);\n` +
|
|
4243
|
-
`export const provide = (...a) => (__ensure().provide)(...a);\n` +
|
|
4244
|
-
`export const inject = (...a) => (__ensure().inject)(...a);\n` +
|
|
4245
|
-
`export const vShow = (__ensure().vShow);\n` +
|
|
4246
|
-
`export const createApp = (...a) => (__ensure().createApp)(...a);\n` +
|
|
4247
|
-
`export const registerElement = (...a) => (__ensure().registerElement)(...a);\n` +
|
|
4248
|
-
`export const $navigateTo = (...a) => { const vm = (__cached_vm || (void __ensure(), __cached_vm)); const rt = __ensure(); try { if (!(g && g.Frame)) { const ns = (__ns_core_bridge && (__ns_core_bridge.__esModule && __ns_core_bridge.default ? __ns_core_bridge.default : (__ns_core_bridge.default || __ns_core_bridge))) || __ns_core_bridge || {}; if (ns) { if (!g.Frame && ns.Frame) g.Frame = ns.Frame; if (!g.Page && ns.Page) g.Page = ns.Page; if (!g.Application && (ns.Application||ns.app||ns.application)) g.Application = (ns.Application||ns.app||ns.application); } } } catch {} try { const hmrRealm = (g && g.__NS_HMR_REALM__) || 'unknown'; const hasTop = !!(g && g.Frame && g.Frame.topmost && g.Frame.topmost()); const top = hasTop ? g.Frame.topmost() : null; const ctor = top && top.constructor && top.constructor.name; } catch {} if (g && typeof g.__nsNavigateUsingApp === 'function') { try { return g.__nsNavigateUsingApp(...a); } catch (e) { console.error('[ns-rt] $navigateTo app navigator error', e); throw e; } } console.error('[ns-rt] $navigateTo unavailable: app navigator missing'); throw new Error('$navigateTo unavailable: app navigator missing'); } ;\n` +
|
|
4249
|
-
`export const $navigateBack = (...a) => { const vm = (__cached_vm || (void __ensure(), __cached_vm)); const rt = __ensure(); const impl = (vm && (vm.$navigateBack || (vm.default && vm.default.$navigateBack))) || (rt && (rt.$navigateBack || (rt.runtimeHelpers && rt.runtimeHelpers.navigateBack))); let res; try { const via = (impl && (impl === (vm && vm.$navigateBack) || impl === (vm && vm.default && vm.default.$navigateBack))) ? 'vm' : (impl ? 'rt' : 'none'); } catch {} try { if (typeof impl === 'function') res = impl(...a); } catch {} try { const top = (g && g.Frame && g.Frame.topmost && g.Frame.topmost()); if (!res && top && top.canGoBack && top.canGoBack()) { res = top.goBack(); } } catch {} try { const hook = g && (g.__NS_HMR_ON_NAVIGATE_BACK || g.__NS_HMR_ON_BACK || g.__nsAttemptBackRemount); if (typeof hook === 'function') hook(); } catch {} return res; }\n` +
|
|
4250
|
-
`export const $showModal = (...a) => { const vm = (__cached_vm || (void __ensure(), __cached_vm)); const rt = __ensure(); const impl = (vm && (vm.$showModal || (vm.default && vm.default.$showModal))) || (rt && (rt.$showModal || (rt.runtimeHelpers && rt.runtimeHelpers.showModal))); try { if (typeof impl === 'function') return impl(...a); } catch (e) { } return undefined; }\n` +
|
|
4251
|
-
// Vite client helpers re-exported through the runtime bridge.
|
|
4252
|
-
//
|
|
4253
|
-
// Vite's `vite:import-analysis` plugin rewrites unresolvable dynamic
|
|
4254
|
-
// imports (where the URL is not a static string literal) as
|
|
4255
|
-
// `__vite__injectQuery(<expr>, 'import')` and prepends an import
|
|
4256
|
-
// from `/@vite/client`. The /* @vite-ignore */ comment only
|
|
4257
|
-
// suppresses the warning, not the rewrite — Vite gates the rewrite
|
|
4258
|
-
// on `urlIsStringRE`, not `hasViteIgnoreRE`.
|
|
4259
|
-
//
|
|
4260
|
-
// In NativeScript dev, the AST normalizer (packages/vite/hmr/helpers/
|
|
4261
|
-
// ast-normalizer.ts) correctly strips the /@vite/client import (the
|
|
4262
|
-
// browser-only client module is not loadable on-device), then sees
|
|
4263
|
-
// the unbound `__vite__injectQuery` identifier and synthesizes
|
|
4264
|
-
// `const { vite__injectQuery: __vite__injectQuery } = __ns_rt_ns_1`
|
|
4265
|
-
// from this bridge. Without this export the destructure binds to
|
|
4266
|
-
// undefined and Angular 21's component HMR loader (and any other
|
|
4267
|
-
// caller of dynamic-import-with-non-literal-URL) fails with
|
|
4268
|
-
// `__vite__injectQuery is not a function` at module evaluation.
|
|
4269
|
-
//
|
|
4270
|
-
// This polyfill mirrors Vite 8's `__vite__injectQuery` in
|
|
4271
|
-
// node_modules/vite/dist/node/chunks/node.js — for relative or
|
|
4272
|
-
// absolute-path URLs it appends `?<queryToInject>` (preserving
|
|
4273
|
-
// existing search/hash); for already-absolute URLs (http(s):, etc.)
|
|
4274
|
-
// it returns the URL unchanged. Angular's `ɵɵgetReplaceMetadataURL`
|
|
4275
|
-
// returns absolute HTTP URLs, so this acts as a passthrough at
|
|
4276
|
-
// runtime, matching Vite's web behavior.
|
|
4277
|
-
`export const vite__injectQuery = (url, queryToInject) => {\n` +
|
|
4278
|
-
` if (typeof url !== 'string') return url;\n` +
|
|
4279
|
-
` if (url[0] !== '.' && url[0] !== '/') return url;\n` +
|
|
4280
|
-
` const pathname = url.replace(/[?#].*$/, '');\n` +
|
|
4281
|
-
` let search = '', hash = '';\n` +
|
|
4282
|
-
` try { const u = new URL(url, 'http://vite.dev'); search = u.search || ''; hash = u.hash || ''; } catch {}\n` +
|
|
4283
|
-
` return pathname + '?' + queryToInject + (search ? '&' + search.slice(1) : '') + (hash || '');\n` +
|
|
4284
|
-
`};\n` +
|
|
4285
|
-
`export default {\n` +
|
|
4286
|
-
` defineComponent, resolveComponent, createVNode, createTextVNode, createCommentVNode,\n` +
|
|
4287
|
-
` Fragment, Teleport, Transition, TransitionGroup, KeepAlive, Suspense, withCtx, openBlock,\n` +
|
|
4288
|
-
` createBlock, createElementVNode, createElementBlock, renderSlot, mergeProps, toHandlers,\n` +
|
|
4289
|
-
` renderList, normalizeProps, guardReactiveProps, normalizeClass, normalizeStyle, toDisplayString,\n` +
|
|
4290
|
-
` withDirectives, resolveDirective, withModifiers, withKeys, resolveDynamicComponent,\n` +
|
|
4291
|
-
` isVNode, cloneVNode, isRef, ref, shallowRef, unref, computed, reactive, readonly, isReactive, isReadonly, toRaw, markRaw, shallowReactive, shallowReadonly,\n` +
|
|
4292
|
-
` watch, watchEffect, watchPostEffect, watchSyncEffect, onBeforeMount, onMounted, onBeforeUpdate, onUpdated,\n` +
|
|
4293
|
-
` onBeforeUnmount, onUnmounted, onActivated, onDeactivated, onErrorCaptured, onRenderTracked, onRenderTriggered, nextTick, h, provide, inject, vShow, createApp, registerElement,\n` +
|
|
4294
|
-
` $navigateTo, $navigateBack, $showModal,\n` +
|
|
4295
|
-
` vite__injectQuery\n` +
|
|
4296
|
-
`};\n`;
|
|
4297
|
-
// Prepend guard and ship (harmless, keeps diagnostics consistent)
|
|
4298
|
-
code = REQUIRE_GUARD_SNIPPET + code;
|
|
4214
|
+
// Single-realm bridge: discover every export `nativescript-vue`
|
|
4215
|
+
// (plus its `@vue/runtime-core` re-export chain) publishes so
|
|
4216
|
+
// the bridge never silently drops a symbol. `discoverNsvBridgeExports`
|
|
4217
|
+
// returns the union of static discovery and the curated baseline,
|
|
4218
|
+
// with the baseline acting as the floor if discovery fails. The
|
|
4219
|
+
// shared builder owns the bridge body (preamble, passthroughs,
|
|
4220
|
+
// HMR shims, polyfills, default export) — there's no inline copy.
|
|
4221
|
+
const vendorExports = discoverNsvBridgeExports(getProjectRootPath());
|
|
4222
|
+
const code = buildNsRtBridgeModule({ rtVer, requireGuardSnippet: REQUIRE_GUARD_SNIPPET, vendorExports });
|
|
4299
4223
|
res.statusCode = 200;
|
|
4300
4224
|
res.end(code);
|
|
4301
4225
|
}
|
|
@@ -4366,7 +4290,7 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
4366
4290
|
return next();
|
|
4367
4291
|
}
|
|
4368
4292
|
});
|
|
4369
|
-
// 2.6) ESM bridge for @nativescript/core: GET /ns/core[/<
|
|
4293
|
+
// 2.6) ESM bridge for @nativescript/core: GET /ns/core[/<sub>]
|
|
4370
4294
|
//
|
|
4371
4295
|
// Since bundle.mjs no longer bundles @nativescript/core (it is
|
|
4372
4296
|
// declared external in the rolldown config under HMR), this
|
|
@@ -4412,7 +4336,7 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
4412
4336
|
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
|
|
4413
4337
|
res.setHeader('Pragma', 'no-cache');
|
|
4414
4338
|
res.setHeader('Expires', '0');
|
|
4415
|
-
const { normalizedSub, sub
|
|
4339
|
+
const { normalizedSub, sub } = coreRequest;
|
|
4416
4340
|
const resolveModuleId = async (moduleId) => {
|
|
4417
4341
|
const resolved = await server.pluginContainer?.resolveId?.(moduleId, undefined);
|
|
4418
4342
|
return typeof resolved === 'string' ? resolved : resolved?.id || null;
|
|
@@ -4438,7 +4362,7 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
4438
4362
|
// Vite's transform output references module IDs with /@fs,
|
|
4439
4363
|
// relative specifiers, or absolute project paths. Rewrite
|
|
4440
4364
|
// those to URLs iOS can fetch over HTTP.
|
|
4441
|
-
let rewritten = rewriteSpecifiersForDevice(transformed.code, getServerOrigin(server), Number(
|
|
4365
|
+
let rewritten = rewriteSpecifiersForDevice(transformed.code, getServerOrigin(server), Number(graphVersion || 0));
|
|
4442
4366
|
// Invariant D (CJS/ESM interop shape) — EXPORT-SIDE fix.
|
|
4443
4367
|
//
|
|
4444
4368
|
// `@nativescript/core/index.js` declares namespace
|
|
@@ -5169,17 +5093,16 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
5169
5093
|
code = ensureVariableDynamicImportHelper(code);
|
|
5170
5094
|
try {
|
|
5171
5095
|
// For variant requests under /ns/sfc, prefer the version from the path segment when present
|
|
5172
|
-
// so that any internal '/ns/rt'
|
|
5096
|
+
// so that any internal '/ns/rt' or '/ns/sfc' imports are aligned with the same version.
|
|
5097
|
+
// `/ns/core` URLs are intentionally unversioned (realm-split history).
|
|
5173
5098
|
const verNum = Number(verFromPath || '0');
|
|
5174
5099
|
if (Number.isFinite(verNum) && verNum > 0) {
|
|
5175
5100
|
code = ensureVersionedRtImports(code, getServerOrigin(server), verNum);
|
|
5176
5101
|
code = ACTIVE_STRATEGY.ensureVersionedImports(code, getServerOrigin(server), verNum);
|
|
5177
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), verNum);
|
|
5178
5102
|
}
|
|
5179
5103
|
else {
|
|
5180
5104
|
code = ensureVersionedRtImports(code, getServerOrigin(server), graphVersion);
|
|
5181
5105
|
code = ACTIVE_STRATEGY.ensureVersionedImports(code, getServerOrigin(server), graphVersion);
|
|
5182
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), graphVersion);
|
|
5183
5106
|
}
|
|
5184
5107
|
}
|
|
5185
5108
|
catch { }
|
|
@@ -5189,7 +5112,7 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
5189
5112
|
}
|
|
5190
5113
|
catch { }
|
|
5191
5114
|
// CRITICAL: As a last step for script/template variants, re-run AST normalization and strip
|
|
5192
|
-
// any sentinel destructures that could cause duplicate locals, then re-apply
|
|
5115
|
+
// any sentinel destructures that could cause duplicate locals, then re-apply rt versioning.
|
|
5193
5116
|
try {
|
|
5194
5117
|
code = astNormalizeModuleImportsAndHelpers(code);
|
|
5195
5118
|
}
|
|
@@ -5203,11 +5126,9 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
5203
5126
|
const verNum = Number(verFromPath || '0');
|
|
5204
5127
|
if (Number.isFinite(verNum) && verNum > 0) {
|
|
5205
5128
|
code = ensureVersionedRtImports(code, getServerOrigin(server), verNum);
|
|
5206
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), verNum);
|
|
5207
5129
|
}
|
|
5208
5130
|
else {
|
|
5209
5131
|
code = ensureVersionedRtImports(code, getServerOrigin(server), graphVersion);
|
|
5210
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), graphVersion);
|
|
5211
5132
|
}
|
|
5212
5133
|
}
|
|
5213
5134
|
catch { }
|
|
@@ -5620,10 +5541,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
5620
5541
|
parts.push(`export default __ns_sfc__`);
|
|
5621
5542
|
let inlineCode = parts.filter(Boolean).join('\n');
|
|
5622
5543
|
inlineCode = processCodeForDevice(inlineCode, false, true);
|
|
5623
|
-
try {
|
|
5624
|
-
inlineCode = ensureVersionedCoreImports(inlineCode, getServerOrigin(server), Number(ver));
|
|
5625
|
-
}
|
|
5626
|
-
catch { }
|
|
5627
5544
|
try {
|
|
5628
5545
|
inlineCode = ensureDestructureCoreImports(inlineCode);
|
|
5629
5546
|
}
|
|
@@ -5690,10 +5607,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
5690
5607
|
outParts.push('export default __ns_sfc__');
|
|
5691
5608
|
let inlineCode2 = outParts.filter(Boolean).join('\n');
|
|
5692
5609
|
inlineCode2 = processCodeForDevice(inlineCode2, false, true);
|
|
5693
|
-
try {
|
|
5694
|
-
inlineCode2 = ensureVersionedCoreImports(inlineCode2, getServerOrigin(server), Number(ver));
|
|
5695
|
-
}
|
|
5696
|
-
catch { }
|
|
5697
5610
|
try {
|
|
5698
5611
|
inlineCode2 = ensureDestructureCoreImports(inlineCode2);
|
|
5699
5612
|
}
|
|
@@ -5897,7 +5810,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
5897
5810
|
const origin = getServerOrigin(server);
|
|
5898
5811
|
inlineCode2 = ensureVersionedRtImports(inlineCode2, origin, Number(ver));
|
|
5899
5812
|
inlineCode2 = ACTIVE_STRATEGY.ensureVersionedImports(inlineCode2, origin, Number(ver));
|
|
5900
|
-
inlineCode2 = ensureVersionedCoreImports(inlineCode2, origin, Number(ver));
|
|
5901
5813
|
}
|
|
5902
5814
|
catch { }
|
|
5903
5815
|
// Normalize imports/helpers via AST to ensure _defineComponent and other helpers are bound once
|
|
@@ -6001,10 +5913,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
6001
5913
|
// Run full device processing so helper aliasing and globals are consistent in this path too
|
|
6002
5914
|
let code = REQUIRE_GUARD_SNIPPET + asm;
|
|
6003
5915
|
code = processCodeForDevice(code, false, true, /(?:^|\/)node_modules\//.test(base), base);
|
|
6004
|
-
try {
|
|
6005
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), Number(ver));
|
|
6006
|
-
}
|
|
6007
|
-
catch { }
|
|
6008
5916
|
code = rewriteImports(code, base, sfcFileMap, depFileMap, projectRoot, !!verbose, undefined, getServerOrigin(server));
|
|
6009
5917
|
try {
|
|
6010
5918
|
code = ensureDestructureCoreImports(code);
|
|
@@ -6016,7 +5924,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
6016
5924
|
const origin = getServerOrigin(server);
|
|
6017
5925
|
code = ensureVersionedRtImports(code, origin, Number(ver));
|
|
6018
5926
|
code = ACTIVE_STRATEGY.ensureVersionedImports(code, origin, Number(ver));
|
|
6019
|
-
code = ensureVersionedCoreImports(code, origin, Number(ver));
|
|
6020
5927
|
}
|
|
6021
5928
|
catch { }
|
|
6022
5929
|
// Inline-template body path already runs processCodeForDevice (AST + sanitizers); no additional _defineComponent fix needed
|
|
@@ -6174,10 +6081,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
6174
6081
|
// Reuse existing sanitation chain (lightweight)
|
|
6175
6082
|
code = cleanCode(code);
|
|
6176
6083
|
code = processCodeForDevice(code, false, true, /(?:^|\/)node_modules\//.test(resolvedCandidate || spec), resolvedCandidate || spec);
|
|
6177
|
-
try {
|
|
6178
|
-
code = ensureVersionedCoreImports(code, getServerOrigin(server), graphVersion);
|
|
6179
|
-
}
|
|
6180
|
-
catch { }
|
|
6181
6084
|
code = rewriteImports(code, spec, sfcFileMap, depFileMap, server.config?.root || process.cwd(), !!verbose, undefined, getServerOrigin(server));
|
|
6182
6085
|
code = ensureVariableDynamicImportHelper(code);
|
|
6183
6086
|
code = ensureGuardPlainDynamicImports(code, origin);
|
|
@@ -6229,10 +6132,6 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
6229
6132
|
let depCode = depTrans.code;
|
|
6230
6133
|
depCode = cleanCode(depCode);
|
|
6231
6134
|
depCode = processCodeForDevice(depCode, false, true, /(?:^|\/)node_modules\//.test(depResolved), depResolved);
|
|
6232
|
-
try {
|
|
6233
|
-
depCode = ensureVersionedCoreImports(depCode, getServerOrigin(server), graphVersion);
|
|
6234
|
-
}
|
|
6235
|
-
catch { }
|
|
6236
6135
|
depCode = rewriteImports(depCode, depResolved, sfcFileMap, depFileMap, server.config?.root || process.cwd(), !!verbose, undefined, getServerOrigin(server));
|
|
6237
6136
|
depCode = ensureVariableDynamicImportHelper(depCode);
|
|
6238
6137
|
depCode = ensureGuardPlainDynamicImports(depCode, origin);
|