Skip to content

Commit f2c40b5

Browse files
committed
Generate React Router route types before playground builds
Fresh CI checkouts lacked the +types modules consumed by React Router routes: Vite builds do not run React Router's type generator. Run typegen before the build so it cannot invalidate the completed Worker output. Clear generated types in the existing production integration and assert that the build recreates them. Check the required type artifacts in CI. Verified the same three CI diagnostics from a clean type directory, the clean-build regression, all five React Router integrations, vp check, all 35 compiler tasks, and the full suite (17,550 passed, 35 skipped).
1 parent 7937843 commit f2c40b5

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎packages/void/test/integration/react-router.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { execFileSync } from 'node:child_process';
2-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
33
import { join } from 'node:path';
44
import spawn from 'cross-spawn';
55
import { afterAll, beforeAll, describe, expect, it } from 'vite-plus/test';
@@ -210,13 +210,21 @@ export async function loader() {
210210
}
211211
});
212212

213-
it('queries MySQL through void/db in the built Worker', async () => {
214-
execFileSync('vp', ['build'], {
213+
it('generates route types from scratch and queries MySQL in the built Worker', async () => {
214+
// The dev server generates these too, so do not let the previous test mask a missing build step.
215+
rmSync(join(playground.root, '.react-router'), { recursive: true, force: true });
216+
execFileSync('vp', ['run', 'build'], {
215217
cwd: playground.root,
216218
stdio: 'pipe',
217219
env: { ...process.env, VOID_INSPECTOR_PORT: 'false' },
218220
shell: process.platform === 'win32',
219221
});
222+
for (const route of ['smoke', 'users']) {
223+
expect(
224+
existsSync(join(playground.root, '.react-router/types/app/routes/+types', `${route}.ts`)),
225+
`The build should generate ${route} route types`,
226+
).toBe(true);
227+
}
220228
const server = await start('preview');
221229
try {
222230
await expectUsers(server);

‎playground/react-router/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"build": "vp build",
6+
"build": "react-router typegen && vp build",
77
"dev": "vp dev"
88
},
99
"dependencies": {

‎test/check-playground-build-artifacts.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ const artifacts = {
66
analog: ['dist/analog/server/index.mjs', 'dist/analog/public'],
77
astro: ['dist/server/entry.mjs'],
88
nuxt: ['.output/server/index.mjs', '.output/public'],
9-
'react-router': ['build/server/index.js', 'build/client'],
9+
'react-router': [
10+
'build/server/index.js',
11+
'build/client',
12+
'.react-router/types/app/routes/+types/smoke.ts',
13+
'.react-router/types/app/routes/+types/users.ts',
14+
],
1015
sveltekit: ['.svelte-kit/cloudflare/_worker.js'],
1116
'tanstack-start': ['dist/server/index.js', 'dist/client'],
1217
'vinext-app': ['dist/server/index.js', 'dist/client'],

0 commit comments

Comments
 (0)