Skip to content

Commit fd616e3

Browse files
committed
refactor(module): drop the native '@/' -> '/src/' alias expansion
Aliasing is resolution policy, and the boundary this branch drew puts resolution policy on the dev server: Vite applies resolve.alias before a module is ever served, so a specifier that still carries '@/' when it reaches the runtime is one the server never rewrote. Guessing '/src/' natively turned that configuration bug into a silent fallback; now it fails through the normal not-found path where the import-map miss logging makes the cause visible.
1 parent 63ed317 commit fd616e3

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

‎NativeScript/runtime/ModuleInternalCallbacks.mm‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,16 +1821,6 @@ static bool IsDocumentsPath(const std::string& path) {
18211821
Log(@"[resolver][spec] %s", normalizedSpec.c_str());
18221822
}
18231823

1824-
// Normalize '@/' alias to '/src/' for static imports (mirrors client dynamic import
1825-
// normalization)
1826-
if (normalizedSpec.rfind("@/", 0) == 0) {
1827-
std::string orig = normalizedSpec;
1828-
normalizedSpec = std::string("/src/") + normalizedSpec.substr(2);
1829-
if (IsScriptLoadingLogEnabled()) {
1830-
Log(@"[resolver][normalize] %@ -> %@", [NSString stringWithUTF8String:orig.c_str()],
1831-
[NSString stringWithUTF8String:normalizedSpec.c_str()]);
1832-
}
1833-
}
18341824
// Guard against a bare '@' spec showing up (invalid); return empty to avoid poisoning registry
18351825
// with '@'
18361826
if (normalizedSpec == "@") {
@@ -2762,7 +2752,7 @@ static bool IsDocumentsPath(const std::string& path) {
27622752
}
27632753
}
27642754
}
2765-
// Normalize spec: expand '@/'; only strip ?query/hash for non-HTTP specs so SFC HTTP keys keep
2755+
// Normalize spec: only strip ?query/hash for non-HTTP specs so SFC HTTP keys keep
27662756
// version tags
27672757
std::string rawSpec = cSpec ? std::string(cSpec) : std::string();
27682758
std::string normalizedSpec = rawSpec;
@@ -2775,10 +2765,6 @@ static bool IsDocumentsPath(const std::string& path) {
27752765
normalizedSpec = normalizedSpec.substr(0, qpos);
27762766
}
27772767
}
2778-
// expand '@/'
2779-
if (normalizedSpec.rfind("@/", 0) == 0) {
2780-
normalizedSpec = std::string("/src/") + normalizedSpec.substr(2);
2781-
}
27822768
if (normalizedSpec != rawSpec) {
27832769
// Rebuild V8 string only if changed
27842770
specifier = tns::ToV8String(isolate, normalizedSpec.c_str());

0 commit comments

Comments
 (0)