From f08e81743a844d6f44e764664504c70cd8fd8c51 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 24 Nov 2026 22:48:57 -0700 Subject: [PATCH] Stabilize Vinext Pages Fast Refresh file watching --- scripts/test-vinext-pages.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/test-vinext-pages.mjs b/scripts/test-vinext-pages.mjs index a58e97e..6ee4d65 100644 --- a/scripts/test-vinext-pages.mjs +++ b/scripts/test-vinext-pages.mjs @@ -73,7 +73,9 @@ for (const deployment of deployments) for (const reference of [true, false]) { await writeFile(join(cwd, 'next.config.mjs'), `export default ${JSON.stringify({ reactStrictMode: true, basePath, trailingSlash: !!basePath, ...(deployment === 'standalone' ? { output: 'standalone' } : staticExport ? { output: 'export' } : {}) })}\n`) if (workers) await cp(join(consumer, 'wrangler.jsonc'), join(cwd, 'wrangler.jsonc')) const config = join(cwd, 'vite.config.mjs') - await writeFile(config, `import { defineConfig } from 'vite'\nimport vinext from 'vinext'\nimport { redact } from '@tanstack/redact/vinext'\nimport { cloudflare } from '@tanstack/redact/cloudflare'\nexport default defineConfig({ root: ${JSON.stringify(cwd)}, cacheDir: ${JSON.stringify(join(cwd, '.vite'))}, plugins: [vinext({appDir:${JSON.stringify(cwd)}}), ${workers ? `await cloudflare({configPath:${JSON.stringify(join(cwd, 'wrangler.jsonc'))},viteEnvironment:{name:'ssr'},inspectorPort:false,persistState:false,remoteBindings:false,tunnel:false}),` : ''} redact({renderer:${JSON.stringify(reference ? 'react' : 'redact')}})] })\n`) + // Programmatic edits can arrive inside the watcher's duplicate-event window. + // Emit each completed save before checking Fast Refresh state preservation. + await writeFile(config, `import { defineConfig } from 'vite'\nimport vinext from 'vinext'\nimport { redact } from '@tanstack/redact/vinext'\nimport { cloudflare } from '@tanstack/redact/cloudflare'\nexport default defineConfig({ root: ${JSON.stringify(cwd)}, cacheDir: ${JSON.stringify(join(cwd, '.vite'))}, server: { watch: { awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 10 } } }, plugins: [vinext({appDir:${JSON.stringify(cwd)}}), ${workers ? `await cloudflare({configPath:${JSON.stringify(join(cwd, 'wrangler.jsonc'))},viteEnvironment:{name:'ssr'},inspectorPort:false,persistState:false,remoteBindings:false,tunnel:false}),` : ''} redact({renderer:${JSON.stringify(reference ? 'react' : 'redact')}})] })\n`) const env = { ...process.env, PORT: String(port), HOST: '127.0.0.1', NEXT_PUBLIC_BASE_PATH: basePath, NEXT_TELEMETRY_DISABLED: '1' } let server, http, browser, logs = '', failure const children = new Set()