Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ea92e7e
feat(image): add shared image config and prop type contract
ogawa0071 Oct 16, 2026
46df19b
feat(image): add void/image core library and /_void/image endpoint
ogawa0071 Oct 16, 2026
f099026
feat(image): infer the Images binding and accept it in native deploys
ogawa0071 Oct 16, 2026
517e31f
feat(image): add Image and getImageProps to the Pages adapters
ogawa0071 Oct 16, 2026
8eda301
docs(image): document Image, void/image and the images config
ogawa0071 Oct 16, 2026
8ce081d
feat(image): wire image config, /_void/image and ?image imports into …
ogawa0071 Oct 16, 2026
a8b1de6
fix(image): allow ?image imports with custom localPatterns in dev and…
ogawa0071 Oct 16, 2026
8b29a8e
feat(image): infer next/image imports and keep preloads in generated …
ogawa0071 Oct 16, 2026
2da1964
test(image): cover Image in the Pages playgrounds
ogawa0071 Oct 16, 2026
1d2d306
fix(image): address review findings
ogawa0071 Oct 16, 2026
4d293bb
test(image): remove the Image playground pages
ogawa0071 Oct 16, 2026
4d0e9db
fix(image): tighten the plugin, source loading and inference after re…
ogawa0071 Oct 19, 2026
c4f9123
fix(image): keep ?image files out of the hashed-file Worker bypass
ogawa0071 Nov 3, 2026
b4223ad
chore: add missing after rebase imports
kossnocorp Nov 23, 2026
4b83586
chore: give image optimization guide name consistent with image gener…
kossnocorp Nov 23, 2026
7d58c0f
chore: add image optimization playground
kossnocorp Nov 23, 2026
77edd21
chore: fix tests after files move in main
kossnocorp Nov 23, 2026
d6cabff
chore: fix SVG picas calc, fix static image import types, update stal…
kossnocorp Nov 23, 2026
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
59 changes: 46 additions & 13 deletions .github/scripts/packed-consumer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,27 @@ assert(frameworks.every((framework) => ['react', 'vue', 'svelte', 'solid'].inclu
const pages = {
react: `import { useState } from 'react';
import { Link } from '@void/react';
import Image from '@void/react/image';
export default function Page({ message }: { message: string }) {
const [count, setCount] = useState(0);
return <><h1>{message}</h1><button onClick={() => setCount(count + 1)}>Count {count}</button><Link href="/next">Next page</Link></>;
return <><h1>{message}</h1><Image src="/packed.png" alt="Packed" width={32} height={32} /><button onClick={() => setCount(count + 1)}>Count {count}</button><Link href="/next">Next page</Link></>;
}`,
vue: `<script setup lang="ts">
import { ref } from 'vue';
import { Link } from '@void/vue';
import { Image, Link } from '@void/vue';
defineProps<{ message: string }>();
const count = ref(0);
</script><template><h1>{{ message }}</h1><button @click="count++">Count {{ count }}</button><Link href="/next">Next page</Link></template>`,
</script><template><h1>{{ message }}</h1><Image src="/packed.png" alt="Packed" :width="32" :height="32" /><button @click="count++">Count {{ count }}</button><Link href="/next">Next page</Link></template>`,
svelte: `<script lang="ts">
import { Link } from '@void/svelte';
import { Image, Link } from '@void/svelte';
let { message }: { message: string } = $props();
let count = $state(0);
</script><h1>{message}</h1><button onclick={() => count++}>Count {count}</button><Link href="/next">Next page</Link>`,
</script><h1>{message}</h1><Image src="/packed.png" alt="Packed" width={32} height={32} /><button onclick={() => count++}>Count {count}</button><Link href="/next">Next page</Link>`,
solid: `import { createSignal } from 'solid-js';
import { Link } from '@void/solid';
import { Image, Link } from '@void/solid';
export default function Page(props: { message: string }) {
const [count, setCount] = createSignal(0);
return <><h1>{props.message}</h1><button onClick={() => setCount(count() + 1)}>Count {count()}</button><Link href="/next">Next page</Link></>;
return <><h1>{props.message}</h1><Image src="/packed.png" alt="Packed" width={32} height={32} /><button onClick={() => setCount(count() + 1)}>Count {count()}</button><Link href="/next">Next page</Link></>;
}`,
};

Expand Down Expand Up @@ -343,16 +344,43 @@ try {
);
mkdirSync(join(fixture, 'public'), { recursive: true });
writeFileSync(join(fixture, 'public/packed.txt'), label);
// A 1x1 PNG for `Image`, which renders through the installed void/image and /_void/image.
writeFileSync(
join(fixture, 'public/packed.png'),
Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
'base64',
),
);
const vite = join(
fixture,
useVitePlus ? 'node_modules/vite-plus/bin/vp' : 'node_modules/vite/bin/vite.js',
);
await run(process.execPath, [vite, 'build'], fixture);
await run(
process.execPath,
[join(fixture, 'node_modules/typescript/bin/tsc'), '--noEmit'],
fixture,
const tsc = join(fixture, 'node_modules/typescript/bin/tsc');
await run(process.execPath, [tsc, '--noEmit'], fixture);
// Check ?image without an adapter import that would load void/image's types.
const imageTypes = join(fixture, '.void/image-types');
mkdirSync(imageTypes, { recursive: true });
writeFileSync(
join(imageTypes, 'tsconfig.json'),
JSON.stringify({
compilerOptions: {
module: 'esnext',
moduleResolution: 'bundler',
noEmit: true,
strict: true,
skipLibCheck: true,
types: ['void/env'],
},
files: ['probe.ts'],
}),
);
writeFileSync(
join(imageTypes, 'probe.ts'),
`import image from '../../public/packed.png?image';\nexport const width: number = image.width;\n`,
);
await run(process.execPath, [tsc, '-p', join(imageTypes, 'tsconfig.json')], fixture);
if (useVitePlus) {
// Vitest loads the app's Vite config, Void's plugin included, and runs the tests in
// Node.js. The test from docs/guide/testing.md replaces the KV module it uses.
Expand Down Expand Up @@ -432,7 +460,12 @@ if (runtime.manifest.platformVersion !== ${JSON.stringify(version)}) throw new E
await new Promise((resolve) => setTimeout(resolve, 200));
}
assert(response?.ok, task.failure());
assert((await response.text()).includes(`Packed ${label}`));
const html = await response.text();
assert(html.includes(`Packed ${label}`));
assert(html.includes('/_void/image?url=%2Fpacked.png&amp;w=32&amp;q=75 1x'), html);
const image = await fetch(`${base}/_void/image?url=%2Fpacked.png&w=32&q=75`);
assert.equal(image.status, 200, task.failure());
assert.match(image.headers.get('content-type') ?? '', /^image\//);
assert.equal(await (await fetch(`${base}/packed.txt`)).text(), label);
const apiResponse = await fetch(`${base}/api/packed`);
const apiBody = await apiResponse.text();
Expand Down Expand Up @@ -539,7 +572,7 @@ if (runtime.manifest.platformVersion !== ${JSON.stringify(version)}) throw new E
}
}
console.log(
`Passed packed ${label} (${suite}): init, frozen install, ${useVitePlus ? 'Vite+ build/typecheck/test' : 'public Vite build/typecheck'}, assets, KV, email, runtime integrity${full ? ', dev/preview, hydration/navigation' : ', dev HTTP'}${framework === 'react' ? ', Node target' : ''}`,
`Passed packed ${label} (${suite}): init, frozen install, ${useVitePlus ? 'Vite+ build/typecheck/test' : 'public Vite build/typecheck'}, assets, KV, email, Image, runtime integrity${full ? ', dev/preview, hydration/navigation' : ', dev HTTP'}${framework === 'react' ? ', Node target' : ''}`,
);
} catch (error) {
failures.push({ fixture: label, error: String(error.stack ?? error) });
Expand Down
2 changes: 2 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const referenceItems: Array<SidebarItem> = [
{ text: 'target', link: '/reference/config#target' },
{ text: 'routing', link: '/reference/config#routing' },
{ text: 'inference', link: '/reference/config#inference' },
{ text: 'images', link: '/reference/config#images' },
{ text: 'output', link: '/reference/config#output' },
{ text: 'remote', link: '/reference/config#remote' },
{ text: 'sandbox', link: '/reference/config#sandbox' },
Expand Down Expand Up @@ -337,6 +338,7 @@ export default extendConfig(
{ text: 'Rewrites', link: '/guide/edge/rewrites' },
],
},
{ text: 'Image Optimization', link: '/guide/image-optimization' },
{ text: 'Custom SSR', link: '/guide/ssr' },
{ text: 'SSG', link: '/guide/ssg' },
],
Expand Down
Loading