feat: support WRN imports and dynamic public shell
This commit is contained in:
@@ -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}`,
|
||||
|
||||
Reference in New Issue
Block a user