Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/void/src/prerender-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export async function collectPrerenderPaths(options: {
}
}
} catch (err) {
console.warn(
`[void] Failed to resolve prerender paths for ${page.pattern}: ${err instanceof Error ? err.message : String(err)}`,
throw new Error(
`Failed to resolve prerender paths for ${page.pattern}: ${err instanceof Error ? err.message : String(err)}`,
);
}
}
Expand Down Expand Up @@ -97,8 +97,8 @@ export async function collectPrerenderPaths(options: {
}
}
} catch (err) {
console.warn(
`[void] Failed to resolve SSR prerender paths: ${err instanceof Error ? err.message : String(err)}`,
throw new Error(
`Failed to resolve SSR prerender paths: ${err instanceof Error ? err.message : String(err)}`,
);
} finally {
await viteServer.close();
Expand Down
12 changes: 12 additions & 0 deletions packages/void/test/integration/static-pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
rmSync(join(pg, "dist"), { recursive: true, force: true });
rmSync(join(pg, ".void"), { recursive: true, force: true });
removeWranglerConfig(pg);
execSync(`pnpm --dir ${PLAYGROUND} build`, { cwd: ROOT, stdio: "pipe" });

Check failure on line 21 in packages/void/test/integration/static-pages.test.ts

View workflow job for this annotation

GitHub Actions / test (core-markdown, test:integration)

[core-markdown] packages/void/test/integration/static-pages.test.ts > playground/static-pages build (output: static)

Error: Command failed: pnpm --dir playground/static-pages build (node:4109) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) error during build: Error: Failed to resolve prerender paths for /tags/:tag: Cannot find module 'virtual:tags' imported from '/home/runner/work/void/void/playground/static-pages/pages/tags/[tag].server.ts' at collectPrerenderPaths (file:///home/runner/work/void/void/packages/void/dist/deploy-DS0m1jM3.mjs:815:12) at async PluginContextImpl.closeBundle (file:///home/runner/work/void/void/packages/void/dist/index.mjs:1705:18) at async plugin (file:///home/runner/work/void/void/node_modules/.pnpm/rolldown@1.0.0-rc.4/node_modules/rolldown/dist/shared/bindingify-input-options-phmnMdxa.mjs:1341:4) at async plugin.<computed> (file:///home/runner/work/void/void/node_modules/.pnpm/rolldown@1.0.0-rc.4/node_modules/rolldown/dist/shared/bindingify-input-options-phmnMdxa.mjs:1590:12) ❯ plugin node_modules/.pnpm/rolldown@1.0.0-rc.4/node_modules/rolldown/dist/shared/bindingify-input-options-phmnMdxa.mjs:1341:4 ❯ packages/void/test/integration/static-pages.test.ts:21:5 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { status: 1, signal: null, output: [ null, '<Buffer(3000) ...>', '<Buffer(1004) ...>' ], pid: 4066, stdout: '<Buffer(3000) ...>', stderr: '<Buffer(1004) ...>' }
}, 120_000);

it("emits worker entry and client manifest", () => {
Expand Down Expand Up @@ -73,6 +73,18 @@
expect(html).toContain("Post hello");
});

it("prerenders dynamic pages with getPrerenderPaths using virtual modules", () => {
// tags/[tag] exports getPrerenderPaths that imports from virtual:tags plugin
const vuePath = join(DIST, "client/tags/vue.html");
const vitePath = join(DIST, "client/tags/vite.html");
expect(existsSync(vuePath)).toBe(true);
expect(existsSync(vitePath)).toBe(true);

const html = readFileSync(vuePath, "utf-8");
expect(html).toContain('data-testid="tag-title"');
expect(html).toContain("Tag vue");
});

it("does not prerender dynamic pages without getPrerenderPaths", () => {
// items/[id] has no getPrerenderPaths, so it should NOT be prerendered
expect(existsSync(join(DIST, "client/items"))).toBe(false);
Expand Down
16 changes: 16 additions & 0 deletions playground/static-pages/pages/tags/[tag].server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineHandler } from "void";
import { tags } from "virtual:tags";

export interface Props {
tag: string;
}

export const prerender = true;

export function getPrerenderPaths() {
return tags.map((tag: string) => ({ tag }));
Comment on lines +10 to +11

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR's stated purpose is to reproduce a known limitation — virtual module imports (and resolve.alias) silently fail during getPrerenderPaths because collectPrerenderPaths uses createServer({ configFile: false }). However, the existing static-pages.test.ts integration test is not updated to document or assert on this behavior.

Without a corresponding test case asserting that tags/vue.html and tags/vite.html are not generated (e.g., expect(existsSync(join(DIST, "client/tags/vue.html"))).toBe(false)), there is no automated check capturing the limitation. This means the limitation could be silently "fixed" or "broken" without any test reflecting the change.

Consider adding a test case to packages/void/test/integration/static-pages.test.ts that explicitly documents this known limitation — for example, asserting that the tag pages are absent from the build output due to the virtual module resolution failure. Such a test would also serve as a regression test once the limitation is eventually fixed (the test expectation would be inverted).

Copilot uses AI. Check for mistakes.
}

export const loader = defineHandler<Props>((c) => {
return { tag: c.req.param("tag") };
});
9 changes: 9 additions & 0 deletions playground/static-pages/pages/tags/[tag].vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup lang="ts">
defineProps<{ tag: string }>();
</script>

<template>
<div>
<h1 data-testid="tag-title">Tag {{ tag }}</h1>
</div>
</template>
20 changes: 18 additions & 2 deletions playground/static-pages/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import { defineConfig } from "vite";
import { defineConfig, type Plugin } from "vite";
import { voidPlugin } from "void";
import { voidVue } from "@void-x/vue";

function virtualTagsPlugin(): Plugin {
const VIRTUAL_ID = "virtual:tags";
const RESOLVED_ID = "\0virtual:tags";
return {
name: "virtual-tags",
resolveId(id) {
if (id === VIRTUAL_ID) return RESOLVED_ID;
},
load(id) {
if (id === RESOLVED_ID) {
return `export const tags = ["vue", "vite"];`;
}
},
};
}

export default defineConfig({
plugins: [voidPlugin(), voidVue()],
plugins: [voidPlugin(), voidVue(), virtualTagsPlugin()],
});
Loading