Commit 963316e
feat(config): static vite config extraction for
Add new `vite_static_config` crate that uses `oxc_parser` to statically
extract JSON-serializable fields from `vite.config.*` files without
executing JavaScript
## Performance
Measured using Chrome trace instrumentation (PR #663).
On a cache hit, `vp run` loads the config, validates the fingerprint,
and streams cached output — no build work. Before this PR, config
loading required a NAPI round-trip to evaluate the config file. With
static extraction that cost drops to ~0ms.
### `vp run` end-to-end time (cache hit)
| Project | Before | After | Reduction |
|---------|--------|-------|-----------|
| vue-mini | ~217ms | **23ms** | ~89% |
| oxlint-plugin-complexity | ~220ms | **17ms** | ~92% |
| vitepress | ~282ms | **32ms** | ~89% |
| vite-vue-vercel | ~326ms | **28ms** | ~91% |
| rollipop | ~670ms | **16–53ms** | ~92–98% |
| frm-stack (10 packages) | ~895ms | **34–69ms** | ~92–96% |
| tanstack-start-helloworld | ~1,383ms | ~1,394ms | — (indirect export,
not yet handled) |
## Summary
- `VitePlusConfigLoader` now tries static extraction first for the `run`
config, falling back to NAPI-based resolution only when the config
cannot be statically extracted
- Static extraction supports all common patterns:
- `export default { ... }` — bare object literal
- `export default defineConfig({ ... })` — direct call
- `export default defineConfig(() => ({ ... }))` — concise arrow body
- `export default defineConfig(fn)` — block body with single return
- `module.exports = ...` — CJS equivalents
- When no `vite.config.*` file exists, returns an empty map immediately
(skips NAPI entirely)
- Spread and computed-key properties correctly invalidate
previously-seen fields
## Test plan
- [x] 50 unit tests in `vite_static_config` pass
- [x] All existing `vite-plus-cli` tests pass
- [x] `cargo fmt --check` passes
- [x] `cargo shear` reports no unused dependencies
- [x] `cargo clippy` clean (no new warnings)
- [ ] CI passes on all platforms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>run config (#679)1 parent 72ff497 commit 963316e
File tree
7 files changed
+1181
-0
lines changed- crates/vite_static_config
- src
- packages/cli/binding
- src
7 files changed
+1181
-0
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| |||
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| 215 | + | |
214 | 216 | | |
| 217 | + | |
| 218 | + | |
215 | 219 | | |
216 | 220 | | |
217 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments