Skip to content

Commit 391c9ba

Browse files
branchseerclaude
andcommitted
refactor: remove oxfmt dependency from TS type generation
The generated run-config.ts no longer needs to be formatted via oxfmt, removing the need for `pnpm install` in packages/tools during cargo test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 21a32db commit 391c9ba

File tree

2 files changed

+45
-84
lines changed

2 files changed

+45
-84
lines changed

crates/vite_task_graph/run-config.ts

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,51 +67,47 @@ export type Task = {
6767
}
6868
);
6969

70-
export type UserGlobalCacheConfig =
71-
| boolean
72-
| {
73-
/**
74-
* Enable caching for package.json scripts not defined in the `tasks` map.
75-
*
76-
* When `false`, package.json scripts will not be cached.
77-
* When `true`, package.json scripts will be cached with default settings.
78-
*
79-
* Default: `false`
80-
*/
81-
scripts?: boolean;
82-
/**
83-
* Global cache kill switch for task entries.
84-
*
85-
* When `false`, overrides all tasks to disable caching, even tasks with `cache: true`.
86-
* When `true`, respects each task's individual `cache` setting
87-
* (each task's `cache` defaults to `true` if omitted).
88-
*
89-
* Default: `true`
90-
*/
91-
tasks?: boolean;
92-
};
70+
export type UserGlobalCacheConfig = boolean | {
71+
/**
72+
* Enable caching for package.json scripts not defined in the `tasks` map.
73+
*
74+
* When `false`, package.json scripts will not be cached.
75+
* When `true`, package.json scripts will be cached with default settings.
76+
*
77+
* Default: `false`
78+
*/
79+
scripts?: boolean,
80+
/**
81+
* Global cache kill switch for task entries.
82+
*
83+
* When `false`, overrides all tasks to disable caching, even tasks with `cache: true`.
84+
* When `true`, respects each task's individual `cache` setting
85+
* (each task's `cache` defaults to `true` if omitted).
86+
*
87+
* Default: `true`
88+
*/
89+
tasks?: boolean, };
9390

94-
export type RunConfig = {
95-
/**
96-
* Root-level cache configuration.
97-
*
98-
* This option can only be set in the workspace root's config file.
99-
* Setting it in a package's config will result in an error.
100-
*/
101-
cache?: UserGlobalCacheConfig;
102-
/**
103-
* Task definitions
104-
*/
105-
tasks?: { [key in string]?: Task };
106-
/**
107-
* Whether to automatically run `preX`/`postX` package.json scripts as
108-
* lifecycle hooks when script `X` is executed.
109-
*
110-
* When `true` (the default), running script `test` will automatically
111-
* run `pretest` before and `posttest` after, if they exist.
112-
*
113-
* This option can only be set in the workspace root's config file.
114-
* Setting it in a package's config will result in an error.
115-
*/
116-
enablePrePostScripts?: boolean;
117-
};
91+
export type RunConfig = {
92+
/**
93+
* Root-level cache configuration.
94+
*
95+
* This option can only be set in the workspace root's config file.
96+
* Setting it in a package's config will result in an error.
97+
*/
98+
cache?: UserGlobalCacheConfig,
99+
/**
100+
* Task definitions
101+
*/
102+
tasks?: { [key in string]?: Task },
103+
/**
104+
* Whether to automatically run `preX`/`postX` package.json scripts as
105+
* lifecycle hooks when script `X` is executed.
106+
*
107+
* When `true` (the default), running script `test` will automatically
108+
* run `pretest` before and `posttest` after, if they exist.
109+
*
110+
* This option can only be set in the workspace root's config file.
111+
* Setting it in a package's config will result in an error.
112+
*/
113+
enablePrePostScripts?: boolean, };

crates/vite_task_graph/src/config/user.rs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,12 @@ impl UserRunConfig {
273273
pub const TS_TYPE: &str = include_str!("../../run-config.ts");
274274

275275
/// Generates TypeScript type definitions for user task configuration.
276-
///
277-
/// # Panics
278-
///
279-
/// Panics if `oxfmt` is not found in `packages/tools`, if the formatter process
280-
/// fails to spawn or write, or if the output is not valid UTF-8.
281276
#[cfg(all(test, not(clippy)))]
282277
#[must_use]
283278
// test code: uses std types for convenience
284279
#[expect(clippy::disallowed_types, reason = "test code uses std types for convenience")]
285280
pub fn generate_ts_definition() -> String {
286-
use std::{
287-
any::TypeId,
288-
collections::HashSet,
289-
io::Write,
290-
process::{Command, Stdio},
291-
};
281+
use std::{any::TypeId, collections::HashSet};
292282

293283
use ts_rs::TypeVisitor;
294284

@@ -335,32 +325,7 @@ impl UserRunConfig {
335325
types.push_str("\n\nexport ");
336326
types.push_str(&Self::decl());
337327

338-
// Format using oxfmt from packages/tools
339-
let workspace_root =
340-
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
341-
let tools_path = workspace_root.join("packages/tools/node_modules/.bin");
342-
343-
let oxfmt_path = which::which_in("oxfmt", Some(&tools_path), &tools_path)
344-
.expect("oxfmt not found in packages/tools");
345-
346-
let mut child = Command::new(oxfmt_path)
347-
.arg("--stdin-filepath=run-config.ts")
348-
.stdin(Stdio::piped())
349-
.stdout(Stdio::piped())
350-
.spawn()
351-
.expect("failed to spawn oxfmt");
352-
353-
child
354-
.stdin
355-
.take()
356-
.unwrap()
357-
.write_all(types.as_bytes())
358-
.expect("failed to write to oxfmt stdin");
359-
360-
let output = child.wait_with_output().expect("failed to read oxfmt output");
361-
assert!(output.status.success(), "oxfmt failed");
362-
363-
String::from_utf8(output.stdout).expect("oxfmt output is not valid UTF-8")
328+
types
364329
}
365330
}
366331

0 commit comments

Comments
 (0)