Skip to content

feat(migrate): move task cache settings under cache - #2814

Merged
wan9chi merged 4 commits into
chore/bump-vite-task-7d69d65from
feat/migrate-task-cache-fields
Sep 25, 2026
Merged

wan9chi merged 4 commits into
chore/bump-vite-task-7d69d65from
feat/migrate-task-cache-fields

Conversation

@wan9chi

@wan9chi wan9chi commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Stacked on #2813, which bumps vite-task to a version that rejects env, untrackedEnv, input, and output at the top level of a task. Its error message tells users to run vp migrate; this PR makes that work.

What vp migrate does

It moves those four settings into the task's cache object in static run.tasks objects in vite.config.*, including configs wrapped in satisfies or as. This runs on fresh migrations and on existing Vite+ projects without --full, for the workspace root and every workspace package.

Before After
build: { command, env: [...] } build: { command, cache: { env: [...] } }
build: { command, cache: true, input: [...] } build: { command, cache: { input: [...] } }
build: { cache: { env: [...] }, output: [...] } build: { cache: { env: [...], output: [...] } }
  • The new cache object takes the position of the first moved setting, or of an existing cache: true.
  • Moved settings keep their text and indentation. The formatting step that runs after a migration indents them inside cache. Like the pack config migration, the edit doesn't try to format the file itself.
  • Comments on their own line above a moved setting, and // comments after it on the same line, move with it.
  • The rewrite does not evaluate config code. It leaves a task unchanged and adds a warning with a link to /config/run#cache for:
    • spreads, or computed, escaped, or duplicate keys;
    • a moved setting written as a method;
    • a comment between a moved setting and its comma, or after the last setting in cache;
    • a moved setting that already exists in cache;
    • cache: false, a shorthand cache, or any other non-literal cache value.
  • On an existing Vite+ project, these warnings don't count as a migration. When nothing else changes, vp migrate prints them and then "This project is already using Vite+!".

The migration summary gets a Task cache settings moved under `cache` line and counts the change as a config update.

Implementation

  • crates/vp_migration/src/task_cache.rs: the AST rewrite and its unit tests. It returns the updated content and the tasks that need manual changes.
  • packages/cli/binding/src/migration.rs: exposes it as migrateTaskCacheConfig.
  • packages/cli/src/migration: migrateTaskCacheConfigInViteConfig runs next to the lazyPlugins wrapping in the standalone, monorepo, and rewriteMonorepoProject paths. On existing Vite+ projects it runs in finalizeCoreMigrationForExistingVitePlus, which reports taskCacheConfig and returns the warnings in taskCacheWarnings. bin.ts adds them to the report only after the up-to-date check.
  • New migration_task_cache_fields snapshot fixture. It covers a migration followed by a second, unchanged run, and the manual-review warnings, including a rerun on the up-to-date project.
  • Docs: a "Task Cache Configuration" section in docs/guide/migrate-rules.md.

Docs builds

The docs site is built with the released vp from setup-vp, not with this repo's build. docs/vite.config.ts keeps the old task format that 1.0.0-rc.0 accepts, because no format works with both that release and the new vite-task. Until now setup-vp installed the latest release, so the first release with the new vite-task would have broken docs deploys and previews. This PR pins version: 1.0.0-rc.0 in .github/actions/deploy-docs/action.yml and .github/workflows/build-docs-fork-preview.yml.

Follow-up after the release becomes npm latest: remove both pins and move the build:site settings under cache in one PR. That PR's staging-deploy check builds the docs with the new release and the converted config.

@wan9chi
wan9chi added this pull request to stack #2815 September 25, 2026 04:29
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://feat-migrate-task-cache-fields-viteplus-dev.voidzero-docs.workers.dev (commit 14c65ed)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://32541022-viteplus-dev.voidzero-docs.workers.dev 14c65ed 2026-09-25T09:39:03.565Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://0429891c-viteplus-dev.voidzero-docs.workers.dev a82648f 2026-09-25T07:46:12.076Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://88cf88c4-viteplus-dev.voidzero-docs.workers.dev b68d4fe 2026-09-25T06:05:37.469Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://a99b6dac-viteplus-dev.voidzero-docs.workers.dev e54e1ec 2026-09-25T05:43:20.908Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://40685412-viteplus-dev.voidzero-docs.workers.dev 60bf751 2026-09-25T04:30:39.174Z Visit the dashboard ↗

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Staging deployment successful!

Preview: https://viteplus-staging.void.app/
Commit: 14c65ed

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

CLI artifact sizes (14c65ed)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.
The dist rows use the Linux build. The core total excludes .node files to match the release artifact.

