Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e6d9a68
checkpoint
james-elicx Mar 31, 2026
1618f15
.
james-elicx Apr 1, 2026
07960f0
.
james-elicx Apr 2, 2026
446fcd9
.
james-elicx Apr 2, 2026
4435463
feat(cache): emit deprecation warning when revalidateTag called witho…
james-elicx Apr 2, 2026
3db6ae6
feat(prerender): pass dynamic-usage reason via HTTP response header
james-elicx Apr 2, 2026
399eacd
feat(app-router): warn when runtime='edge' and dynamic='force-static'…
james-elicx Apr 2, 2026
83df3f3
fix(prerender): support layout-level generateStaticParams in static map
james-elicx Apr 2, 2026
73c107e
.
james-elicx Apr 3, 2026
c07495a
test(next-fixture): mock api/delay endpoint to eliminate 3s network o…
james-elicx Apr 3, 2026
a1a7439
test(next-fixture): exclude *-custom-handler.test.* from Vitest colle…
james-elicx Apr 3, 2026
94be787
test(next-fixture): fix CJS require() of .test modules via Vite plugin
james-elicx Apr 3, 2026
cf4f061
Remove 2MB in-memory fetch cache limit; restore load-data skip entry
james-elicx Apr 3, 2026
c2b6a00
fix: 5 start-mode tests for partial-gen-params, force-static revalida…
james-elicx Apr 3, 2026
6db6868
fix(tests): pass 'should correctly error and not update cache for ISR'
james-elicx Apr 3, 2026
d18da06
fix: propagate unstable_cache tags to prerendered ISR entries for cor…
james-elicx Apr 3, 2026
24ce675
feat: emit .meta files during prerender and fix readFile path in star…
james-elicx Apr 3, 2026
bea8bb3
feat: skip caching fetch responses >2MB in dev mode to match Next.js …
james-elicx Apr 3, 2026
a1a54a7
feat: correct cache tags for prerendered 404 routes + intercept .meta…
james-elicx Apr 3, 2026
0884d48
feat: collect prerender fetch metrics and expose as .next/diagnostics…
james-elicx Apr 3, 2026
4c9bb32
fix(vinext): fix RSC Vary header, pages RSC routing, and content-type
james-elicx Apr 3, 2026
d442870
fix(vinext): inject RSC finalize scripts before </body></html>
james-elicx Apr 3, 2026
fc38e76
fix(next-test-setup): emit Experiments startup message for fixtures w…
james-elicx Apr 3, 2026
3b14fbf
fix(next.js): skip tests requiring window.next.router / Next.js-speci…
james-elicx Apr 3, 2026
02aac7b
fix(vinext): reorder route params in URL segment order for pages and …
james-elicx Apr 3, 2026
071648a
fix(vinext): forward rewrite query params and add per-layout loading …
james-elicx Apr 3, 2026
f6f0098
test(vinext): wait 60ms after hydration for React effects to settle
james-elicx Apr 4, 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
Prev Previous commit
Next Next commit
test(next-fixture): fix CJS require() of .test modules via Vite plugin
Some upstream Next.js fixture files use CJS require('./foo.test') to
re-run another test file with a different env var. In our ESM-first
Vitest setup this fails because Node.js's CJS require can't load
TypeScript modules that use ESM imports with Vite aliases (e.g.
e2e-utils).

Fix: add a pre-transform Vite plugin that rewrites require('./foo.test')
to await import('./foo.test'). Vitest processes every .ts file through
vite-node's async module evaluator so top-level await works, and the
dynamic import() goes through Vite's full module resolution pipeline
(aliases, TypeScript transforms, etc.).

Result: app-static-custom-handler.test.ts now loads cleanly and shows
77 tests skipped (via skip-manifest "*":["*"]) instead of crashing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  • Loading branch information
james-elicx and claude committed Apr 3, 2026
commit 94be787a96e8b1b02a88388ecddde2e873e86101
37 changes: 28 additions & 9 deletions tests/fixtures-repos/next.js/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
import { defineConfig } from "vite-plus";
import { defineConfig, type Plugin } from "vite-plus";
import { randomUUID } from "node:crypto";
import { join } from "node:path";

/**
* Some upstream Next.js fixture files use CJS `require('./some.test')` to
* re-run another test file with different env vars (e.g.
* app-static-custom-handler.test.ts requires app-static.test.ts). In our
* ESM-first Vitest setup this fails because Node.js's CJS require can't load
* TypeScript files that use ESM `import` statements with Vite aliases.
*
* The fix: transform `require('./foo.test')` → `await import('./foo.test')`.
* Vitest processes every .ts file through vite-node's async module evaluator,
* so top-level `await` works. The dynamic `import()` goes through Vite's full
* module resolution pipeline, which resolves aliases like `e2e-utils` and
* applies TypeScript transforms correctly.
*/
const requireToImportPlugin: Plugin = {
name: "vinext-test:cjs-require-to-esm-import",
enforce: "pre",
transform(code, id) {
if (!id.includes("/clone/")) return;
if (!code.includes("require(")) return;
return code.replace(
/\brequire\((['"])(\.\/[^'"]+\.test)\1\)/g,
(_match, _quote, specifier) => `await import('${specifier}')`,
);
},
};

export default defineConfig({
plugins: [requireToImportPlugin],
test: {
reporters: process.env.CI ? ["default", "github-actions"] : ["default", "agent"],
setupFiles: [join(import.meta.dirname, "./vitest-setup.ts")],
Expand All @@ -13,14 +40,6 @@ export default defineConfig({
"next-test-utils": join(import.meta.dirname, "./next-test-utils.js"),
},

// Exclude fixture files that use CJS `require('./foo.test')` to re-run
// another test file with different env vars. vite-node's require shim
// falls back to Node.js CJS for the required file's transitive ESM
// imports, which can't resolve Vite aliases (e.g. 'e2e-utils'). These
// files are covered by the skip-manifest "*": ["*"] wildcard anyway —
// excluding them produces the same outcome without the load-time crash.
exclude: ["**/*-custom-handler.test.*", "**/node_modules/**"],

fileParallelism: false,
testTimeout: 30_000,
globals: true,
Expand Down