From 95a3aa3160176cb3b65533b668f0d88c721db716 Mon Sep 17 00:00:00 2001 From: 0froq Date: Fri, 20 Nov 2026 19:27:21 +0800 Subject: [PATCH 1/2] fix(deploy): honor a configured inference.appType in the Cloudflare static check The direct Cloudflare branch re-ran strict preset detection even when the app type was configured, so a VitePress site with `routes/` and the guide's own `appType: "void"` was refused with a message telling the user to set that option. --- .../void/src/cli/deploy-cloudflare-static.ts | 3 +- packages/void/test/unit/preset.test.ts | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/void/src/cli/deploy-cloudflare-static.ts b/packages/void/src/cli/deploy-cloudflare-static.ts index ca2ed3674..4995e7e9b 100644 --- a/packages/void/src/cli/deploy-cloudflare-static.ts +++ b/packages/void/src/cli/deploy-cloudflare-static.ts @@ -191,7 +191,8 @@ export function resolveCloudflareStaticPreset( ), }; } - if (detectFramework(root)) { + // `static` and `spa` returned above, so a configured app type here means a Worker deploy. + if (detectFramework(root) || voidConfig.inference?.appType) { return null; } const detected = detectPreset(root, { spa: options.spa, strictBackend: true }); diff --git a/packages/void/test/unit/preset.test.ts b/packages/void/test/unit/preset.test.ts index 2b4ad947b..588ceffc7 100644 --- a/packages/void/test/unit/preset.test.ts +++ b/packages/void/test/unit/preset.test.ts @@ -4,6 +4,7 @@ import { join, resolve } from 'node:path'; import { toSlash } from 'pathslash'; import { describe, expect, it, beforeEach, afterEach } from 'vite-plus/test'; import { packageFixturePath } from '../../../../test/fixture-dir.ts'; +import { resolveCloudflareStaticPreset } from '../../src/cli/deploy-cloudflare-static.ts'; import { detectPreset, findBackendSources, @@ -11,6 +12,7 @@ import { hasBackendFiles, resolveProjectCommand, } from '../../src/cli/preset.ts'; +import type { VoidConfig } from '../../src/config.ts'; const TMP = packageFixturePath(import.meta.dirname, '.tmp-preset'); @@ -266,6 +268,32 @@ describe('detectPreset — strictBackend', () => { }); }); +describe('resolveCloudflareStaticPreset — configured app type', () => { + const vitepressPkg = { devDependencies: { vitepress: '^1.0.0' } }; + + // The guide sends a VitePress site with `routes/` to `appType: "void"`, which this branch ignored. + it('returns null for a configured appType "void" with an SSG plus backend', () => { + const root = setupProject({ pkg: vitepressPkg, dirs: ['.vitepress', 'routes'] }); + const voidConfig = { inference: { appType: 'void' } } as VoidConfig; + expect(resolveCloudflareStaticPreset(root, voidConfig, {})).toBeNull(); + }); + + it('still refuses the unconfigured SSG plus backend case', () => { + const root = setupProject({ pkg: vitepressPkg, dirs: ['.vitepress', 'routes'] }); + expect(() => resolveCloudflareStaticPreset(root, {} as VoidConfig, {})).toThrow('vitepress'); + }); + + it('keeps resolving a configured static app that also has backend sources', () => { + const root = setupProject({ pkg: vitepressPkg, dirs: ['.vitepress', 'routes'] }); + const voidConfig = { inference: { appType: 'static' } } as VoidConfig; + expect(resolveCloudflareStaticPreset(root, voidConfig, {})).toEqual({ + buildCommand: 'vitepress build', + outputDir: toSlash(resolve(root, '.vitepress/dist')), + appType: 'static', + }); + }); +}); + describe('findBackendSources', () => { it('lists every backend source relative to the root', () => { const root = setupProject({ From 06580f147407039a628e314fe73e9b29a418b0d7 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Sun, 22 Nov 2026 18:56:02 +0900 Subject: [PATCH 2/2] Honor the configured app type during native Cloudflare deploy preflight. --- .../src/cli/cloudflare-deploy/classify.ts | 15 +++++----- .../void/test/unit/cloudflare-deploy.test.ts | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/packages/void/src/cli/cloudflare-deploy/classify.ts b/packages/void/src/cli/cloudflare-deploy/classify.ts index f35d8ddcc..7e9983e00 100644 --- a/packages/void/src/cli/cloudflare-deploy/classify.ts +++ b/packages/void/src/cli/cloudflare-deploy/classify.ts @@ -27,14 +27,15 @@ export function classifyCloudflareDeployApp( application: ApplicationAnalysis, ): CloudflareDeployAppClassification { const framework = application.framework; + const configuredAppType = voidConfig.inference?.appType; - // Frameworks have their own Worker output. Their Vite dependency does not - // imply that the project is a standalone SPA. - const staticPreset = framework - ? null - : detectPreset(root, { dir: options.dir, spa: options.spa }); - const configuredStatic = - voidConfig.inference?.appType === 'static' || voidConfig.inference?.appType === 'spa'; + // Infer a static preset only when neither the config nor a framework determines + // the app type, just as in the static deployment path. + const staticPreset = + framework || configuredAppType + ? null + : detectPreset(root, { dir: options.dir, spa: options.spa }); + const configuredStatic = configuredAppType === 'static' || configuredAppType === 'spa'; if (staticPreset || configuredStatic || options.dir || options.spa) { const appType = staticPreset?.appType ?? (options.spa ? 'spa' : 'static'); return unsupported( diff --git a/packages/void/test/unit/cloudflare-deploy.test.ts b/packages/void/test/unit/cloudflare-deploy.test.ts index ee451ed1a..c193c3c8d 100644 --- a/packages/void/test/unit/cloudflare-deploy.test.ts +++ b/packages/void/test/unit/cloudflare-deploy.test.ts @@ -1158,6 +1158,35 @@ function harness(overrides: Partial = {}): { return { deps, trace, wranglerArgs, exitCalls }; } +it('reaches the native Worker build for VitePress with a configured Void backend', async () => { + const root = makeProject({ + 'package.json': JSON.stringify({ name: 'site', dependencies: { void: '*', vitepress: '*' } }), + 'void.config.ts': `export default { + inference: { appType: 'void', build: 'vitepress build && vite build' }, + cloudflare: { name: 'site', account_id: 'personal' }, + };`, + 'vite.config.ts': `import { voidPlugin } from 'void'; + export default { plugins: [voidPlugin()], publicDir: '.vitepress/dist' };`, + 'routes/api/hello.ts': 'export const GET = () => "hello";', + '.vitepress/config.ts': 'export default {};', + 'index.md': '# Site', + }); + const runBuild = vi.fn(() => { + throw new Error('Reached the Worker build'); + }); + const { deps } = harness({ runBuild }); + const output = vi.spyOn(log, 'error').mockImplementation(() => {}); + try { + await expect( + runCloudflareDeploy(root, { platform: 'cloudflare' }, silentCliLog, deps), + ).rejects.toBeInstanceOf(ExitError); + expect(output).toHaveBeenCalledWith('deploy: build failed — Reached the Worker build'); + expect(runBuild).toHaveBeenCalledOnce(); + } finally { + output.mockRestore(); + } +}); + describe('existing Cloudflare site handoff', () => { const existing = { versionId: 'original',