feat: support WRN imports and dynamic public shell

This commit is contained in:
2026-07-21 11:15:06 +05:30
parent 0013c0771d
commit 2ca2d02b22
82 changed files with 959 additions and 174 deletions
+14
View File
@@ -57,6 +57,20 @@ test("parses a page with a layout member", () => {
expect(ast.layout).toBe("public");
});
test("top-level imports are preserved and available to SSR view expressions", async () => {
const source = `import { posix } from "node:path";
page Home {
view { <PublicHeader signInHref="{posix.join('/sso', '/sign-in')}" /> }
}`;
const ast = parse(source);
expect(ast.imports).toEqual(['import { posix } from "node:path";']);
const mod = await compileAndImport(source);
const render = mod.default as (ctx: unknown) => string;
expect(String(await render({}))).toContain('signInHref="/sso/sign-in"');
});
test("parses a component with props and state", () => {
const ast = parse(
`component C {\n props {\n n = 0\n }\n state count = n\n view { <b>{count}</b> }\n}`,