You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(migrate): move task cache settings in wrapped config callbacks (#2823)
The task cache migration from #2814 skipped `run.tasks` in configs
written as a `defineConfig` callback with a type assertion, and printed
no warning:
```ts
export default defineConfig(
(conf) =>
({
run: { tasks: { build: { command: 'tsc && vp build', input: [...], output: [...] } } },
}) as UserConfig,
);
```
It looked through `as` directly around the config object, but not
through the parentheses of the arrow body, nor through parentheses or
assertions around the callback itself (`defineConfig(((conf) => ({ ...
})) as T)`). `vp migrate` reported success, then `vp run` failed with
`Failed to load task graph: Cache settings ... must be set under cache`
and asked the user to run `vp migrate` again.
The migration now looks through any mix of parentheses and type
assertions around the config object and around its `defineConfig`
callback.
It also warns about tasks in a top-level `vite.config.*` object that is
not the exported config, such as a variable the config refers to or an
object passed to `mergeConfig`, instead of skipping them silently. Tasks
created in other modules, for example by a shared helper, are still not
detected; the migration rules page now says so.
Found by the v1.0.0-rc.1 ecosystem smoke test (#2818):
| Project | Before | After |
| --- | --- | --- |
| `vite-plus-ecosystem-ci/BlockNote` | 19 `vite.config.ts` files left
unchanged without a warning; CI fails to load the task graph | All 19
migrate; a second pass finds nothing left to move |
| `vite-plus-ecosystem-ci/cloudflare-os` | No warning | Warns about
`typed-storage`'s `build` task, which is passed to a helper. Tasks built
in shared helper modules still need manual changes |
The new unit tests fail against the previous logic and pass with this
change.
Copy file name to clipboardExpand all lines: docs/guide/migrate-rules.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,6 +90,8 @@ The transform does not evaluate configuration code. It leaves a task unchanged a
90
90
- a moved setting that already exists in `cache`;
91
91
- a `cache` value other than `true` or an object literal.
92
92
93
+
It also warns about tasks in a `vite.config.*` object that is not the exported config itself, such as a variable the config refers to or an object passed to `mergeConfig`. Tasks created in other modules, for example by a shared helper function, are not detected. Move their settings by hand; `vp run` lists every task that still needs it.
94
+
93
95
With `cache: false`, the moved settings would have no effect, so decide whether to remove them or enable caching. On a project that is otherwise up to date, `vp migrate` prints these warnings without running the rest of the migration.
0 commit comments