[PR #606] Improve build report route analysis with AST parsing #706

Open
opened 2026-05-06 13:09:41 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/606
Author: @Boyeep
Created: 3/20/2026
Status: 🔄 Open

Base: mainHead: fix/scope-getstaticprops-revalidate


📝 Commits (10+)

  • e6b1264 fix: scope getStaticProps revalidate parsing
  • 5a1f4c8 fix: handle early returns in getStaticProps revalidate parsing
  • 8e6136f fix: scope getStaticProps parsing to its declaration
  • 98598e2 fix: handle destructured getStaticProps params
  • 1a86e86 fix: ignore nested helper returns in getStaticProps
  • 8942db5 fix: avoid re-export false positives in getStaticProps parsing
  • 4280a13 fix: harden getStaticProps revalidate parsing
  • f3d2a60 chore: polish getStaticProps parser follow-up
  • 78a438b Improve build report route analysis with AST parsing
  • 685b5c9 Merge upstream/main into fix/scope-getstaticprops-revalidate

📊 Changes

16 files changed (+781 additions, -569 deletions)

View changed files

📝 packages/vinext/package.json (+1 -0)
📝 packages/vinext/src/build/report.ts (+447 -425)
📝 pnpm-lock.yaml (+3 -0)
📝 tests/build-report.test.ts (+262 -144)
tests/fixtures/build-report/lib/build-report-shared-gsp.ts (+3 -0)
tests/fixtures/build-report/lib/build-report-types.ts (+7 -0)
tests/fixtures/build-report/pages/build-report-alias-export.tsx (+7 -0)
tests/fixtures/build-report/pages/build-report-default-export-gsp.tsx (+3 -0)
tests/fixtures/build-report/pages/build-report-default-export-gssp.tsx (+3 -0)
tests/fixtures/build-report/pages/build-report-factory-gsp.tsx (+11 -0)
tests/fixtures/build-report/pages/build-report-generic-gsp.ts (+5 -0)
tests/fixtures/build-report/pages/build-report-import-reexport-gsp.tsx (+7 -0)
tests/fixtures/build-report/pages/build-report-local-identifier-gsp.tsx (+7 -0)
tests/fixtures/build-report/pages/build-report-reexport-gsp.tsx (+5 -0)
tests/fixtures/build-report/pages/build-report-type-only-gsp.tsx (+5 -0)
tests/fixtures/build-report/pages/build-report-type-only-gssp.tsx (+5 -0)

📄 Description

Fixes #605

  1. Summary

This replaces the build report’s regex/string-based route analysis with AST-based analysis using the TypeScript compiler API.

The main goal is to make route classification more accurate, especially around getStaticProps and exported route config, while keeping the existing report flow intact.

  1. What changed
  • Switched build-report source inspection in packages/vinext/src/build/report.ts to TypeScript AST parsing

  • Replaced regex-based detection for:

  • named exports

  • export const dynamic = ...

  • export const revalidate = ...

  • getStaticProps revalidate extraction

  • Reused a single parsed AST per file during route classification instead of reparsing for each helper

  • Added support for:

  • aliased exports

  • local identifier aliases

  • as const

  • satisfies

  • extension-aware TS vs TSX parsing

  • Ignored non-runtime exports:

  • export type { ... }

  • export { type ... }

  • export declare ...

  • Treated non-local or non-analyzable getStaticProps exports conservatively as unknown instead of incorrectly reporting static

  • Applied speculative prerender promotion to Pages routes as well, so Pages routes classified as unknown can still be upgraded to static when prerender confirms them

  1. Tests

Added regression coverage for:

  • early-return redirects
  • re-exports
  • imported re-exports
  • aliased exports
  • default exports
  • type-only exports
  • generic arrow getStaticProps
  • local identifier aliases
  • non-analyzable local getStaticProps factories
  • as const / satisfies
  • speculative prerender upgrade for Pages routes

vp test tests/build-report.test.ts passes with 107 tests.

  1. Notes

vp lint still reports the existing unrelated benchmark import errors:

benchmarks/vinext/vite.config.ts
benchmarks/vinext-rolldown/vite.config.ts


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/606 **Author:** [@Boyeep](https://github.com/Boyeep) **Created:** 3/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/scope-getstaticprops-revalidate` --- ### 📝 Commits (10+) - [`e6b1264`](https://github.com/cloudflare/vinext/commit/e6b1264ea2d2df31d006bb7f425b1c69941de36e) fix: scope getStaticProps revalidate parsing - [`5a1f4c8`](https://github.com/cloudflare/vinext/commit/5a1f4c87f09c20869fef746c99dace6e3ca631ac) fix: handle early returns in getStaticProps revalidate parsing - [`8e6136f`](https://github.com/cloudflare/vinext/commit/8e6136fde80b4906ed82cdde158b13fcda278eee) fix: scope getStaticProps parsing to its declaration - [`98598e2`](https://github.com/cloudflare/vinext/commit/98598e2ab9f3039158a0d4d80f98e10a73dc275a) fix: handle destructured getStaticProps params - [`1a86e86`](https://github.com/cloudflare/vinext/commit/1a86e860d36e65e30594c02b482413a2bbc1b80a) fix: ignore nested helper returns in getStaticProps - [`8942db5`](https://github.com/cloudflare/vinext/commit/8942db5cc745229d0fdb5e704db00135a2e1823f) fix: avoid re-export false positives in getStaticProps parsing - [`4280a13`](https://github.com/cloudflare/vinext/commit/4280a136fed97c49378a7c9d80ccdf19b90e8ff3) fix: harden getStaticProps revalidate parsing - [`f3d2a60`](https://github.com/cloudflare/vinext/commit/f3d2a6081882aa97afc711fdbe54ecc7bb718c7d) chore: polish getStaticProps parser follow-up - [`78a438b`](https://github.com/cloudflare/vinext/commit/78a438b13bc27da55d42ea0906efda684587b017) Improve build report route analysis with AST parsing - [`685b5c9`](https://github.com/cloudflare/vinext/commit/685b5c98b63b96ea4afc6bd4d8e58ec0e4e73f58) Merge upstream/main into fix/scope-getstaticprops-revalidate ### 📊 Changes **16 files changed** (+781 additions, -569 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/package.json` (+1 -0) 📝 `packages/vinext/src/build/report.ts` (+447 -425) 📝 `pnpm-lock.yaml` (+3 -0) 📝 `tests/build-report.test.ts` (+262 -144) ➕ `tests/fixtures/build-report/lib/build-report-shared-gsp.ts` (+3 -0) ➕ `tests/fixtures/build-report/lib/build-report-types.ts` (+7 -0) ➕ `tests/fixtures/build-report/pages/build-report-alias-export.tsx` (+7 -0) ➕ `tests/fixtures/build-report/pages/build-report-default-export-gsp.tsx` (+3 -0) ➕ `tests/fixtures/build-report/pages/build-report-default-export-gssp.tsx` (+3 -0) ➕ `tests/fixtures/build-report/pages/build-report-factory-gsp.tsx` (+11 -0) ➕ `tests/fixtures/build-report/pages/build-report-generic-gsp.ts` (+5 -0) ➕ `tests/fixtures/build-report/pages/build-report-import-reexport-gsp.tsx` (+7 -0) ➕ `tests/fixtures/build-report/pages/build-report-local-identifier-gsp.tsx` (+7 -0) ➕ `tests/fixtures/build-report/pages/build-report-reexport-gsp.tsx` (+5 -0) ➕ `tests/fixtures/build-report/pages/build-report-type-only-gsp.tsx` (+5 -0) ➕ `tests/fixtures/build-report/pages/build-report-type-only-gssp.tsx` (+5 -0) </details> ### 📄 Description ## Fixes #605 1. Summary This replaces the build report’s regex/string-based route analysis with AST-based analysis using the TypeScript compiler API. The main goal is to make route classification more accurate, especially around getStaticProps and exported route config, while keeping the existing report flow intact. 2. What changed - Switched build-report source inspection in `packages/vinext/src/build/report.ts` to TypeScript AST parsing - Replaced regex-based detection for: - named exports - `export const dynamic = ...` - `export const revalidate = ...` - `getStaticProps` `revalidate` extraction - Reused a single parsed AST per file during route classification instead of reparsing for each helper - Added support for: - aliased exports - local identifier aliases - `as const` - `satisfies` - extension-aware TS vs TSX parsing - Ignored non-runtime exports: - `export type { ... }` - `export { type ... }` - `export declare ...` - Treated non-local or non-analyzable getStaticProps exports conservatively as unknown instead of incorrectly reporting static - Applied speculative prerender promotion to Pages routes as well, so Pages routes classified as unknown can still be upgraded to static when prerender confirms them 3. Tests Added regression coverage for: - early-return redirects - re-exports - imported re-exports - aliased exports - default exports - type-only exports - generic arrow `getStaticProps` - local identifier aliases - non-analyzable local `getStaticProps` factories - `as const` / `satisfies` - speculative prerender upgrade for Pages routes `vp test tests/build-report.test.ts` passes with 107 tests. 4. Notes `vp lint` still reports the existing unrelated benchmark import errors: `benchmarks/vinext/vite.config.ts` `benchmarks/vinext-rolldown/vite.config.ts` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#706
No description provided.