Skip to content

refactor(plugins): use ESTree types for AST transforms - #3172

Open
camc314 wants to merge 1 commit into
cloudflare:mainfrom
camc314:codex/use-estree-node-types
Open

refactor(plugins): use ESTree types for AST transforms#3172
camc314 wants to merge 1 commit into
cloudflare:mainfrom
camc314:codex/use-estree-node-types

Conversation

@camc314

@camc314 camc314 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace loose structural AST records with Vite-exported ESTree node types across plugin transforms
  • pass typed programs and nodes through traversal and scope helpers instead of repeatedly validating parser output at runtime
  • migrate the remaining structural callers and utility tests to use the real parser node shapes

Copilot AI lite review requested due to automatic review settings September 3, 2026 15:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T15:59:50.159501Z 14d1dd8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@3172
npm i https://pkg.pr.new/create-vinext-app@3172
npm i https://pkg.pr.new/@vinext/types@3172
npm i https://pkg.pr.new/vinext@3172

commit: 14d1dd8

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The refactor touches many critical AST-based transforms and shared traversal/scope utilities, making subtle behavioral regressions hard to rule out without a deeper manual review and full test/fixture validation.

Pull request overview

Refactors vinext’s plugin AST transforms to use Vite-exported ESTree node types end-to-end, replacing prior “loose record” AST shapes and runtime validation with typed node threading through traversals and scope helpers.

Changes:

  • Migrates core AST utilities (ast-utils, ast-scope) from structural records to ESTree.Node APIs (typed traversal, binding collection, wrapper unwrapping).
  • Updates multiple transform plugins to consume typed programs/nodes directly (removing many isAstRecord / hasRange / nodeArray guards).
  • Refreshes AST utility tests to use parseAst() output shapes instead of hand-built node objects.
File summaries
File Description
tests/plugin-utils.test.ts Updates AST utility tests to parse real code via parseAst() and assert against actual ESTree node shapes.
packages/vinext/src/plugins/worker-image-imports.ts Uses ESTree types when walking and rewriting import specifiers for worker image handling.
packages/vinext/src/plugins/typeof-window.ts Converts environment-condition replacement logic to operate on typed ESTree.Node values and typed scopes.
packages/vinext/src/plugins/styled-jsx.ts Tightens JSX tag detection using typed JSX node fields rather than structural casting.
packages/vinext/src/plugins/require-context.ts Refactors require.context parsing/analysis helpers to typed ESTree nodes (incl. regex literal handling).
packages/vinext/src/plugins/require-condition-resolution.ts Moves conditional-require analysis to typed nodes and simplifies traversal over typed bodies/args.
packages/vinext/src/plugins/pages-node-externals.ts Updates dependency specifier extraction to use typed import/export/dynamic-import node handling.
packages/vinext/src/plugins/optimize-imports.ts Replaces custom declaration shape types with typed declaration/binding collection via collectBindingNames.
packages/vinext/src/plugins/middleware-export-validation.ts Switches middleware export static analysis to iterate typed program statements/specifiers.
packages/vinext/src/plugins/import-meta-url.ts Converts import.meta.url detection and CJS global analysis to typed nodes, simplifying child walking.
packages/vinext/src/plugins/ignore-dynamic-requests.ts Refactors dynamic request detection/static evaluation helpers to typed ESTree nodes and arguments.
packages/vinext/src/plugins/extensionless-dynamic-import.ts Updates extensionless dynamic import collection/parsing to typed ESTree.Program and nodes.
packages/vinext/src/plugins/dynamic-preload-metadata.ts Replaces record-based AST inspection with typed traversal, binding collection, and object property helpers.
packages/vinext/src/plugins/ast-utils.ts Core change: redefines AST utility surface area around ESTree types (walkers, literal helpers, bindings).
packages/vinext/src/plugins/ast-scope.ts Updates scope/binding collection utilities to typed node unions and typed statement-container handling.
Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 14d1dd8 against base e91f3bd using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.3 KB 142.3 KB ⚫ -0.0%
Client entry size (gzip) vinext 129.6 KB 129.6 KB ⚫ -0.0%
Dev server cold start vinext 2.62 s 2.61 s ⚫ -0.4%
Production build time vinext 2.80 s 2.81 s ⚫ +0.1%
RSC entry closure size (gzip) vinext 119.2 KB 119.2 KB ⚫ -0.0%
Server bundle size (gzip) vinext 202.8 KB 202.8 KB ⚫ -0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants