Improve build report route analysis with AST parsing#606
Open
Boyeep wants to merge 12 commits intocloudflare:mainfrom
Open
Improve build report route analysis with AST parsing#606Boyeep wants to merge 12 commits intocloudflare:mainfrom
Boyeep wants to merge 12 commits intocloudflare:mainfrom
Conversation
commit: |
Collaborator
|
Sorry to be a pain - have you looked at oxc-parser before? It might be a nice option to try out as it has great performance and compatibility - https://npmx.dev/package/oxc-parser |
Contributor
Author
|
oxc-parser actually does seem like a strong option here. For this PR, I’d prefer to keep the current TypeScript compiler API approach so the scope stays limited to improving report accuracy and landing the current follow-up fixes cleanly. But I agree Oxc looks like a very reasonable option for the longer-term parser-based follow-up, and I’d be happy to explore that in a separate PR. |
Collaborator
|
Completely slipped my mind before - Vite also has a |
Contributor
Author
|
Yeah, that makes sense probably worth checking first. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #605
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.
Switched build-report source inspection in
packages/vinext/src/build/report.tsto TypeScript AST parsingReplaced regex-based detection for:
named exports
export const dynamic = ...export const revalidate = ...getStaticPropsrevalidateextractionReused a single parsed AST per file during route classification instead of reparsing for each helper
Added support for:
aliased exports
local identifier aliases
as constsatisfiesextension-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
Added regression coverage for:
getStaticPropsgetStaticPropsfactoriesas const/satisfiesvp test tests/build-report.test.tspasses with 107 tests.vp lintstill reports the existing unrelated benchmark import errors:benchmarks/vinext/vite.config.tsbenchmarks/vinext-rolldown/vite.config.ts