Artifact Format Base PR Change
packages/cli/dist Directory total 2.34 MiB 2.35 MiB +2.34 KiB (+0.10%)
packages/core/dist Directory total 3.95 MiB 3.95 MiB 0 B (0.00%)
Combined package dist Directory total 6.30 MiB 6.30 MiB +2.34 KiB (+0.04%)
vp (Linux x64) Binary 11.29 MiB 11.29 MiB 0 B (0.00%)
vp (Linux x64) gzip -9 4.88 MiB 4.88 MiB 0 B (0.00%)
NAPI (Linux x64) Binary 32.19 MiB 32.23 MiB +36.00 KiB (+0.11%)
NAPI (Linux x64) gzip -9 12.76 MiB 12.77 MiB +10.76 KiB (+0.08%)
vp (macOS ARM64) Binary 8.41 MiB 8.41 MiB 0 B (0.00%)
vp (macOS ARM64) gzip -9 4.26 MiB 4.26 MiB 0 B (0.00%)
NAPI (macOS ARM64) Binary 39.80 MiB 39.83 MiB +32.30 KiB (+0.08%)
NAPI (macOS ARM64) gzip -9 17.07 MiB 17.08 MiB +9.18 KiB (+0.05%)
vp (Windows x64) Binary 9.15 MiB 9.15 MiB 0 B (0.00%)
vp (Windows x64) gzip -9 4.00 MiB 4.00 MiB +3 B (+0.00%)
NAPI (Windows x64) Binary 27.15 MiB 27.17 MiB +28.50 KiB (+0.10%)
NAPI (Windows x64) gzip -9 10.87 MiB 10.88 MiB +12.48 KiB (+0.11%)
Trampoline (Windows x64) Binary 13.50 KiB 13.50 KiB 0 B (0.00%)
Trampoline (Windows x64) gzip -9 7.09 KiB 7.08 KiB -2 B (-0.03%)
Installer (Windows x64) Binary 4.56 MiB 4.56 MiB 0 B (0.00%)
Installer (Windows x64) gzip -9 2.13 MiB 2.13 MiB -2 B (-0.00%)

@wan9chi
wan9chi force-pushed the feat/migrate-task-cache-fields branch from 60bf751 to e54e1ec Compare September 25, 2026 05:42
@wan9chi
wan9chi marked this pull request as draft September 25, 2026 05:57
- Keep moved settings as written instead of reindenting them; the
  post-migration formatter nests them inside `cache`.
- Leave tasks with a comment before a moved setting's comma, or after the
  last setting in `cache`, for manual review instead of misplacing it.
- Move a trailing `//` comment even when the setting has no comma.
- Treat escaped keys as unknown so they cannot hide a conflict.
- Recognize configs wrapped in `as` type assertions.
- Report manual-review warnings on up-to-date projects without running
  the rest of the migration.
@wan9chi
wan9chi marked this pull request as ready for review September 25, 2026 09:24
@wan9chi
wan9chi merged commit 688fe4a into main Sep 25, 2026
72 checks passed
@wan9chi
wan9chi deleted the feat/migrate-task-cache-fields branch September 25, 2026 09:47
wan9chi added a commit that referenced this pull request Sep 25, 2026
Bumps vite-task from `790b152` to `7d69d65`.

Changelog:
voidzero-dev/vite-task@790b152...7d69d65#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed

## Changes from vite-task

- **Changed** A task's cache settings now go inside `cache`, e.g.
`cache: { env: ["NODE_ENV"], input: ["src/**"] }`. `cache: true` is the
same as `cache: {}`. Top-level `env`, `untrackedEnv`, `input`, and
`output` are rejected with an error that points to `vp migrate`
([voidzero-dev/vite-task#749](voidzero-dev/vite-task#749)).
- **Fixed** On Windows, environment variable names used by `vp run`
match regardless of ASCII letter case
([voidzero-dev/vite-task#747](voidzero-dev/vite-task#747)).
- **Fixed** Cached tasks on macOS no longer intermittently fail with
`oils I/O error (main): No such process`
([voidzero-dev/vite-task#703](voidzero-dev/vite-task#703)).

## Changes in this PR

- `Session::init_with`, `ScriptCommand::envs`, and
`SyntheticPlanRequest::envs` now key environment variables by
`vt_casefold::EnvName`. The `vite-plus-cli` env maps use the same key
type (`EnvMap`), so PATH lookup and env merging follow the platform
rules. The hand-written case-insensitive PATH lookups are replaced by
`vt::get_path_env`.
- Adds `vt_casefold` as a workspace dependency, including the commented
local `[patch]` entry.
- Regenerates `packages/cli/src/run-config.ts`.
- Moves top-level task cache fields under `cache` in CLI snapshot
fixtures and a `vp_static_config` test.
- Keeps `docs/vite.config.ts` in the old format. Docs deploys build it
with the released `vp` from `setup-vp`, and that version rejects a
`cache` object. #2814 pins that `vp` version for docs builds, so the
first release with this vite-task doesn't break them.
- Documents the `cache` object in `docs/config/run.md`. `env`,
`untrackedEnv`, `input`, and `output` become `cache.env`,
`cache.untrackedEnv`, `cache.input`, and `cache.output`. Updates the
examples and links in the cache, run, and automatic data tracking guides
and the READMEs. The docs describe only the `cache` object and don't
mention the old top-level fields.

`vp migrate` support for moving these fields comes in the next PR in
this stack.
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