release: WRNexusJS 0.8.3
Quality / quality (ubuntu-latest) (push) Failing after 12m9s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-03 19:47:30 +05:30
parent e8f630f12d
commit 4cebacadfe
156 changed files with 2608 additions and 473 deletions
+23 -6
View File
@@ -1,4 +1,4 @@
import { existsSync, realpathSync } from "node:fs";
import { existsSync, realpathSync, statSync } from "node:fs";
import { dirname, extname, join, resolve } from "node:path";
import type { StructuredImportDecl } from "@wrnexus/syntax";
@@ -33,12 +33,29 @@ export function resolveWrnImport(
options: ImportResolverOptions,
): ResolvedImport {
const source = declaration.source;
if (!source.startsWith(".") && !source.startsWith("@/")) return { declaration, resolved: source };
const aliasRoot = options.aliases?.["@"] ?? "./app";
const base = source.startsWith("@/")
? resolve(options.appRoot, aliasRoot, source.slice(2))
const aliases: Record<string, string> = {
"@": "./app",
...(options.aliases ?? {}),
};
const alias = Object.keys(aliases)
.filter((key) => key.length > 0 && (source === key || source.startsWith(`${key}/`)))
.sort((left, right) => right.length - left.length)[0];
if (!source.startsWith(".") && !alias) return { declaration, resolved: source };
const base = alias
? resolve(
options.appRoot,
aliases[alias]!,
source === alias ? "" : source.slice(alias.length + 1),
)
: resolve(dirname(importer), source);
const found = candidates(base).find(existsSync);
const found = candidates(base).find((candidate) => {
if (!existsSync(candidate)) return false;
try {
return statSync(candidate).isFile();
} catch {
return false;
}
});
if (found) return { declaration, resolved: realpathSync(found) };
const severity = (options.mode ?? "compatible") === "explicit" ? "error" : "warning";
return {