Skip to content

feat(build): run lifecycle through Vite - #3377

Draft
james-elicx wants to merge 19 commits into
codex/shared-build-lifecyclefrom
codex/vite-build-lifecycle
Draft

james-elicx wants to merge 19 commits into
codex/shared-build-lifecyclefrom
codex/vite-build-lifecycle

Conversation

@james-elicx

@james-elicx james-elicx commented Sep 22, 2026

Copy link
Copy Markdown
Member

Summary

  • connect the shared lifecycle to full direct Vite CLI builds, including global options before the command
  • keep watch, targeted/SSR, ordinary programmatic, and nested Vite builds outside the top-level lifecycle
  • preserve configured prerender concurrency, resolved user plugins, custom output roots, and production semantics
  • isolate the auxiliary hybrid Pages bundle in its own named environment

Validation

  • Vite command contract and invocation tests
  • prerender configuration tests
  • vp check
  • vp run vinext#build

PR 3 of 7.

@james-elicx
james-elicx added this pull request to stack #3382 September 22, 2026 11:37
@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@3377

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@3377

@vinext/types

npm i https://pkg.pr.new/@vinext/types@3377

vinext

npm i https://pkg.pr.new/vinext@3377

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@3377

commit: a6bef91

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues\n\nTime limit: 8 minutes. Complete the review and post all findings within that limit.

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
workers-cache preview production
kv preview production
static-export preview production
web preview production

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared a6bef91 against base 1f61de6 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.7 KB 129.7 KB ⚫ -0.0%
Dev server cold start vinext 3.37 s 3.34 s ⚫ -1.0%
Production build time vinext 3.91 s 3.93 s ⚫ +0.6%
RSC entry closure size (gzip) vinext 127.9 KB 127.8 KB ⚫ -0.1%
Server bundle size (gzip) vinext 226.0 KB 226.0 KB ⚫ +0.0%

View detailed results and traces

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

Comment thread packages/vinext/src/utils/vite-cli-invocation.ts Outdated
Comment thread packages/vinext/src/index.ts Outdated
Comment thread packages/vinext/src/config/prerender.ts
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 3 actionable inline findings.

github run

@james-elicx
james-elicx force-pushed the codex/vite-build-lifecycle branch from 078c7d0 to ab7311c Compare September 22, 2026 11:51
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues\n\nTime limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/build/lifecycle.ts Outdated
Comment thread packages/vinext/src/build/lifecycle.ts Outdated
Comment thread packages/vinext/src/build/lifecycle.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 3 actionable inline findings.

github run

@james-elicx
james-elicx force-pushed the codex/vite-build-lifecycle branch from ab7311c to 86e2104 Compare September 22, 2026 12:16
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/utils/vite-cli-invocation.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding. Targeted tests pass after rebuilding vinext.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues\n\nTime limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx
james-elicx force-pushed the codex/vite-build-lifecycle branch from 7f41ce5 to 9341cf4 Compare September 22, 2026 12:44
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues\n\nTime limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/build/lifecycle.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx
james-elicx force-pushed the codex/vite-build-lifecycle branch from 9341cf4 to ae580bb Compare September 22, 2026 13:06
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts Outdated
Comment thread packages/vinext/src/build/lifecycle.ts
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 2 actionable inline findings. Targeted unit tests pass.

github run

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@james-elicx Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues\n\nTime limit: 8 minutes. Complete the review and post all findings within that limit.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts Outdated
if (process.env.NODE_ENV !== resolvedNodeEnv) {
const preserveTestNodeEnv =
process.env.NODE_ENV === "test" &&
(mode === "test" || viteCliBuildConfigNodeEnv === "test");

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.

P1: This still preserves NODE_ENV=test solely because Vite's mode is test, even when there is no direct CLI invocation to justify config-time compatibility. The existing programmatic config contract now fails (tests/build-optimization.test.ts:946): calling this hook for { command: "build", mode: "test" } leaves process.env.NODE_ENV as test instead of switching the actual build to production. CI's Vitest (unit 1/3) is failing on exactly that assertion. Please gate preservation on the captured direct-CLI test environment rather than mode === "test"; mode selects config/env files but should not select build-time NODE_ENV.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding. Targeted lifecycle tests pass; CI confirms the reported NODE_ENV regression.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues\n\nTime limit: 8 minutes. Complete the review and post all findings within that limit.

index++;
continue;
}
if (arg.startsWith("-")) continue;

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.

P2: Treat -- as the end of option parsing instead of skipping it. CAC treats everything after this marker as positional input, so vite -- build starts the dev server with build as the project root (confirmed against the bundled Vite CLI), while this loop skips -- and classifies it as a production build. Because getViteCliInvocation() runs at module load, that valid dev invocation gets NODE_ENV=production and loads .env.production before its Vite config executes. Stop command detection at -- and preserve the remaining positional arguments for the default dev command.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding. Targeted unit tests pass.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

index++;
continue;
}
if (arg.startsWith("-")) continue;

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.

P2: CAC also expands clustered short options, but this scanner skips the cluster wholesale. For example, the bundled Vite CLI accepts vite -dm staging build (-d plus -m staging) and selects the production build command, while commandArguments() skips -dm, sees staging as the first positional, and classifies the invocation as a dev server rooted there. That suppresses the vinext lifecycle and also loads the wrong config-time mode/env. Please account for CAC's short-option clustering (or derive command/mode from the authoritative parsed invocation) rather than treating every option-looking token as one flag.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding. Targeted CLI invocation tests pass.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

No new actionable findings beyond the existing inline review comments.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

No new actionable findings beyond the existing inline review comments.

github run

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.

1 participant