feat(compiler): resolve .tsx imports and tag them as islands

.wrn keeps resolution priority so existing components are unaffected
when a .tsx file shares their name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 15:15:08 +05:30
co-authored by Claude Opus 5
parent cd07f0f8e2
commit b405025f37
2 changed files with 74 additions and 1 deletions
+10 -1
View File
@@ -11,6 +11,8 @@ export interface ImportResolverOptions {
export interface ResolvedImport {
declaration: StructuredImportDecl;
resolved?: string;
/** `.tsx` imports are React islands, not `.wrn` components. */
kind?: "island";
diagnostic?: { code: string; message: string; severity: "error" | "warning" };
}
@@ -21,9 +23,11 @@ function candidates(path: string): string[] {
path,
`${path}.wrn`,
`${path}.ts`,
`${path}.tsx`,
`${path}.d.ts`,
join(path, "index.wrn"),
join(path, "index.ts"),
join(path, "index.tsx"),
];
}
@@ -56,7 +60,12 @@ export function resolveWrnImport(
return false;
}
});
if (found) return { declaration, resolved: realpathSync(found) };
if (found) {
const resolved = realpathSync(found);
return resolved.endsWith(".tsx")
? { declaration, resolved, kind: "island" as const }
: { declaration, resolved };
}
const severity = (options.mode ?? "compatible") === "explicit" ? "error" : "warning";
return {
declaration,