Skip to content
Merged
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
44 changes: 44 additions & 0 deletions packages/void/test/integration/node-static-md.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { execSync } from 'node:child_process';
import { existsSync, readFileSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { beforeAll, describe, expect, it } from 'vite-plus/test';

// A Markdown-only pages app still needs a client build: its closeBundle
// prerenders. Markdown pages are implicit islands, so the client input comes
// from the islands plugin; without it the build fails with UNRESOLVED_ENTRY.
const ROOT = join(import.meta.dirname, '..', '..', '..', '..');
const PLAYGROUND = 'playground/node-static-md';
const DIST = join(ROOT, PLAYGROUND, 'dist');

describe('playground/node-static-md build (Markdown-only, target: node, output: static)', () => {
beforeAll(() => {
const pg = join(ROOT, PLAYGROUND);
rmSync(join(pg, 'dist'), { recursive: true, force: true });
rmSync(join(pg, '.void'), { recursive: true, force: true });
execSync(`vp run --filter ./${PLAYGROUND} build`, { cwd: ROOT, stdio: 'pipe' });
});

it('emits the Node SSR entry', () => {
expect(existsSync(join(DIST, 'ssr/app.js'))).toBe(true);
});

it('prerenders Markdown pages to HTML', () => {
const index = join(DIST, 'client/index.html');
const post = join(DIST, 'client/posts/hello.html');
expect(existsSync(index)).toBe(true);
expect(existsSync(post)).toBe(true);

const postHtml = readFileSync(post, 'utf-8');
expect(postHtml).toContain('<!doctype html>');
// The Markdown body and its syntax-highlighted code block were rendered.
expect(postHtml).toContain('Hello');
expect(postHtml).toContain('shiki');
});

it('keeps prerendered Markdown pages free of client JS bundles', () => {
const postHtml = readFileSync(join(DIST, 'client/posts/hello.html'), 'utf-8');
// No framework hydration/entry bundle is referenced by a zero-JS page.
expect(postHtml).not.toContain('type="module"');
expect(postHtml).not.toContain('src="/assets/');
});
});
25 changes: 25 additions & 0 deletions playground/node-static-md/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "playground-node-static-md",
"private": true,
"type": "module",
"scripts": {
"build": "vp build",
"dev": "vp dev",
"preview": "vp preview"
},
"dependencies": {
"@hono/node-server": "^2.1.5",
"hono": "^4.13.13",
"react": "catalog:",
"react-dom": "catalog:"
},
"devDependencies": {
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@void/md": "workspace:*",
"@void/react": "workspace:*",
"vite": "catalog:",
"vite-plus": "catalog:",
"void": "workspace:*"
}
}
9 changes: 9 additions & 0 deletions playground/node-static-md/pages/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Home
---

# Home

A Markdown-only static site with no client-side islands.

[Hello post](/posts/hello)
14 changes: 14 additions & 0 deletions playground/node-static-md/pages/posts/hello.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Hello
---

# Hello

The first paragraph of a Markdown post, with a fenced code block to exercise
syntax highlighting during the static build.

```ts
export function add(a: number, b: number): number {
return a + b;
}
```
14 changes: 14 additions & 0 deletions playground/node-static-md/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"allowImportingTsExtensions": true
},
"include": ["pages"]
}
9 changes: 9 additions & 0 deletions playground/node-static-md/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { voidMarkdown } from '@void/md/plugin';
import { voidReact } from '@void/react/plugin';
import { defineConfig } from 'vite-plus';
import { voidPlugin } from 'void';

// Markdown-only: every page is an implicit island with no client-side JS.
export default defineConfig({
plugins: [voidPlugin(), voidReact(), voidMarkdown()],
});
6 changes: 6 additions & 0 deletions playground/node-static-md/void.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from 'void/config';

export default defineConfig({
target: 'node',
output: 'static',
});
37 changes: 37 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/integration-timings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const integrationTimings: Readonly<Record<string, number>> = {
'packages/void/test/integration/mysql-test.test.ts': 11000,
'packages/void/test/integration/named-layouts.test.ts': 9939,
'packages/void/test/integration/nitro-worker.test.ts': 30000,
'packages/void/test/integration/node-static-md.test.ts': 2000,
'packages/void/test/integration/node-static.test.ts': 13667,
'packages/void/test/integration/node-target.test.ts': 10833,
'packages/void/test/integration/nuxt.test.ts': 43000,
Expand Down