From baa3e11d57bc232c74b2d15dad01d403524efb6f Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 16:33:11 +0800 Subject: [PATCH 01/13] feat: config types --- crates/vite_task_graph/src/config/user.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 9f213eb5..2990922a 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -93,9 +93,12 @@ pub struct UserTaskConfig { /// User configuration file structure for `vite.config.*` #[derive(Debug, Deserialize)] pub struct UserConfigFile { - pub tasks: HashMap, + pub tasks: UserConfigTasks, } +/// Type of the `tasks` field in `vite.config.*` +pub type UserConfigTasks = HashMap; + #[cfg(test)] mod tests { use serde_json::json; From 45f59a02eb6b93d3ee3459308949def6d041c9fa Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 17:53:10 +0800 Subject: [PATCH 02/13] feat: add TypeScript type generation for task config Add ts-rs based TypeScript type generation for UserConfigTasks under a new 'ts-types' feature flag. This enables generating TypeScript definitions for the vite.config.json task configuration schema. - Add ts-rs dependency to workspace - Implement TS trait for Str and RelativePathBuf (map to 'string') - Add TS derives to all user config types with MustBe! overrides - Convert UserConfigTasks to newtype for TS derive support - Add 'config-types' CLI subcommand to print generated types Co-Authored-By: Claude Opus 4.5 --- Cargo.lock | 35 ++++++++++++++ Cargo.toml | 1 + crates/vite_path/Cargo.toml | 2 + crates/vite_path/src/relative.rs | 32 +++++++++++++ crates/vite_str/Cargo.toml | 4 ++ crates/vite_str/src/lib.rs | 32 +++++++++++++ crates/vite_task_bin/Cargo.toml | 4 ++ crates/vite_task_bin/src/lib.rs | 3 ++ crates/vite_task_bin/src/main.rs | 16 +++++++ crates/vite_task_graph/Cargo.toml | 4 ++ crates/vite_task_graph/src/config/user.rs | 57 ++++++++++++++++++++++- crates/vite_task_graph/src/lib.rs | 2 +- 12 files changed, 190 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e498ad7d..b165e473 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2803,6 +2803,15 @@ dependencies = [ "windows-sys 0.61.1", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "test-log" version = "0.2.18" @@ -3037,6 +3046,28 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "ts-rs" +version = "11.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4994acea2522cd2b3b85c1d9529a55991e3ad5e25cdcd3de9d505972c4379424" +dependencies = [ + "thiserror 2.0.17", + "ts-rs-macros", +] + +[[package]] +name = "ts-rs-macros" +version = "11.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6ff59666c9cbaec3533964505d39154dc4e0a56151fdea30a09ed0301f62e2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", + "termcolor", +] + [[package]] name = "tui-term" version = "0.2.0" @@ -3208,6 +3239,7 @@ dependencies = [ "ref-cast", "serde", "thiserror 2.0.17", + "ts-rs", "vite_str", ] @@ -3231,6 +3263,7 @@ dependencies = [ "compact_str 0.9.0", "diff-struct", "serde", + "ts-rs", ] [[package]] @@ -3285,6 +3318,7 @@ dependencies = [ "vite_path", "vite_str", "vite_task", + "vite_task_graph", "vite_workspace", "which", ] @@ -3302,6 +3336,7 @@ dependencies = [ "serde_json", "thiserror 2.0.17", "tokio", + "ts-rs", "vec1", "vite_graph_ser", "vite_path", diff --git a/Cargo.toml b/Cargo.toml index b928c23b..acf91716 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,6 +116,7 @@ toml = "0.9.5" tracing = "0.1.43" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "serde"] } +ts-rs = "11.1.0" tui-term = "0.2.0" twox-hash = "2.1.1" uuid = "1.18.1" diff --git a/crates/vite_path/Cargo.toml b/crates/vite_path/Cargo.toml index 5184a749..cc02e1ac 100644 --- a/crates/vite_path/Cargo.toml +++ b/crates/vite_path/Cargo.toml @@ -12,10 +12,12 @@ diff-struct = { workspace = true } ref-cast = { workspace = true } serde = { workspace = true, features = ["derive", "rc"] } thiserror = { workspace = true } +ts-rs = { workspace = true, optional = true } vite_str = { workspace = true } [features] absolute-redaction = [] +ts-types = ["dep:ts-rs", "vite_str/ts-types"] [lints] workspace = true diff --git a/crates/vite_path/src/relative.rs b/crates/vite_path/src/relative.rs index 87f2bc25..ccfed5c3 100644 --- a/crates/vite_path/src/relative.rs +++ b/crates/vite_path/src/relative.rs @@ -263,6 +263,38 @@ pub enum FromPathError { InvalidPathData(#[from] InvalidPathDataError), } +#[cfg(feature = "ts-types")] +mod ts_impl { + use ts_rs::TS; + + use super::RelativePathBuf; + + impl TS for RelativePathBuf { + type OptionInnerType = Self; + type WithoutGenerics = Self; + + fn name() -> String { + "string".to_owned() + } + + fn inline() -> String { + "string".to_owned() + } + + fn inline_flattened() -> String { + panic!("RelativePathBuf cannot be flattened") + } + + fn decl() -> String { + panic!("RelativePathBuf is a primitive type") + } + + fn decl_concrete() -> String { + panic!("RelativePathBuf is a primitive type") + } + } +} + #[cfg(test)] mod tests { diff --git a/crates/vite_str/Cargo.toml b/crates/vite_str/Cargo.toml index d8ef5583..84d4283c 100644 --- a/crates/vite_str/Cargo.toml +++ b/crates/vite_str/Cargo.toml @@ -11,6 +11,10 @@ bincode = { workspace = true } compact_str = { workspace = true, features = ["serde"] } diff-struct = { workspace = true } serde = { workspace = true, features = ["derive"] } +ts-rs = { workspace = true, optional = true } + +[features] +ts-types = ["dep:ts-rs"] [lints] workspace = true diff --git a/crates/vite_str/src/lib.rs b/crates/vite_str/src/lib.rs index 318c7b1d..16ce7eee 100644 --- a/crates/vite_str/src/lib.rs +++ b/crates/vite_str/src/lib.rs @@ -176,6 +176,38 @@ impl PartialEq for Str { } } +#[cfg(feature = "ts-types")] +mod ts_impl { + use ts_rs::TS; + + use super::Str; + + impl TS for Str { + type OptionInnerType = Self; + type WithoutGenerics = Self; + + fn name() -> String { + "string".to_owned() + } + + fn inline() -> String { + "string".to_owned() + } + + fn inline_flattened() -> String { + panic!("Str cannot be flattened") + } + + fn decl() -> String { + panic!("Str is a primitive type") + } + + fn decl_concrete() -> String { + panic!("Str is a primitive type") + } + } +} + #[cfg(test)] mod tests { use bincode::{config::standard, decode_from_slice, encode_to_vec}; diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index 59d984dd..fe0c8c96 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -19,8 +19,12 @@ tokio = { workspace = true, features = ["full"] } vite_path = { workspace = true } vite_str = { workspace = true } vite_task = { workspace = true } +vite_task_graph = { workspace = true, optional = true } which = { workspace = true } +[features] +ts-types = ["dep:vite_task_graph", "vite_task_graph/ts-types"] + [dev-dependencies] copy_dir = { workspace = true } cow-utils = { workspace = true } diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs index 7921136a..8572515f 100644 --- a/crates/vite_task_bin/src/lib.rs +++ b/crates/vite_task_bin/src/lib.rs @@ -44,6 +44,9 @@ pub enum CustomTaskSubcommand { #[derive(Debug, Subcommand)] pub enum NonTaskSubcommand { Version, + /// Print the generated TypeScript type definitions for the config file schema. + /// This is useful for debugging the ts-rs type generation. + ConfigTypes, } #[derive(Debug, Default)] diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index 43dc2a78..6580d2a8 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -30,6 +30,22 @@ async fn run() -> anyhow::Result { println!("{}", env!("CARGO_PKG_VERSION")); return Ok(ExitStatus::SUCCESS); } + CLIArgs::NonTask(NonTaskSubcommand::ConfigTypes) => { + #[cfg(feature = "ts-types")] + { + println!( + "{}", + vite_task_graph::config::user::UserConfigTasks::typescript_definition() + ); + return Ok(ExitStatus::SUCCESS); + } + #[cfg(not(feature = "ts-types"))] + { + eprintln!("TypeScript type generation requires the 'ts-types' feature."); + eprintln!("Rebuild with: cargo build --features ts-types"); + return Ok(ExitStatus::FAILURE); + } + } }; let mut owned_callbacks = OwnedSessionCallbacks::default(); diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 80ef4955..6a10f5f9 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -16,12 +16,16 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs"] } +ts-rs = { workspace = true, optional = true } vec1 = { workspace = true, features = ["smallvec-v1"] } vite_graph_ser = { workspace = true } vite_path = { workspace = true } vite_str = { workspace = true } vite_workspace = { workspace = true } +[features] +ts-types = ["dep:ts-rs", "vite_str/ts-types", "vite_path/ts-types"] + [dev-dependencies] tokio = { workspace = true, features = ["fs", "rt-multi-thread"] } diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 2990922a..bf567f79 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -4,17 +4,21 @@ use std::{collections::HashMap, sync::Arc}; use monostate::MustBe; use serde::Deserialize; +#[cfg(feature = "ts-types")] +use ts_rs::TS; use vite_path::RelativePathBuf; use vite_str::Str; /// Cache-related fields of a task defined by user in `vite.config.*` #[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "ts-types", derive(TS))] #[serde(untagged, deny_unknown_fields, rename_all = "camelCase")] pub enum UserCacheConfig { /// Cache is enabled Enabled { /// The `cache` field must be true or omitted #[serde(default)] + #[cfg_attr(feature = "ts-types", ts(type = "true"))] cache: MustBe!(true), #[serde(flatten)] @@ -23,12 +27,14 @@ pub enum UserCacheConfig { /// Cache is disabled Disabled { /// The `cache` field must be false + #[cfg_attr(feature = "ts-types", ts(type = "false"))] cache: MustBe!(false), }, } /// Cache configuration fields when caching is enabled #[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "ts-types", derive(TS))] #[serde(rename_all = "camelCase")] pub struct EnabledCacheConfig { /// Environment variable names to be fingerprinted and passed to the task. @@ -42,6 +48,7 @@ pub struct EnabledCacheConfig { /// Options for user-defined tasks in `vite.config.*`, excluding the command. #[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "ts-types", derive(TS))] #[serde(rename_all = "camelCase")] pub struct UserTaskOptions { /// The working directory for the task, relative to the package root (not workspace root). @@ -80,6 +87,7 @@ impl Default for UserTaskOptions { /// Full user-defined task configuration in `vite.config.*`, including the command and options. #[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(feature = "ts-types", derive(TS))] #[serde(rename_all = "camelCase")] pub struct UserTaskConfig { /// If None, the script from `package.json` with the same name will be used @@ -97,7 +105,54 @@ pub struct UserConfigFile { } /// Type of the `tasks` field in `vite.config.*` -pub type UserConfigTasks = HashMap; +#[derive(Debug, Default, Deserialize)] +#[serde(transparent)] +#[cfg_attr(feature = "ts-types", derive(TS))] +pub struct UserConfigTasks(pub HashMap); + +#[cfg(feature = "ts-types")] +impl UserConfigTasks { + /// Returns the TypeScript type definitions for user task configuration. + pub fn typescript_definition() -> String { + use ts_rs::TypeVisitor; + + struct DeclCollector(Vec); + + impl TypeVisitor for DeclCollector { + fn visit(&mut self) { + // Only collect declarations from types that are exportable + // (i.e., have an output path - built-in types like HashMap don't) + if T::output_path().is_some() { + self.0.push(T::decl()); + } + } + } + + let mut collector = DeclCollector(Vec::new()); + Self::visit_dependencies(&mut collector); + collector.0.push(Self::decl()); + collector.0.join("\n\n") + } +} + +#[cfg(all(test, feature = "ts-types"))] +mod ts_tests { + use super::*; + + #[test] + fn test_typescript_generation() { + let ts = UserConfigTasks::typescript_definition(); + eprintln!("Generated TypeScript:\n{ts}"); + // Check for key type definitions + assert!(ts.contains("type UserTaskConfig"), "Missing UserTaskConfig in:\n{ts}"); + assert!(ts.contains("type UserConfigTasks"), "Missing UserConfigTasks in:\n{ts}"); + // Check for key fields (flattened types are inlined) + assert!(ts.contains("cache: true"), "Missing cache: true in:\n{ts}"); + assert!(ts.contains("cache: false"), "Missing cache: false in:\n{ts}"); + assert!(ts.contains("cwd:"), "Missing cwd field in:\n{ts}"); + assert!(ts.contains("dependsOn:"), "Missing dependsOn field in:\n{ts}"); + } +} #[cfg(test)] mod tests { diff --git a/crates/vite_task_graph/src/lib.rs b/crates/vite_task_graph/src/lib.rs index a71b8beb..de1450b3 100644 --- a/crates/vite_task_graph/src/lib.rs +++ b/crates/vite_task_graph/src/lib.rs @@ -217,7 +217,7 @@ impl IndexedTaskGraph { TaskGraphLoadError::ConfigLoadError { error, package_path: package_dir.clone() } })?; - for (task_name, task_user_config) in user_config.tasks { + for (task_name, task_user_config) in user_config.tasks.0 { // For each task defined in vite.config.*, look up the corresponding package.json script (if any) let package_json_script = package_json_scripts.remove(task_name.as_str()); From 40c7a12294582289368b8f54aae28958d74fab02 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 18:08:39 +0800 Subject: [PATCH 03/13] update --- Cargo.lock | 749 +++++++++++++++++++++- Cargo.toml | 2 +- crates/vite_path/Cargo.toml | 3 +- crates/vite_path/src/relative.rs | 1 - crates/vite_str/Cargo.toml | 5 +- crates/vite_str/src/lib.rs | 1 - crates/vite_task_bin/Cargo.toml | 5 +- crates/vite_task_bin/src/main.rs | 16 +- crates/vite_task_graph/Cargo.toml | 6 +- crates/vite_task_graph/src/config/user.rs | 39 +- 10 files changed, 778 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b165e473..52e5b985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,6 +106,15 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +[[package]] +name = "ar_archive_writer" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c269894b6fe5e9d7ada0cf69b5bf847ff35bc25fc271f08e1d080fce80339a" +dependencies = [ + "object 0.32.2", +] + [[package]] name = "arrayvec" version = "0.7.6" @@ -141,6 +150,17 @@ version = "9.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59051ec02907378a67b0ba1b8631121f5388c8dbbb3cec8c749d8f93c2c3c211" +[[package]] +name = "ast_node" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a184645bcc6f52d69d8e7639720699c6a99efb711f886e251ed1d16db8dd90e" +dependencies = [ + "quote", + "swc_macros_common", + "syn 2.0.106", +] + [[package]] name = "async-trait" version = "0.1.89" @@ -168,7 +188,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.37.3", "rustc-demangle", "windows-link", ] @@ -179,6 +199,15 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "better_scoped_tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd228125315b132eed175bf47619ac79b945b26e56b848ba203ae4ea8603609" +dependencies = [ + "scoped-tls", +] + [[package]] name = "bincode" version = "2.0.1" @@ -327,6 +356,16 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +[[package]] +name = "bytes-str" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c60b5ce37e0b883c37eb89f79a1e26fbe9c1081945d024eee93e8d91a7e18b3" +dependencies = [ + "bytes", + "serde", +] + [[package]] name = "cached" version = "0.56.0" @@ -360,6 +399,26 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" +[[package]] +name = "capacity_builder" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f2d24a6dcf0cd402a21b65d35340f3a49ff3475dc5fdac91d22d2733e6641c6" +dependencies = [ + "capacity_builder_macros", + "itoa", +] + +[[package]] +name = "capacity_builder_macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b4a6cae9efc04cc6cbb8faf338d2c497c165c83e74509cf4dbedea948bbf6e5" +dependencies = [ + "quote", + "syn 2.0.106", +] + [[package]] name = "cassowary" version = "0.3.0" @@ -796,6 +855,79 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + +[[package]] +name = "deno_ast" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c72e0409b3dbd60a5bf296cbc273a8e36bb3a3aab6abac389f1891e187d5ce14" +dependencies = [ + "capacity_builder", + "deno_error", + "deno_media_type", + "deno_terminal", + "dprint-swc-ext", + "percent-encoding", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_lexer", + "swc_ecma_parser", + "swc_eq_ignore_macros", + "text_lines", + "thiserror 2.0.17", + "unicode-width 0.2.0", + "url", +] + +[[package]] +name = "deno_error" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3007d3f1ea92ea503324ae15883aac0c2de2b8cf6fead62203ff6a67161007ab" +dependencies = [ + "deno_error_macro", + "libc", +] + +[[package]] +name = "deno_error_macro" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b565e60a9685cdf312c888665b5f8647ac692a7da7e058a5e2268a466da8eaf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "deno_media_type" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd0af4161f90b092feb363864a64d7c74e0efc13a15905d0d09df73bb72a123" +dependencies = [ + "data-url", + "serde", + "url", +] + +[[package]] +name = "deno_terminal" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ba8041ae7319b3ca6a64c399df4112badcbbe0868b4517637647614bede4be" +dependencies = [ + "once_cell", + "termcolor", +] + [[package]] name = "derive_more" version = "2.0.1" @@ -877,6 +1009,17 @@ dependencies = [ "windows-sys 0.61.1", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "document-features" version = "0.2.11" @@ -892,6 +1035,65 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" +[[package]] +name = "dprint-core" +version = "0.67.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1d827947704a9495f705d6aeed270fa21a67f825f22902c28f38dc3af7a9ae" +dependencies = [ + "anyhow", + "bumpalo", + "hashbrown 0.15.5", + "indexmap", + "rustc-hash", + "serde", + "unicode-width 0.2.0", +] + +[[package]] +name = "dprint-core-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1675ad2b358481f3cc46202040d64ac7a36c4ade414a696df32e0e45421a6e9f" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dprint-plugin-typescript" +version = "0.95.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed62468ffd2bc0a759497022c7e20ec08f15d74057ad17c0bfa5b3ca657e8c8d" +dependencies = [ + "anyhow", + "capacity_builder", + "deno_ast", + "dprint-core", + "dprint-core-macros", + "percent-encoding", + "rustc-hash", + "serde", +] + +[[package]] +name = "dprint-swc-ext" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf592ae6a864437e98ef9c6ae7936b822077e9d038a3a48ee081ab92313afad4" +dependencies = [ + "allocator-api2", + "bumpalo", + "num-bigint", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_lexer", + "swc_ecma_parser", + "text_lines", +] + [[package]] name = "dtor" version = "0.1.0" @@ -1053,6 +1255,25 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "from_variant" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308530a56b099da144ebc5d8e179f343ad928fa2b3558d1eb3db9af18d6eff43" +dependencies = [ + "swc_macros_common", + "syn 2.0.106", +] + [[package]] name = "fspy" version = "0.1.0" @@ -1358,6 +1579,16 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "hashbrown" version = "0.15.5" @@ -1396,12 +1627,127 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hstr" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f11d91d7befd2ffd9d216e9e5ea1fae6174b20a2a1b67a688138003d2f4122" +dependencies = [ + "hashbrown 0.14.5", + "new_debug_unreachable", + "once_cell", + "rustc-hash", + "triomphe", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec 1.15.1", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec 1.15.1", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "indenter" version = "0.3.4" @@ -1416,6 +1762,8 @@ checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", "hashbrown 0.16.1", + "serde", + "serde_core", ] [[package]] @@ -1456,6 +1804,18 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "is-macro" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "is_ci" version = "1.2.0" @@ -1583,6 +1943,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + [[package]] name = "litrs" version = "0.4.2" @@ -1705,6 +2071,12 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nix" version = "0.23.2" @@ -1793,6 +2165,7 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", + "serde", ] [[package]] @@ -1844,6 +2217,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + [[package]] name = "object" version = "0.37.3" @@ -1976,6 +2358,12 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "132dca9b868d927b35b5dd728167b2dee150eb1ad686008fc71ccb298b776fca" +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + [[package]] name = "pest" version = "2.8.4" @@ -2071,7 +2459,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "siphasher", + "siphasher 1.0.1", ] [[package]] @@ -2122,6 +2510,15 @@ dependencies = [ "winreg", ] +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -2163,6 +2560,16 @@ dependencies = [ "yansi", ] +[[package]] +name = "psm" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11f2fedc3b7dafdc2851bc52f277377c5473d378859be234bc7ebb593144d01" +dependencies = [ + "ar_archive_writer", + "cc", +] + [[package]] name = "quote" version = "1.0.41" @@ -2452,6 +2859,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -2487,6 +2900,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "seq-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" + [[package]] name = "serde" version = "1.0.228" @@ -2664,6 +3083,12 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "siphasher" version = "1.0.1" @@ -2688,6 +3113,17 @@ version = "2.0.0-alpha.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef784004ca8777809dcdad6ac37629f0a97caee4c685fcea805278d81dd8b857" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + [[package]] name = "socket2" version = "0.6.0" @@ -2698,6 +3134,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "stackalloc" version = "1.2.1" @@ -2708,12 +3150,37 @@ dependencies = [ "rustc_version 0.2.3", ] +[[package]] +name = "stacker" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1f8b29fb42aafcea4edeeb6b2f2d7ecd0d969c48b4cf0d2e64aafc471dd6e59" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.52.0", + "windows-sys 0.59.0", +] + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "string_enum" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae36a4951ca7bd1cfd991c241584a9824a70f6aff1e7d4f693fb3f2465e4030e" +dependencies = [ + "quote", + "swc_macros_common", + "syn 2.0.106", +] + [[package]] name = "strsim" version = "0.11.1" @@ -2751,6 +3218,134 @@ dependencies = [ "is_ci", ] +[[package]] +name = "swc_atoms" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3500dcf04c84606b38464561edc5e46f5132201cb3e23cf9613ed4033d6b1bb2" +dependencies = [ + "hstr", + "once_cell", + "serde", +] + +[[package]] +name = "swc_common" +version = "14.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2bb772b3a26b8b71d4e8c112ced5b5867be2266364b58517407a270328a2696" +dependencies = [ + "anyhow", + "ast_node", + "better_scoped_tls", + "bytes-str", + "either", + "from_variant", + "new_debug_unreachable", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "siphasher 0.3.11", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_visit", + "tracing", + "unicode-width 0.1.14", + "url", +] + +[[package]] +name = "swc_ecma_ast" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c25af97d53cf8aab66a6c68f3418663313fc969ad267fc2a4d19402c329be1" +dependencies = [ + "bitflags 2.10.0", + "is-macro", + "num-bigint", + "once_cell", + "phf", + "rustc-hash", + "serde", + "string_enum", + "swc_atoms", + "swc_common", + "swc_visit", + "unicode-id-start", +] + +[[package]] +name = "swc_ecma_lexer" +version = "23.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "017d06ea85008234aa9fb34d805c7dc563f2ea6e03869ed5ac5a2dc27d561e4d" +dependencies = [ + "arrayvec", + "bitflags 2.10.0", + "either", + "num-bigint", + "phf", + "rustc-hash", + "seq-macro", + "serde", + "smallvec 1.15.1", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", +] + +[[package]] +name = "swc_ecma_parser" +version = "24.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9011783c975ba592ffc09cd208ced92b1dfabb2e5e0ef453559e2e25286127" +dependencies = [ + "either", + "num-bigint", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_lexer", + "tracing", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c16ce73424a6316e95e09065ba6a207eba7765496fed113702278b7711d4b632" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "swc_macros_common" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1efbaa74943dc5ad2a2fb16cbd78b77d7e4d63188f3c5b4df2b4dcd2faaae" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "swc_visit" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62fb71484b486c185e34d2172f0eabe7f4722742aad700f426a494bb2de232a2" +dependencies = [ + "either", + "new_debug_unreachable", +] + [[package]] name = "syn" version = "1.0.109" @@ -2773,6 +3368,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "syscalls" version = "0.6.18" @@ -2834,6 +3440,15 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "text_lines" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd5828de7deaa782e1dd713006ae96b3bee32d3279b79eb67ecf8072c059bcf" +dependencies = [ + "serde", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -2883,6 +3498,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tokio" version = "1.48.0" @@ -3046,12 +3671,23 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "triomphe" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd69c5aa8f924c7519d6372789a74eac5b94fb0f8fcf0d4a97eb0bfc3e785f39" +dependencies = [ + "serde", + "stable_deref_trait", +] + [[package]] name = "ts-rs" version = "11.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4994acea2522cd2b3b85c1d9529a55991e3ad5e25cdcd3de9d505972c4379424" dependencies = [ + "dprint-plugin-typescript", "thiserror 2.0.17", "ts-rs-macros", ] @@ -3105,6 +3741,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +[[package]] +name = "unicode-id-start" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b79ad29b5e19de4260020f8919b443b2ef0277d242ce532ec7b7a2cc8b6007" + [[package]] name = "unicode-ident" version = "1.0.19" @@ -3152,6 +3794,19 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", +] + [[package]] name = "utf8-chars" version = "3.0.6" @@ -3161,6 +3816,12 @@ dependencies = [ "arrayvec", ] +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -3330,6 +3991,7 @@ dependencies = [ "anyhow", "async-trait", "clap", + "dprint-plugin-typescript", "monostate", "petgraph", "serde", @@ -3871,6 +4533,12 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + [[package]] name = "xattr" version = "1.6.1" @@ -3893,6 +4561,29 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.8.27" @@ -3912,3 +4603,57 @@ dependencies = [ "quote", "syn 2.0.106", ] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] diff --git a/Cargo.toml b/Cargo.toml index acf91716..bd4d6cfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ toml = "0.9.5" tracing = "0.1.43" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "serde"] } -ts-rs = "11.1.0" +ts-rs = { version = "11.1.0", features = ["format"] } tui-term = "0.2.0" twox-hash = "2.1.1" uuid = "1.18.1" diff --git a/crates/vite_path/Cargo.toml b/crates/vite_path/Cargo.toml index cc02e1ac..2b559951 100644 --- a/crates/vite_path/Cargo.toml +++ b/crates/vite_path/Cargo.toml @@ -12,12 +12,11 @@ diff-struct = { workspace = true } ref-cast = { workspace = true } serde = { workspace = true, features = ["derive", "rc"] } thiserror = { workspace = true } -ts-rs = { workspace = true, optional = true } +ts-rs = { workspace = true } vite_str = { workspace = true } [features] absolute-redaction = [] -ts-types = ["dep:ts-rs", "vite_str/ts-types"] [lints] workspace = true diff --git a/crates/vite_path/src/relative.rs b/crates/vite_path/src/relative.rs index ccfed5c3..e6a9053b 100644 --- a/crates/vite_path/src/relative.rs +++ b/crates/vite_path/src/relative.rs @@ -263,7 +263,6 @@ pub enum FromPathError { InvalidPathData(#[from] InvalidPathDataError), } -#[cfg(feature = "ts-types")] mod ts_impl { use ts_rs::TS; diff --git a/crates/vite_str/Cargo.toml b/crates/vite_str/Cargo.toml index 84d4283c..735e8229 100644 --- a/crates/vite_str/Cargo.toml +++ b/crates/vite_str/Cargo.toml @@ -11,10 +11,7 @@ bincode = { workspace = true } compact_str = { workspace = true, features = ["serde"] } diff-struct = { workspace = true } serde = { workspace = true, features = ["derive"] } -ts-rs = { workspace = true, optional = true } - -[features] -ts-types = ["dep:ts-rs"] +ts-rs = { workspace = true } [lints] workspace = true diff --git a/crates/vite_str/src/lib.rs b/crates/vite_str/src/lib.rs index 16ce7eee..1f9c941a 100644 --- a/crates/vite_str/src/lib.rs +++ b/crates/vite_str/src/lib.rs @@ -176,7 +176,6 @@ impl PartialEq for Str { } } -#[cfg(feature = "ts-types")] mod ts_impl { use ts_rs::TS; diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index fe0c8c96..2c14381d 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -19,12 +19,9 @@ tokio = { workspace = true, features = ["full"] } vite_path = { workspace = true } vite_str = { workspace = true } vite_task = { workspace = true } -vite_task_graph = { workspace = true, optional = true } +vite_task_graph = { workspace = true } which = { workspace = true } -[features] -ts-types = ["dep:vite_task_graph", "vite_task_graph/ts-types"] - [dev-dependencies] copy_dir = { workspace = true } cow-utils = { workspace = true } diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index 6580d2a8..f691b46a 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -31,20 +31,8 @@ async fn run() -> anyhow::Result { return Ok(ExitStatus::SUCCESS); } CLIArgs::NonTask(NonTaskSubcommand::ConfigTypes) => { - #[cfg(feature = "ts-types")] - { - println!( - "{}", - vite_task_graph::config::user::UserConfigTasks::typescript_definition() - ); - return Ok(ExitStatus::SUCCESS); - } - #[cfg(not(feature = "ts-types"))] - { - eprintln!("TypeScript type generation requires the 'ts-types' feature."); - eprintln!("Rebuild with: cargo build --features ts-types"); - return Ok(ExitStatus::FAILURE); - } + println!("{}", vite_task_graph::config::user::UserConfigTasks::typescript_definition()); + return Ok(ExitStatus::SUCCESS); } }; diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 6a10f5f9..6b3ec197 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -10,22 +10,20 @@ rust-version.workspace = true anyhow = { workspace = true } async-trait = { workspace = true } clap = { workspace = true, features = ["derive"] } +dprint-plugin-typescript = "0.95" monostate = { workspace = true } petgraph = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs"] } -ts-rs = { workspace = true, optional = true } +ts-rs = { workspace = true } vec1 = { workspace = true, features = ["smallvec-v1"] } vite_graph_ser = { workspace = true } vite_path = { workspace = true } vite_str = { workspace = true } vite_workspace = { workspace = true } -[features] -ts-types = ["dep:ts-rs", "vite_str/ts-types", "vite_path/ts-types"] - [dev-dependencies] tokio = { workspace = true, features = ["fs", "rt-multi-thread"] } diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index bf567f79..101a0669 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -4,21 +4,19 @@ use std::{collections::HashMap, sync::Arc}; use monostate::MustBe; use serde::Deserialize; -#[cfg(feature = "ts-types")] use ts_rs::TS; use vite_path::RelativePathBuf; use vite_str::Str; /// Cache-related fields of a task defined by user in `vite.config.*` -#[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(feature = "ts-types", derive(TS))] +#[derive(Debug, Deserialize, PartialEq, Eq, TS)] #[serde(untagged, deny_unknown_fields, rename_all = "camelCase")] pub enum UserCacheConfig { /// Cache is enabled Enabled { /// The `cache` field must be true or omitted #[serde(default)] - #[cfg_attr(feature = "ts-types", ts(type = "true"))] + #[ts(type = "true")] cache: MustBe!(true), #[serde(flatten)] @@ -27,14 +25,13 @@ pub enum UserCacheConfig { /// Cache is disabled Disabled { /// The `cache` field must be false - #[cfg_attr(feature = "ts-types", ts(type = "false"))] + #[ts(type = "false")] cache: MustBe!(false), }, } /// Cache configuration fields when caching is enabled -#[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(feature = "ts-types", derive(TS))] +#[derive(Debug, Deserialize, PartialEq, Eq, TS)] #[serde(rename_all = "camelCase")] pub struct EnabledCacheConfig { /// Environment variable names to be fingerprinted and passed to the task. @@ -47,8 +44,7 @@ pub struct EnabledCacheConfig { } /// Options for user-defined tasks in `vite.config.*`, excluding the command. -#[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(feature = "ts-types", derive(TS))] +#[derive(Debug, Deserialize, PartialEq, Eq, TS)] #[serde(rename_all = "camelCase")] pub struct UserTaskOptions { /// The working directory for the task, relative to the package root (not workspace root). @@ -86,8 +82,7 @@ impl Default for UserTaskOptions { } /// Full user-defined task configuration in `vite.config.*`, including the command and options. -#[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(feature = "ts-types", derive(TS))] +#[derive(Debug, Deserialize, PartialEq, Eq, TS)] #[serde(rename_all = "camelCase")] pub struct UserTaskConfig { /// If None, the script from `package.json` with the same name will be used @@ -105,15 +100,16 @@ pub struct UserConfigFile { } /// Type of the `tasks` field in `vite.config.*` -#[derive(Debug, Default, Deserialize)] +#[derive(Debug, Default, Deserialize, TS)] #[serde(transparent)] -#[cfg_attr(feature = "ts-types", derive(TS))] pub struct UserConfigTasks(pub HashMap); -#[cfg(feature = "ts-types")] impl UserConfigTasks { /// Returns the TypeScript type definitions for user task configuration. pub fn typescript_definition() -> String { + use dprint_plugin_typescript::{ + FormatTextOptions, configuration::ConfigurationBuilder, format_text, + }; use ts_rs::TypeVisitor; struct DeclCollector(Vec); @@ -131,11 +127,22 @@ impl UserConfigTasks { let mut collector = DeclCollector(Vec::new()); Self::visit_dependencies(&mut collector); collector.0.push(Self::decl()); - collector.0.join("\n\n") + let unformatted = collector.0.join("\n\n"); + + // Format with dprint + let fmt_cfg = ConfigurationBuilder::new().deno().build(); + let options = FormatTextOptions { + config: &fmt_cfg, + path: std::path::Path::new("user_config.d.ts"), + text: unformatted.clone(), + extension: None, + external_formatter: None, + }; + format_text(options).ok().flatten().unwrap_or(unformatted) } } -#[cfg(all(test, feature = "ts-types"))] +#[cfg(test)] mod ts_tests { use super::*; From 6e04d44c49dbc53f391ff9170f80784a1a981139 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 18:41:44 +0800 Subject: [PATCH 04/13] update --- Cargo.lock | 13 ++++- crates/vite_task_bin/src/lib.rs | 3 - crates/vite_task_bin/src/main.rs | 4 -- crates/vite_task_graph/Cargo.toml | 4 +- crates/vite_task_graph/src/config/user.rs | 67 ++++++++++++++--------- crates/vite_task_graph/task-config.ts | 38 +++++++++++++ 6 files changed, 95 insertions(+), 34 deletions(-) create mode 100644 crates/vite_task_graph/task-config.ts diff --git a/Cargo.lock b/Cargo.lock index 52e5b985..098c9a39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2528,6 +2528,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "prettyplease" version = "0.2.37" @@ -3160,7 +3170,6 @@ dependencies = [ "cfg-if", "libc", "psm", - "windows-sys 0.52.0", "windows-sys 0.59.0", ] @@ -3994,8 +4003,10 @@ dependencies = [ "dprint-plugin-typescript", "monostate", "petgraph", + "pretty_assertions", "serde", "serde_json", + "tempfile", "thiserror 2.0.17", "tokio", "ts-rs", diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs index 8572515f..7921136a 100644 --- a/crates/vite_task_bin/src/lib.rs +++ b/crates/vite_task_bin/src/lib.rs @@ -44,9 +44,6 @@ pub enum CustomTaskSubcommand { #[derive(Debug, Subcommand)] pub enum NonTaskSubcommand { Version, - /// Print the generated TypeScript type definitions for the config file schema. - /// This is useful for debugging the ts-rs type generation. - ConfigTypes, } #[derive(Debug, Default)] diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index f691b46a..43dc2a78 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -30,10 +30,6 @@ async fn run() -> anyhow::Result { println!("{}", env!("CARGO_PKG_VERSION")); return Ok(ExitStatus::SUCCESS); } - CLIArgs::NonTask(NonTaskSubcommand::ConfigTypes) => { - println!("{}", vite_task_graph::config::user::UserConfigTasks::typescript_definition()); - return Ok(ExitStatus::SUCCESS); - } }; let mut owned_callbacks = OwnedSessionCallbacks::default(); diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 6b3ec197..0a0326f1 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -17,7 +17,7 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs"] } -ts-rs = { workspace = true } +ts-rs = { workspace = true, features = ["format"] } vec1 = { workspace = true, features = ["smallvec-v1"] } vite_graph_ser = { workspace = true } vite_path = { workspace = true } @@ -25,6 +25,8 @@ vite_str = { workspace = true } vite_workspace = { workspace = true } [dev-dependencies] +pretty_assertions = "1.4.1" +tempfile = { workspace = true } tokio = { workspace = true, features = ["fs", "rt-multi-thread"] } [lints] diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 101a0669..104bb771 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -14,7 +14,7 @@ use vite_str::Str; pub enum UserCacheConfig { /// Cache is enabled Enabled { - /// The `cache` field must be true or omitted + /// Whether to cache the task #[serde(default)] #[ts(type = "true")] cache: MustBe!(true), @@ -24,7 +24,7 @@ pub enum UserCacheConfig { }, /// Cache is disabled Disabled { - /// The `cache` field must be false + /// Whether to cache the task #[ts(type = "false")] cache: MustBe!(false), }, @@ -52,7 +52,7 @@ pub struct UserTaskOptions { #[serde(rename = "cwd")] pub cwd_relative_to_package: RelativePathBuf, - /// Explicit dependencies of this task. + /// Dependencies of this task. Use `package-name#task-name` to refer to tasks in other packages. #[serde(default)] // default to empty if omitted pub depends_on: Arc<[Str]>, @@ -84,8 +84,11 @@ impl Default for UserTaskOptions { /// Full user-defined task configuration in `vite.config.*`, including the command and options. #[derive(Debug, Deserialize, PartialEq, Eq, TS)] #[serde(rename_all = "camelCase")] +#[ts(rename = "Task")] pub struct UserTaskConfig { - /// If None, the script from `package.json` with the same name will be used + /// The command to run for the task. + /// + /// If omitted, the script from `package.json` with the same name will be used pub command: Option>, /// Fields other than the command @@ -102,11 +105,16 @@ pub struct UserConfigFile { /// Type of the `tasks` field in `vite.config.*` #[derive(Debug, Default, Deserialize, TS)] #[serde(transparent)] +#[ts(rename = "Tasks")] pub struct UserConfigTasks(pub HashMap); impl UserConfigTasks { - /// Returns the TypeScript type definitions for user task configuration. - pub fn typescript_definition() -> String { + /// TypeScript type definitions for user task configuration. + pub const TS_TYPE: &str = include_str!("../../task-config.ts"); + + /// Generates TypeScript type definitions for user task configuration. + #[cfg(test)] + pub fn generate_ts_definition() -> String { use dprint_plugin_typescript::{ FormatTextOptions, configuration::ConfigurationBuilder, format_text, }; @@ -126,38 +134,47 @@ impl UserConfigTasks { let mut collector = DeclCollector(Vec::new()); Self::visit_dependencies(&mut collector); - collector.0.push(Self::decl()); - let unformatted = collector.0.join("\n\n"); + let mut types = collector.0.join("\n\n"); + + // Export the main type + types.push_str("\n\nexport "); + types.push_str(&Self::decl()); - // Format with dprint - let fmt_cfg = ConfigurationBuilder::new().deno().build(); + // Format + let fmt_cfg = ConfigurationBuilder::new().build(); let options = FormatTextOptions { config: &fmt_cfg, - path: std::path::Path::new("user_config.d.ts"), - text: unformatted.clone(), + path: std::path::Path::new("task-config.ts"), + text: types.clone(), extension: None, external_formatter: None, }; - format_text(options).ok().flatten().unwrap_or(unformatted) + format_text(options).unwrap().unwrap() } } #[cfg(test)] mod ts_tests { - use super::*; + use std::{env, path::PathBuf}; + + use super::UserConfigTasks; #[test] - fn test_typescript_generation() { - let ts = UserConfigTasks::typescript_definition(); - eprintln!("Generated TypeScript:\n{ts}"); - // Check for key type definitions - assert!(ts.contains("type UserTaskConfig"), "Missing UserTaskConfig in:\n{ts}"); - assert!(ts.contains("type UserConfigTasks"), "Missing UserConfigTasks in:\n{ts}"); - // Check for key fields (flattened types are inlined) - assert!(ts.contains("cache: true"), "Missing cache: true in:\n{ts}"); - assert!(ts.contains("cache: false"), "Missing cache: false in:\n{ts}"); - assert!(ts.contains("cwd:"), "Missing cwd field in:\n{ts}"); - assert!(ts.contains("dependsOn:"), "Missing dependsOn field in:\n{ts}"); + fn typescript_generation() { + let file_path = + PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("task-config.ts"); + let ts = UserConfigTasks::generate_ts_definition(); + + if env::var("VT_UPDATE_TS_TYPES").unwrap_or_default() == "1" { + std::fs::write(&file_path, ts).unwrap(); + } else { + let existing_ts = std::fs::read_to_string(&file_path).unwrap_or_default(); + pretty_assertions::assert_eq!( + ts, + existing_ts, + "Generated TypeScript types do not match the existing ones. If you made changes to the types, please set VT_UPDATE_TS_TYPES=1 and run the tests again to update the TypeScript definitions." + ); + } } } diff --git a/crates/vite_task_graph/task-config.ts b/crates/vite_task_graph/task-config.ts new file mode 100644 index 00000000..75f0b9ed --- /dev/null +++ b/crates/vite_task_graph/task-config.ts @@ -0,0 +1,38 @@ +type Task = + & { + /** + * The command to run for the task. + * + * If omitted, the script from `package.json` with the same name will be used + */ + command: string | null; + /** + * The working directory for the task, relative to the package root (not workspace root). + */ + cwd: string; + /** + * Dependencies of this task. Use `package-name#task-name` to refer to tasks in other packages. + */ + dependsOn: Array; + } + & ({ + /** + * Whether to cache the task + */ + cache: true; + /** + * Environment variable names to be fingerprinted and passed to the task. + */ + envs: Array; + /** + * Environment variable names to be passed to the task without fingerprinting. + */ + passThroughEnvs: Array; + } | { + /** + * Whether to cache the task + */ + cache: false; + }); + +export type Tasks = { [key in string]?: Task }; From de26de668873e45cb9d23079300235f8586d59bc Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 18:49:03 +0800 Subject: [PATCH 05/13] feat: make ts-rs optional in vite_path/vite_str, dev-only in vite_task_graph Move TypeScript type generation support behind feature flags to reduce compile-time dependencies for production builds. The ts-rs dependency is now only needed when running tests. Co-Authored-By: Claude Opus 4.5 --- crates/vite_path/Cargo.toml | 3 ++- crates/vite_path/src/relative.rs | 1 + crates/vite_str/Cargo.toml | 5 ++++- crates/vite_str/src/lib.rs | 1 + crates/vite_task_graph/Cargo.toml | 4 +++- crates/vite_task_graph/src/config/user.rs | 24 ++++++++++++++--------- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/crates/vite_path/Cargo.toml b/crates/vite_path/Cargo.toml index 2b559951..207f05e0 100644 --- a/crates/vite_path/Cargo.toml +++ b/crates/vite_path/Cargo.toml @@ -12,11 +12,12 @@ diff-struct = { workspace = true } ref-cast = { workspace = true } serde = { workspace = true, features = ["derive", "rc"] } thiserror = { workspace = true } -ts-rs = { workspace = true } +ts-rs = { workspace = true, optional = true } vite_str = { workspace = true } [features] absolute-redaction = [] +ts-rs = ["dep:ts-rs", "vite_str/ts-rs"] [lints] workspace = true diff --git a/crates/vite_path/src/relative.rs b/crates/vite_path/src/relative.rs index e6a9053b..de76ca1f 100644 --- a/crates/vite_path/src/relative.rs +++ b/crates/vite_path/src/relative.rs @@ -263,6 +263,7 @@ pub enum FromPathError { InvalidPathData(#[from] InvalidPathDataError), } +#[cfg(feature = "ts-rs")] mod ts_impl { use ts_rs::TS; diff --git a/crates/vite_str/Cargo.toml b/crates/vite_str/Cargo.toml index 735e8229..7159106c 100644 --- a/crates/vite_str/Cargo.toml +++ b/crates/vite_str/Cargo.toml @@ -11,7 +11,10 @@ bincode = { workspace = true } compact_str = { workspace = true, features = ["serde"] } diff-struct = { workspace = true } serde = { workspace = true, features = ["derive"] } -ts-rs = { workspace = true } +ts-rs = { workspace = true, optional = true } + +[features] +ts-rs = ["dep:ts-rs"] [lints] workspace = true diff --git a/crates/vite_str/src/lib.rs b/crates/vite_str/src/lib.rs index 1f9c941a..eee7882f 100644 --- a/crates/vite_str/src/lib.rs +++ b/crates/vite_str/src/lib.rs @@ -176,6 +176,7 @@ impl PartialEq for Str { } } +#[cfg(feature = "ts-rs")] mod ts_impl { use ts_rs::TS; diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 0a0326f1..dfab399f 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -17,7 +17,6 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs"] } -ts-rs = { workspace = true, features = ["format"] } vec1 = { workspace = true, features = ["smallvec-v1"] } vite_graph_ser = { workspace = true } vite_path = { workspace = true } @@ -28,6 +27,9 @@ vite_workspace = { workspace = true } pretty_assertions = "1.4.1" tempfile = { workspace = true } tokio = { workspace = true, features = ["fs", "rt-multi-thread"] } +ts-rs = { workspace = true, features = ["format"] } +vite_path = { workspace = true, features = ["ts-rs"] } +vite_str = { workspace = true, features = ["ts-rs"] } [lints] workspace = true diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 104bb771..4aae27aa 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -4,19 +4,21 @@ use std::{collections::HashMap, sync::Arc}; use monostate::MustBe; use serde::Deserialize; +#[cfg(test)] use ts_rs::TS; use vite_path::RelativePathBuf; use vite_str::Str; /// Cache-related fields of a task defined by user in `vite.config.*` -#[derive(Debug, Deserialize, PartialEq, Eq, TS)] +#[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(test, derive(TS))] #[serde(untagged, deny_unknown_fields, rename_all = "camelCase")] pub enum UserCacheConfig { /// Cache is enabled Enabled { /// Whether to cache the task #[serde(default)] - #[ts(type = "true")] + #[cfg_attr(test, ts(type = "true"))] cache: MustBe!(true), #[serde(flatten)] @@ -25,13 +27,14 @@ pub enum UserCacheConfig { /// Cache is disabled Disabled { /// Whether to cache the task - #[ts(type = "false")] + #[cfg_attr(test, ts(type = "false"))] cache: MustBe!(false), }, } /// Cache configuration fields when caching is enabled -#[derive(Debug, Deserialize, PartialEq, Eq, TS)] +#[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(test, derive(TS))] #[serde(rename_all = "camelCase")] pub struct EnabledCacheConfig { /// Environment variable names to be fingerprinted and passed to the task. @@ -44,7 +47,8 @@ pub struct EnabledCacheConfig { } /// Options for user-defined tasks in `vite.config.*`, excluding the command. -#[derive(Debug, Deserialize, PartialEq, Eq, TS)] +#[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(test, derive(TS))] #[serde(rename_all = "camelCase")] pub struct UserTaskOptions { /// The working directory for the task, relative to the package root (not workspace root). @@ -82,9 +86,10 @@ impl Default for UserTaskOptions { } /// Full user-defined task configuration in `vite.config.*`, including the command and options. -#[derive(Debug, Deserialize, PartialEq, Eq, TS)] +#[derive(Debug, Deserialize, PartialEq, Eq)] +#[cfg_attr(test, derive(TS))] #[serde(rename_all = "camelCase")] -#[ts(rename = "Task")] +#[cfg_attr(test, ts(rename = "Task"))] pub struct UserTaskConfig { /// The command to run for the task. /// @@ -103,9 +108,10 @@ pub struct UserConfigFile { } /// Type of the `tasks` field in `vite.config.*` -#[derive(Debug, Default, Deserialize, TS)] +#[derive(Debug, Default, Deserialize)] +#[cfg_attr(test, derive(TS))] #[serde(transparent)] -#[ts(rename = "Tasks")] +#[cfg_attr(test, ts(rename = "Tasks"))] pub struct UserConfigTasks(pub HashMap); impl UserConfigTasks { From 2df0c5966470579e484111b6f87da441dcd61159 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 18:52:50 +0800 Subject: [PATCH 06/13] clean up --- Cargo.lock | 3 --- Cargo.toml | 4 +++- crates/vite_task_bin/Cargo.toml | 1 - crates/vite_task_graph/Cargo.toml | 7 +++---- crates/vite_task_plan/Cargo.toml | 2 +- dprint.json | 3 ++- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 098c9a39..62018a34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3696,7 +3696,6 @@ version = "11.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4994acea2522cd2b3b85c1d9529a55991e3ad5e25cdcd3de9d505972c4379424" dependencies = [ - "dprint-plugin-typescript", "thiserror 2.0.17", "ts-rs-macros", ] @@ -3988,7 +3987,6 @@ dependencies = [ "vite_path", "vite_str", "vite_task", - "vite_task_graph", "vite_workspace", "which", ] @@ -4006,7 +4004,6 @@ dependencies = [ "pretty_assertions", "serde", "serde_json", - "tempfile", "thiserror 2.0.17", "tokio", "ts-rs", diff --git a/Cargo.toml b/Cargo.toml index bd4d6cfd..8372c3b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ ctor = "0.6" derive_more = "2.0.1" diff-struct = "0.5.3" directories = "6.0.0" +dprint-plugin-typescript = "0.95" elf = { version = "0.8.0", default-features = false } flate2 = "1.0.35" fspy = { path = "crates/fspy" } @@ -88,6 +89,7 @@ passfd = { git = "https://github.com/polachok/passfd", rev = "d55881752c16aced1a petgraph = "0.8.2" phf = { version = "0.11.3", features = ["macros"] } portable-pty = "0.9.0" +pretty_assertions = "1.4.1" rand = "0.9.1" ratatui = "0.29.0" rayon = "1.10.0" @@ -116,7 +118,7 @@ toml = "0.9.5" tracing = "0.1.43" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "serde"] } -ts-rs = { version = "11.1.0", features = ["format"] } +ts-rs = { version = "11.1.0" } tui-term = "0.2.0" twox-hash = "2.1.1" uuid = "1.18.1" diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index 2c14381d..59d984dd 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -19,7 +19,6 @@ tokio = { workspace = true, features = ["full"] } vite_path = { workspace = true } vite_str = { workspace = true } vite_task = { workspace = true } -vite_task_graph = { workspace = true } which = { workspace = true } [dev-dependencies] diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index dfab399f..0f7eb948 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -10,7 +10,7 @@ rust-version.workspace = true anyhow = { workspace = true } async-trait = { workspace = true } clap = { workspace = true, features = ["derive"] } -dprint-plugin-typescript = "0.95" +dprint-plugin-typescript = { workspace = true } monostate = { workspace = true } petgraph = { workspace = true } serde = { workspace = true, features = ["derive"] } @@ -24,10 +24,9 @@ vite_str = { workspace = true } vite_workspace = { workspace = true } [dev-dependencies] -pretty_assertions = "1.4.1" -tempfile = { workspace = true } +pretty_assertions = { workspace = true } tokio = { workspace = true, features = ["fs", "rt-multi-thread"] } -ts-rs = { workspace = true, features = ["format"] } +ts-rs = { workspace = true } vite_path = { workspace = true, features = ["ts-rs"] } vite_str = { workspace = true, features = ["ts-rs"] } diff --git a/crates/vite_task_plan/Cargo.toml b/crates/vite_task_plan/Cargo.toml index 571bcadc..2cdd741f 100644 --- a/crates/vite_task_plan/Cargo.toml +++ b/crates/vite_task_plan/Cargo.toml @@ -39,7 +39,7 @@ tempfile = { workspace = true } tokio = { workspace = true, features = ["rt", "macros"] } toml = { workspace = true } vite_task = { workspace = true } -vite_task_bin = { path = "../vite_task_bin" } +vite_task_bin = { workspace = true } vite_workspace = { workspace = true } [[test]] diff --git a/dprint.json b/dprint.json index 16a591a5..0484a32c 100644 --- a/dprint.json +++ b/dprint.json @@ -14,7 +14,8 @@ }, "excludes": [ "crates/fspy_detours_sys/detours", - "pnpm-lock.yaml" + "pnpm-lock.yaml", + "crates/vite_task_graph/task-config.ts" ], "plugins": [ "https://plugins.dprint.dev/typescript-0.94.0.wasm", From c2d0b69275b24a24e2ab40ef18dc11d10ee6cb50 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 19:12:00 +0800 Subject: [PATCH 07/13] ignore CR on windows --- crates/vite_task_graph/src/config/user.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 4aae27aa..4275af1a 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -169,12 +169,13 @@ mod ts_tests { fn typescript_generation() { let file_path = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("task-config.ts"); - let ts = UserConfigTasks::generate_ts_definition(); + let ts = UserConfigTasks::generate_ts_definition().replace("\r", ""); if env::var("VT_UPDATE_TS_TYPES").unwrap_or_default() == "1" { std::fs::write(&file_path, ts).unwrap(); } else { - let existing_ts = std::fs::read_to_string(&file_path).unwrap_or_default(); + let existing_ts = + std::fs::read_to_string(&file_path).unwrap_or_default().replace('\r', ""); pretty_assertions::assert_eq!( ts, existing_ts, From 8fd85cae741784d5eb016adbadd1d9b79664fd5e Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 19:32:31 +0800 Subject: [PATCH 08/13] refactor: replace dprint-plugin-typescript with oxfmt Replace the Rust dprint-plugin-typescript crate with oxfmt CLI for formatting generated TypeScript types. This removes a heavy Rust dependency and uses the faster oxfmt formatter via subprocess. Co-Authored-By: Claude Opus 4.5 --- Cargo.lock | 747 +--------------------- Cargo.toml | 1 - crates/vite_task_graph/Cargo.toml | 1 - crates/vite_task_graph/src/config/user.rs | 39 +- crates/vite_task_graph/task-config.ts | 73 +-- packages/tools/package.json | 1 + pnpm-lock.yaml | 95 +++ 7 files changed, 162 insertions(+), 795 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62018a34..54d4fadd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,15 +106,6 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" -[[package]] -name = "ar_archive_writer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c269894b6fe5e9d7ada0cf69b5bf847ff35bc25fc271f08e1d080fce80339a" -dependencies = [ - "object 0.32.2", -] - [[package]] name = "arrayvec" version = "0.7.6" @@ -150,17 +141,6 @@ version = "9.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59051ec02907378a67b0ba1b8631121f5388c8dbbb3cec8c749d8f93c2c3c211" -[[package]] -name = "ast_node" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a184645bcc6f52d69d8e7639720699c6a99efb711f886e251ed1d16db8dd90e" -dependencies = [ - "quote", - "swc_macros_common", - "syn 2.0.106", -] - [[package]] name = "async-trait" version = "0.1.89" @@ -188,7 +168,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object 0.37.3", + "object", "rustc-demangle", "windows-link", ] @@ -199,15 +179,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "better_scoped_tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd228125315b132eed175bf47619ac79b945b26e56b848ba203ae4ea8603609" -dependencies = [ - "scoped-tls", -] - [[package]] name = "bincode" version = "2.0.1" @@ -356,16 +327,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" -[[package]] -name = "bytes-str" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c60b5ce37e0b883c37eb89f79a1e26fbe9c1081945d024eee93e8d91a7e18b3" -dependencies = [ - "bytes", - "serde", -] - [[package]] name = "cached" version = "0.56.0" @@ -399,26 +360,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" -[[package]] -name = "capacity_builder" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f2d24a6dcf0cd402a21b65d35340f3a49ff3475dc5fdac91d22d2733e6641c6" -dependencies = [ - "capacity_builder_macros", - "itoa", -] - -[[package]] -name = "capacity_builder_macros" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b4a6cae9efc04cc6cbb8faf338d2c497c165c83e74509cf4dbedea948bbf6e5" -dependencies = [ - "quote", - "syn 2.0.106", -] - [[package]] name = "cassowary" version = "0.3.0" @@ -855,79 +796,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "data-url" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" - -[[package]] -name = "deno_ast" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72e0409b3dbd60a5bf296cbc273a8e36bb3a3aab6abac389f1891e187d5ce14" -dependencies = [ - "capacity_builder", - "deno_error", - "deno_media_type", - "deno_terminal", - "dprint-swc-ext", - "percent-encoding", - "serde", - "swc_atoms", - "swc_common", - "swc_ecma_ast", - "swc_ecma_lexer", - "swc_ecma_parser", - "swc_eq_ignore_macros", - "text_lines", - "thiserror 2.0.17", - "unicode-width 0.2.0", - "url", -] - -[[package]] -name = "deno_error" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3007d3f1ea92ea503324ae15883aac0c2de2b8cf6fead62203ff6a67161007ab" -dependencies = [ - "deno_error_macro", - "libc", -] - -[[package]] -name = "deno_error_macro" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b565e60a9685cdf312c888665b5f8647ac692a7da7e058a5e2268a466da8eaf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - -[[package]] -name = "deno_media_type" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd0af4161f90b092feb363864a64d7c74e0efc13a15905d0d09df73bb72a123" -dependencies = [ - "data-url", - "serde", - "url", -] - -[[package]] -name = "deno_terminal" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ba8041ae7319b3ca6a64c399df4112badcbbe0868b4517637647614bede4be" -dependencies = [ - "once_cell", - "termcolor", -] - [[package]] name = "derive_more" version = "2.0.1" @@ -1009,17 +877,6 @@ dependencies = [ "windows-sys 0.61.1", ] -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "document-features" version = "0.2.11" @@ -1035,65 +892,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" -[[package]] -name = "dprint-core" -version = "0.67.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1d827947704a9495f705d6aeed270fa21a67f825f22902c28f38dc3af7a9ae" -dependencies = [ - "anyhow", - "bumpalo", - "hashbrown 0.15.5", - "indexmap", - "rustc-hash", - "serde", - "unicode-width 0.2.0", -] - -[[package]] -name = "dprint-core-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1675ad2b358481f3cc46202040d64ac7a36c4ade414a696df32e0e45421a6e9f" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "dprint-plugin-typescript" -version = "0.95.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed62468ffd2bc0a759497022c7e20ec08f15d74057ad17c0bfa5b3ca657e8c8d" -dependencies = [ - "anyhow", - "capacity_builder", - "deno_ast", - "dprint-core", - "dprint-core-macros", - "percent-encoding", - "rustc-hash", - "serde", -] - -[[package]] -name = "dprint-swc-ext" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf592ae6a864437e98ef9c6ae7936b822077e9d038a3a48ee081ab92313afad4" -dependencies = [ - "allocator-api2", - "bumpalo", - "num-bigint", - "rustc-hash", - "swc_atoms", - "swc_common", - "swc_ecma_ast", - "swc_ecma_lexer", - "swc_ecma_parser", - "text_lines", -] - [[package]] name = "dtor" version = "0.1.0" @@ -1255,25 +1053,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "form_urlencoded" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "from_variant" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308530a56b099da144ebc5d8e179f343ad928fa2b3558d1eb3db9af18d6eff43" -dependencies = [ - "swc_macros_common", - "syn 2.0.106", -] - [[package]] name = "fspy" version = "0.1.0" @@ -1579,16 +1358,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] - [[package]] name = "hashbrown" version = "0.15.5" @@ -1627,127 +1396,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hstr" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f11d91d7befd2ffd9d216e9e5ea1fae6174b20a2a1b67a688138003d2f4122" -dependencies = [ - "hashbrown 0.14.5", - "new_debug_unreachable", - "once_cell", - "rustc-hash", - "triomphe", -] - -[[package]] -name = "icu_collections" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" -dependencies = [ - "displaydoc", - "potential_utf", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locale_core" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" -dependencies = [ - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec 1.15.1", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" - -[[package]] -name = "icu_properties" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" -dependencies = [ - "icu_collections", - "icu_locale_core", - "icu_properties_data", - "icu_provider", - "zerotrie", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" - -[[package]] -name = "icu_provider" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" -dependencies = [ - "displaydoc", - "icu_locale_core", - "writeable", - "yoke", - "zerofrom", - "zerotrie", - "zerovec", -] - [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" -dependencies = [ - "idna_adapter", - "smallvec 1.15.1", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" -dependencies = [ - "icu_normalizer", - "icu_properties", -] - [[package]] name = "indenter" version = "0.3.4" @@ -1762,8 +1416,6 @@ checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", "hashbrown 0.16.1", - "serde", - "serde_core", ] [[package]] @@ -1804,18 +1456,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "is-macro" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "is_ci" version = "1.2.0" @@ -1943,12 +1583,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" -[[package]] -name = "litemap" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" - [[package]] name = "litrs" version = "0.4.2" @@ -2071,12 +1705,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" - [[package]] name = "nix" version = "0.23.2" @@ -2165,7 +1793,6 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", - "serde", ] [[package]] @@ -2217,15 +1844,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - [[package]] name = "object" version = "0.37.3" @@ -2358,12 +1976,6 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "132dca9b868d927b35b5dd728167b2dee150eb1ad686008fc71ccb298b776fca" -[[package]] -name = "percent-encoding" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" - [[package]] name = "pest" version = "2.8.4" @@ -2459,7 +2071,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ - "siphasher 1.0.1", + "siphasher", ] [[package]] @@ -2510,15 +2122,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "potential_utf" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" -dependencies = [ - "zerovec", -] - [[package]] name = "ppv-lite86" version = "0.2.21" @@ -2570,16 +2173,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "psm" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d11f2fedc3b7dafdc2851bc52f277377c5473d378859be234bc7ebb593144d01" -dependencies = [ - "ar_archive_writer", - "cc", -] - [[package]] name = "quote" version = "1.0.41" @@ -2869,12 +2462,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.2.0" @@ -2910,12 +2497,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "seq-macro" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" - [[package]] name = "serde" version = "1.0.228" @@ -3093,12 +2674,6 @@ version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - [[package]] name = "siphasher" version = "1.0.1" @@ -3123,17 +2698,6 @@ version = "2.0.0-alpha.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef784004ca8777809dcdad6ac37629f0a97caee4c685fcea805278d81dd8b857" -[[package]] -name = "smartstring" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" -dependencies = [ - "autocfg", - "static_assertions", - "version_check", -] - [[package]] name = "socket2" version = "0.6.0" @@ -3144,12 +2708,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" - [[package]] name = "stackalloc" version = "1.2.1" @@ -3160,36 +2718,12 @@ dependencies = [ "rustc_version 0.2.3", ] -[[package]] -name = "stacker" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f8b29fb42aafcea4edeeb6b2f2d7ecd0d969c48b4cf0d2e64aafc471dd6e59" -dependencies = [ - "cc", - "cfg-if", - "libc", - "psm", - "windows-sys 0.59.0", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "string_enum" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae36a4951ca7bd1cfd991c241584a9824a70f6aff1e7d4f693fb3f2465e4030e" -dependencies = [ - "quote", - "swc_macros_common", - "syn 2.0.106", -] - [[package]] name = "strsim" version = "0.11.1" @@ -3227,134 +2761,6 @@ dependencies = [ "is_ci", ] -[[package]] -name = "swc_atoms" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3500dcf04c84606b38464561edc5e46f5132201cb3e23cf9613ed4033d6b1bb2" -dependencies = [ - "hstr", - "once_cell", - "serde", -] - -[[package]] -name = "swc_common" -version = "14.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2bb772b3a26b8b71d4e8c112ced5b5867be2266364b58517407a270328a2696" -dependencies = [ - "anyhow", - "ast_node", - "better_scoped_tls", - "bytes-str", - "either", - "from_variant", - "new_debug_unreachable", - "num-bigint", - "once_cell", - "rustc-hash", - "serde", - "siphasher 0.3.11", - "swc_atoms", - "swc_eq_ignore_macros", - "swc_visit", - "tracing", - "unicode-width 0.1.14", - "url", -] - -[[package]] -name = "swc_ecma_ast" -version = "15.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c25af97d53cf8aab66a6c68f3418663313fc969ad267fc2a4d19402c329be1" -dependencies = [ - "bitflags 2.10.0", - "is-macro", - "num-bigint", - "once_cell", - "phf", - "rustc-hash", - "serde", - "string_enum", - "swc_atoms", - "swc_common", - "swc_visit", - "unicode-id-start", -] - -[[package]] -name = "swc_ecma_lexer" -version = "23.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "017d06ea85008234aa9fb34d805c7dc563f2ea6e03869ed5ac5a2dc27d561e4d" -dependencies = [ - "arrayvec", - "bitflags 2.10.0", - "either", - "num-bigint", - "phf", - "rustc-hash", - "seq-macro", - "serde", - "smallvec 1.15.1", - "smartstring", - "stacker", - "swc_atoms", - "swc_common", - "swc_ecma_ast", - "tracing", -] - -[[package]] -name = "swc_ecma_parser" -version = "24.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9011783c975ba592ffc09cd208ced92b1dfabb2e5e0ef453559e2e25286127" -dependencies = [ - "either", - "num-bigint", - "serde", - "swc_atoms", - "swc_common", - "swc_ecma_ast", - "swc_ecma_lexer", - "tracing", -] - -[[package]] -name = "swc_eq_ignore_macros" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c16ce73424a6316e95e09065ba6a207eba7765496fed113702278b7711d4b632" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - -[[package]] -name = "swc_macros_common" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1efbaa74943dc5ad2a2fb16cbd78b77d7e4d63188f3c5b4df2b4dcd2faaae" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - -[[package]] -name = "swc_visit" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62fb71484b486c185e34d2172f0eabe7f4722742aad700f426a494bb2de232a2" -dependencies = [ - "either", - "new_debug_unreachable", -] - [[package]] name = "syn" version = "1.0.109" @@ -3377,17 +2783,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "syscalls" version = "0.6.18" @@ -3449,15 +2844,6 @@ dependencies = [ "syn 2.0.106", ] -[[package]] -name = "text_lines" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd5828de7deaa782e1dd713006ae96b3bee32d3279b79eb67ecf8072c059bcf" -dependencies = [ - "serde", -] - [[package]] name = "thiserror" version = "1.0.69" @@ -3507,16 +2893,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "tinystr" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tokio" version = "1.48.0" @@ -3680,16 +3056,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "triomphe" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd69c5aa8f924c7519d6372789a74eac5b94fb0f8fcf0d4a97eb0bfc3e785f39" -dependencies = [ - "serde", - "stable_deref_trait", -] - [[package]] name = "ts-rs" version = "11.1.0" @@ -3749,12 +3115,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" -[[package]] -name = "unicode-id-start" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b79ad29b5e19de4260020f8919b443b2ef0277d242ce532ec7b7a2cc8b6007" - [[package]] name = "unicode-ident" version = "1.0.19" @@ -3802,19 +3162,6 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" -[[package]] -name = "url" -version = "2.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", - "serde", - "serde_derive", -] - [[package]] name = "utf8-chars" version = "3.0.6" @@ -3824,12 +3171,6 @@ dependencies = [ "arrayvec", ] -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -3998,7 +3339,6 @@ dependencies = [ "anyhow", "async-trait", "clap", - "dprint-plugin-typescript", "monostate", "petgraph", "pretty_assertions", @@ -4541,12 +3881,6 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" -[[package]] -name = "writeable" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" - [[package]] name = "xattr" version = "1.6.1" @@ -4569,29 +3903,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" -[[package]] -name = "yoke" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" -dependencies = [ - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", - "synstructure", -] - [[package]] name = "zerocopy" version = "0.8.27" @@ -4611,57 +3922,3 @@ dependencies = [ "quote", "syn 2.0.106", ] - -[[package]] -name = "zerofrom" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", - "synstructure", -] - -[[package]] -name = "zerotrie" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", -] - -[[package]] -name = "zerovec" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] diff --git a/Cargo.toml b/Cargo.toml index 8372c3b1..4595da9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,6 @@ ctor = "0.6" derive_more = "2.0.1" diff-struct = "0.5.3" directories = "6.0.0" -dprint-plugin-typescript = "0.95" elf = { version = "0.8.0", default-features = false } flate2 = "1.0.35" fspy = { path = "crates/fspy" } diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 0f7eb948..821d2fad 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -10,7 +10,6 @@ rust-version.workspace = true anyhow = { workspace = true } async-trait = { workspace = true } clap = { workspace = true, features = ["derive"] } -dprint-plugin-typescript = { workspace = true } monostate = { workspace = true } petgraph = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 4275af1a..cf57e64b 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -121,9 +121,11 @@ impl UserConfigTasks { /// Generates TypeScript type definitions for user task configuration. #[cfg(test)] pub fn generate_ts_definition() -> String { - use dprint_plugin_typescript::{ - FormatTextOptions, configuration::ConfigurationBuilder, format_text, + use std::{ + io::Write, + process::{Command, Stdio}, }; + use ts_rs::TypeVisitor; struct DeclCollector(Vec); @@ -146,16 +148,29 @@ impl UserConfigTasks { types.push_str("\n\nexport "); types.push_str(&Self::decl()); - // Format - let fmt_cfg = ConfigurationBuilder::new().build(); - let options = FormatTextOptions { - config: &fmt_cfg, - path: std::path::Path::new("task-config.ts"), - text: types.clone(), - extension: None, - external_formatter: None, - }; - format_text(options).unwrap().unwrap() + // Format using oxfmt from packages/tools + let workspace_root = + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap(); + let oxfmt = workspace_root.join("packages/tools/node_modules/.bin/oxfmt"); + + let mut child = Command::new(oxfmt) + .arg("--stdin-filepath=task-config.ts") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .expect("failed to spawn oxfmt"); + + child + .stdin + .take() + .unwrap() + .write_all(types.as_bytes()) + .expect("failed to write to oxfmt stdin"); + + let output = child.wait_with_output().expect("failed to read oxfmt output"); + assert!(output.status.success(), "oxfmt failed"); + + String::from_utf8(output.stdout).expect("oxfmt output is not valid UTF-8") } } diff --git a/crates/vite_task_graph/task-config.ts b/crates/vite_task_graph/task-config.ts index 75f0b9ed..8a9131aa 100644 --- a/crates/vite_task_graph/task-config.ts +++ b/crates/vite_task_graph/task-config.ts @@ -1,38 +1,39 @@ -type Task = - & { - /** - * The command to run for the task. - * - * If omitted, the script from `package.json` with the same name will be used - */ - command: string | null; - /** - * The working directory for the task, relative to the package root (not workspace root). - */ - cwd: string; - /** - * Dependencies of this task. Use `package-name#task-name` to refer to tasks in other packages. - */ - dependsOn: Array; - } - & ({ - /** - * Whether to cache the task - */ - cache: true; - /** - * Environment variable names to be fingerprinted and passed to the task. - */ - envs: Array; - /** - * Environment variable names to be passed to the task without fingerprinting. - */ - passThroughEnvs: Array; - } | { - /** - * Whether to cache the task - */ - cache: false; - }); +type Task = { + /** + * The command to run for the task. + * + * If omitted, the script from `package.json` with the same name will be used + */ + command: string | null; + /** + * The working directory for the task, relative to the package root (not workspace root). + */ + cwd: string; + /** + * Dependencies of this task. Use `package-name#task-name` to refer to tasks in other packages. + */ + dependsOn: Array; +} & ( + | { + /** + * Whether to cache the task + */ + cache: true; + /** + * Environment variable names to be fingerprinted and passed to the task. + */ + envs: Array; + /** + * Environment variable names to be passed to the task without fingerprinting. + */ + passThroughEnvs: Array; + } + | { + /** + * Whether to cache the task + */ + cache: false; + } +); export type Tasks = { [key in string]?: Task }; diff --git a/packages/tools/package.json b/packages/tools/package.json index 7e746efe..e770356f 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "cross-env": "^10.1.0", + "oxfmt": "0.26.0", "oxlint": "catalog:", "oxlint-tsgolint": "catalog:", "vite-task-tools": "link:" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 200a128a..5ca50755 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: cross-env: specifier: ^10.1.0 version: 10.1.0 + oxfmt: + specifier: 0.26.0 + version: 0.26.0 oxlint: specifier: 'catalog:' version: 1.38.0(oxlint-tsgolint@0.10.1) @@ -62,6 +65,50 @@ packages: '@epic-web/invariant@1.0.0': resolution: {integrity: sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==} + '@oxfmt/darwin-arm64@0.26.0': + resolution: {integrity: sha512-AAGc+8CffkiWeVgtWf4dPfQwHEE5c/j/8NWH7VGVxxJRCZFdmWcqCXprvL2H6qZFewvDLrFbuSPRCqYCpYGaTQ==} + cpu: [arm64] + os: [darwin] + + '@oxfmt/darwin-x64@0.26.0': + resolution: {integrity: sha512-xFx5ijCTjw577wJvFlZEMmKDnp3HSCcbYdCsLRmC5i3TZZiDe9DEYh3P46uqhzj8BkEw1Vm1ZCWdl48aEYAzvQ==} + cpu: [x64] + os: [darwin] + + '@oxfmt/linux-arm64-gnu@0.26.0': + resolution: {integrity: sha512-GubkQeQT5d3B/Jx/IiR7NMkSmXrCZcVI0BPh1i7mpFi8HgD1hQ/LbhiBKAMsMqs5bbugdQOgBEl8bOhe8JhW1g==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxfmt/linux-arm64-musl@0.26.0': + resolution: {integrity: sha512-OEypUwK69bFPj+aa3/LYCnlIUPgoOLu//WNcriwpnWNmt47808Ht7RJSg+MNK8a7pSZHpXJ5/E6CRK/OTwFdaQ==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxfmt/linux-x64-gnu@0.26.0': + resolution: {integrity: sha512-xO6iEW2bC6ZHyOTPmPWrg/nM6xgzyRPaS84rATy6F8d79wz69LdRdJ3l/PXlkqhi7XoxhvX4ExysA0Nf10ZZEQ==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxfmt/linux-x64-musl@0.26.0': + resolution: {integrity: sha512-Z3KuZFC+MIuAyFCXBHY71kCsdRq1ulbsbzTe71v+hrEv7zVBn6yzql+/AZcgfIaKzWO9OXNuz5WWLWDmVALwow==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxfmt/win32-arm64@0.26.0': + resolution: {integrity: sha512-3zRbqwVWK1mDhRhTknlQFpRFL9GhEB5GfU6U7wawnuEwpvi39q91kJ+SRJvJnhyPCARkjZBd1V8XnweN5IFd1g==} + cpu: [arm64] + os: [win32] + + '@oxfmt/win32-x64@0.26.0': + resolution: {integrity: sha512-m8TfIljU22i9UEIkD+slGPifTFeaCwIUfxszN3E6ABWP1KQbtwSw9Ak0TdoikibvukF/dtbeyG3WW63jv9DnEg==} + cpu: [x64] + os: [win32] + '@oxlint-tsgolint/darwin-arm64@0.10.1': resolution: {integrity: sha512-KGC4++BeEqrIcmDHiJt/e6/860PWJmUJjjp0mE+smpBmRXMjmOFFjrPmN+ZyCyVgf1WdmhPkQXsRSPeTR+2omw==} cpu: [arm64] @@ -242,6 +289,11 @@ packages: resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==} engines: {node: '>=18'} + oxfmt@0.26.0: + resolution: {integrity: sha512-UDD1wFNwfeorMm2ZY0xy1KRAAvJ5NjKBfbDmiMwGP7baEHTq65cYpC0aPP+BGHc8weXUbSZaK8MdGyvuRUvS4Q==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + oxlint-tsgolint@0.10.1: resolution: {integrity: sha512-EEHNdo5cW2w1xwYdBQ7d3IXDqWAtMkfVFrh+9gQ4kYbYJwygY4QXSh1eH80/xVipZdVKujAwBgg/nNNHk56kxQ==} hasBin: true @@ -308,6 +360,10 @@ packages: resolution: {integrity: sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==} engines: {node: '>=12'} + tinypool@2.0.0: + resolution: {integrity: sha512-/RX9RzeH2xU5ADE7n2Ykvmi9ED3FBGPAjw9u3zucrNNaEBIO0HPSYgL0NT7+3p147ojeSdaVu08F6hjpv31HJg==} + engines: {node: ^20.0.0 || >=22.0.0} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -333,6 +389,30 @@ snapshots: '@epic-web/invariant@1.0.0': {} + '@oxfmt/darwin-arm64@0.26.0': + optional: true + + '@oxfmt/darwin-x64@0.26.0': + optional: true + + '@oxfmt/linux-arm64-gnu@0.26.0': + optional: true + + '@oxfmt/linux-arm64-musl@0.26.0': + optional: true + + '@oxfmt/linux-x64-gnu@0.26.0': + optional: true + + '@oxfmt/linux-x64-musl@0.26.0': + optional: true + + '@oxfmt/win32-arm64@0.26.0': + optional: true + + '@oxfmt/win32-x64@0.26.0': + optional: true + '@oxlint-tsgolint/darwin-arm64@0.10.1': optional: true @@ -477,6 +557,19 @@ snapshots: dependencies: mimic-function: 5.0.1 + oxfmt@0.26.0: + dependencies: + tinypool: 2.0.0 + optionalDependencies: + '@oxfmt/darwin-arm64': 0.26.0 + '@oxfmt/darwin-x64': 0.26.0 + '@oxfmt/linux-arm64-gnu': 0.26.0 + '@oxfmt/linux-arm64-musl': 0.26.0 + '@oxfmt/linux-x64-gnu': 0.26.0 + '@oxfmt/linux-x64-musl': 0.26.0 + '@oxfmt/win32-arm64': 0.26.0 + '@oxfmt/win32-x64': 0.26.0 + oxlint-tsgolint@0.10.1: optionalDependencies: '@oxlint-tsgolint/darwin-arm64': 0.10.1 @@ -541,6 +634,8 @@ snapshots: dependencies: ansi-regex: 6.2.2 + tinypool@2.0.0: {} + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 From bb82d5710864e8bc8c34e6ef7e86e51213120d48 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 19:36:43 +0800 Subject: [PATCH 09/13] export all items --- crates/vite_task_graph/src/config/user.rs | 9 ++++++++- crates/vite_task_graph/task-config.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index cf57e64b..989b7a13 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -142,7 +142,14 @@ impl UserConfigTasks { let mut collector = DeclCollector(Vec::new()); Self::visit_dependencies(&mut collector); - let mut types = collector.0.join("\n\n"); + + // Export all types + let mut types: String = collector + .0 + .iter() + .map(|decl| vite_str::format!("export {decl}")) + .collect::>() + .join("\n\n"); // Export the main type types.push_str("\n\nexport "); diff --git a/crates/vite_task_graph/task-config.ts b/crates/vite_task_graph/task-config.ts index 8a9131aa..d8e92922 100644 --- a/crates/vite_task_graph/task-config.ts +++ b/crates/vite_task_graph/task-config.ts @@ -1,4 +1,4 @@ -type Task = { +export type Task = { /** * The command to run for the task. * From 0ce59a000e0f780490fa9f5dc044587d0f1acf66 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 19:52:21 +0800 Subject: [PATCH 10/13] find oxfmt with which --- Cargo.lock | 1 + crates/vite_task_graph/Cargo.toml | 1 + crates/vite_task_graph/src/config/user.rs | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54d4fadd..8fdaa00c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3352,6 +3352,7 @@ dependencies = [ "vite_path", "vite_str", "vite_workspace", + "which", ] [[package]] diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 821d2fad..17fc8225 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -28,6 +28,7 @@ tokio = { workspace = true, features = ["fs", "rt-multi-thread"] } ts-rs = { workspace = true } vite_path = { workspace = true, features = ["ts-rs"] } vite_str = { workspace = true, features = ["ts-rs"] } +which = { workspace = true } [lints] workspace = true diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 989b7a13..a383efe3 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -158,9 +158,12 @@ impl UserConfigTasks { // Format using oxfmt from packages/tools let workspace_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap(); - let oxfmt = workspace_root.join("packages/tools/node_modules/.bin/oxfmt"); + let tools_path = workspace_root.join("packages/tools/node_modules/.bin"); - let mut child = Command::new(oxfmt) + let oxfmt_path = which::which_in("oxfmt", Some(&tools_path), &tools_path) + .expect("oxfmt not found in packages/tools"); + + let mut child = Command::new(oxfmt_path) .arg("--stdin-filepath=task-config.ts") .stdin(Stdio::piped()) .stdout(Stdio::piped()) From f18826cf7d72eb6df5b25a0b36ee177c73b39096 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 20:20:18 +0800 Subject: [PATCH 11/13] feat: make serde(default) fields optional in generated TypeScript Replace `#[serde(default)]` with `Option` for config fields so they generate as optional (`?:`) in TypeScript. This allows users to omit fields like `cwd`, `dependsOn`, `envs`, and `passThroughEnvs` in their config files. Co-Authored-By: Claude Opus 4.5 --- crates/vite_task_bin/src/lib.rs | 7 ++-- crates/vite_task_graph/src/config/mod.rs | 22 ++++++----- crates/vite_task_graph/src/config/user.rs | 45 +++++++++-------------- crates/vite_task_graph/src/lib.rs | 6 +-- crates/vite_task_graph/task-config.ts | 12 +++--- 5 files changed, 42 insertions(+), 50 deletions(-) diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs index 7921136a..1284f415 100644 --- a/crates/vite_task_bin/src/lib.rs +++ b/crates/vite_task_bin/src/lib.rs @@ -8,7 +8,6 @@ use std::{ }; use clap::Subcommand; -use monostate::MustBe; use vite_path::AbsolutePath; use vite_str::Str; use vite_task::{ @@ -120,10 +119,10 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { args: [name.clone()].into(), task_options: UserTaskOptions { cache_config: UserCacheConfig::Enabled { - cache: MustBe!(true), + cache: None, enabled_cache_config: EnabledCacheConfig { - envs: Box::new([]), - pass_through_envs: vec![name], + envs: None, + pass_through_envs: Some(vec![name]), }, }, ..Default::default() diff --git a/crates/vite_task_graph/src/config/mod.rs b/crates/vite_task_graph/src/config/mod.rs index 2a468a0a..e9bc1a78 100644 --- a/crates/vite_task_graph/src/config/mod.rs +++ b/crates/vite_task_graph/src/config/mod.rs @@ -41,21 +41,23 @@ pub struct ResolvedTaskOptions { impl ResolvedTaskOptions { /// Resolves from user-defined options and the directory path where the options are defined. pub fn resolve(user_options: UserTaskOptions, dir: &Arc) -> Self { - let cwd: Arc = if user_options.cwd_relative_to_package.as_str().is_empty() { - Arc::clone(dir) - } else { - dir.join(user_options.cwd_relative_to_package).into() + let cwd: Arc = match user_options.cwd_relative_to_package { + Some(ref cwd) if !cwd.as_str().is_empty() => dir.join(cwd).into(), + _ => Arc::clone(dir), }; let cache_config = match user_options.cache_config { UserCacheConfig::Disabled { cache: MustBe!(false) } => None, - UserCacheConfig::Enabled { cache: MustBe!(true), mut enabled_cache_config } => { - enabled_cache_config - .pass_through_envs - .extend(DEFAULT_PASSTHROUGH_ENVS.iter().copied().map(Str::from)); + UserCacheConfig::Enabled { cache: _, enabled_cache_config } => { + let mut pass_through_envs = + enabled_cache_config.pass_through_envs.unwrap_or_default(); + pass_through_envs.extend(DEFAULT_PASSTHROUGH_ENVS.iter().copied().map(Str::from)); Some(CacheConfig { env_config: EnvConfig { - fingerprinted_envs: enabled_cache_config.envs.into_iter().collect(), - pass_through_envs: enabled_cache_config.pass_through_envs.into(), + fingerprinted_envs: enabled_cache_config + .envs + .map(|e| e.into_vec().into_iter().collect()) + .unwrap_or_default(), + pass_through_envs: pass_through_envs.into(), }, }) } diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index a383efe3..394453fa 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -11,15 +11,14 @@ use vite_str::Str; /// Cache-related fields of a task defined by user in `vite.config.*` #[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(test, derive(TS))] +#[cfg_attr(test, derive(TS), ts(optional_fields))] #[serde(untagged, deny_unknown_fields, rename_all = "camelCase")] pub enum UserCacheConfig { /// Cache is enabled Enabled { /// Whether to cache the task - #[serde(default)] - #[cfg_attr(test, ts(type = "true"))] - cache: MustBe!(true), + #[cfg_attr(test, ts(type = "true", optional))] + cache: Option, #[serde(flatten)] enabled_cache_config: EnabledCacheConfig, @@ -34,31 +33,27 @@ pub enum UserCacheConfig { /// Cache configuration fields when caching is enabled #[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(test, derive(TS))] +#[cfg_attr(test, derive(TS), ts(optional_fields))] #[serde(rename_all = "camelCase")] pub struct EnabledCacheConfig { /// Environment variable names to be fingerprinted and passed to the task. - #[serde(default)] // default to empty if omitted - pub envs: Box<[Str]>, + pub envs: Option>, /// Environment variable names to be passed to the task without fingerprinting. - #[serde(default)] // default to empty if omitted - pub pass_through_envs: Vec, + pub pass_through_envs: Option>, } /// Options for user-defined tasks in `vite.config.*`, excluding the command. #[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(test, derive(TS))] +#[cfg_attr(test, derive(TS), ts(optional_fields))] #[serde(rename_all = "camelCase")] pub struct UserTaskOptions { /// The working directory for the task, relative to the package root (not workspace root). - #[serde(default)] // default to empty if omitted #[serde(rename = "cwd")] - pub cwd_relative_to_package: RelativePathBuf, + pub cwd_relative_to_package: Option, /// Dependencies of this task. Use `package-name#task-name` to refer to tasks in other packages. - #[serde(default)] // default to empty if omitted - pub depends_on: Arc<[Str]>, + pub depends_on: Option>, /// Cache-related fields #[serde(flatten)] @@ -70,16 +65,13 @@ impl Default for UserTaskOptions { fn default() -> Self { Self { // Runs in the package root - cwd_relative_to_package: RelativePathBuf::default(), + cwd_relative_to_package: None, // No dependencies - depends_on: Arc::new([]), + depends_on: None, // Caching enabled with no fingerprinted envs cache_config: UserCacheConfig::Enabled { - cache: MustBe!(true), - enabled_cache_config: EnabledCacheConfig { - envs: Box::new([]), - pass_through_envs: Vec::new(), - }, + cache: None, + enabled_cache_config: EnabledCacheConfig { envs: None, pass_through_envs: None }, }, } } @@ -87,9 +79,8 @@ impl Default for UserTaskOptions { /// Full user-defined task configuration in `vite.config.*`, including the command and options. #[derive(Debug, Deserialize, PartialEq, Eq)] -#[cfg_attr(test, derive(TS))] +#[cfg_attr(test, derive(TS), ts(optional_fields, rename = "Task"))] #[serde(rename_all = "camelCase")] -#[cfg_attr(test, ts(rename = "Task"))] pub struct UserTaskConfig { /// The command to run for the task. /// @@ -236,7 +227,7 @@ mod tests { "cwd": "src" }); let user_config: UserTaskConfig = serde_json::from_value(user_config_json).unwrap(); - assert_eq!(user_config.options.cwd_relative_to_package.as_str(), "src"); + assert_eq!(user_config.options.cwd_relative_to_package.as_ref().unwrap().as_str(), "src"); } #[test] @@ -261,10 +252,10 @@ mod tests { assert_eq!( serde_json::from_value::(user_config_json).unwrap(), UserCacheConfig::Enabled { - cache: MustBe!(true), + cache: Some(MustBe!(true)), enabled_cache_config: EnabledCacheConfig { - envs: ["NODE_ENV".into()].into_iter().collect(), - pass_through_envs: ["FOO".into()].into_iter().collect(), + envs: Some(["NODE_ENV".into()].into_iter().collect()), + pass_through_envs: Some(["FOO".into()].into_iter().collect()), } }, ); diff --git a/crates/vite_task_graph/src/lib.rs b/crates/vite_task_graph/src/lib.rs index de1450b3..5190a571 100644 --- a/crates/vite_task_graph/src/lib.rs +++ b/crates/vite_task_graph/src/lib.rs @@ -192,7 +192,7 @@ impl IndexedTaskGraph { let package_graph = vite_workspace::load_package_graph(workspace_root)?; // Record dependency specifiers for each task node to add explicit dependencies later - let mut task_ids_with_dependency_specifiers: Vec<(TaskId, Arc<[Str]>)> = Vec::new(); + let mut task_ids_with_dependency_specifiers: Vec<(TaskId, Option>)> = Vec::new(); // index tasks by ids let mut node_indices_by_task_id: HashMap = @@ -223,7 +223,7 @@ impl IndexedTaskGraph { let task_id = TaskId { task_name: task_name.clone(), package_index }; - let dependency_specifiers = Arc::clone(&task_user_config.options.depends_on); + let dependency_specifiers = task_user_config.options.depends_on.clone(); // Resolve the task configuration combining vite.config.* and package.json script let resolved_config = ResolvedTaskConfig::resolve( @@ -298,7 +298,7 @@ impl IndexedTaskGraph { // Add explicit dependencies for (from_task_id, dependency_specifiers) in task_ids_with_dependency_specifiers { let from_node_index = me.node_indices_by_task_id[&from_task_id]; - for specifier in dependency_specifiers.iter().cloned() { + for specifier in dependency_specifiers.iter().flat_map(|s| s.iter()).cloned() { let to_node_index = me .get_task_index_by_specifier::( TaskSpecifier::parse_raw(&specifier), diff --git a/crates/vite_task_graph/task-config.ts b/crates/vite_task_graph/task-config.ts index d8e92922..0c3db044 100644 --- a/crates/vite_task_graph/task-config.ts +++ b/crates/vite_task_graph/task-config.ts @@ -4,29 +4,29 @@ export type Task = { * * If omitted, the script from `package.json` with the same name will be used */ - command: string | null; + command?: string; /** * The working directory for the task, relative to the package root (not workspace root). */ - cwd: string; + cwd?: string; /** * Dependencies of this task. Use `package-name#task-name` to refer to tasks in other packages. */ - dependsOn: Array; + dependsOn?: Array; } & ( | { /** * Whether to cache the task */ - cache: true; + cache?: true; /** * Environment variable names to be fingerprinted and passed to the task. */ - envs: Array; + envs?: Array; /** * Environment variable names to be passed to the task without fingerprinting. */ - passThroughEnvs: Array; + passThroughEnvs?: Array; } | { /** From 52b97c021b7b98801f9b85276a0dc20ed23b5c2f Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 20:27:18 +0800 Subject: [PATCH 12/13] cargo shear --fix --- Cargo.lock | 1 - crates/vite_task_bin/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8fdaa00c..7c4b8a5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3319,7 +3319,6 @@ dependencies = [ "copy_dir", "cow-utils", "insta", - "monostate", "regex", "serde", "tempfile", diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index 59d984dd..879a468b 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -14,7 +14,6 @@ path = "src/main.rs" anyhow = { workspace = true } async-trait = { workspace = true } clap = { workspace = true, features = ["derive"] } -monostate = { workspace = true } tokio = { workspace = true, features = ["full"] } vite_path = { workspace = true } vite_str = { workspace = true } From 9cfc3cb24db1a0b794732a6ccf658f15d840ac17 Mon Sep 17 00:00:00 2001 From: branchseer Date: Fri, 23 Jan 2026 20:29:13 +0800 Subject: [PATCH 13/13] ci: split lint commands into separate steps Separates each lint command into its own step for better visibility in CI logs when a specific check fails. Co-Authored-By: Claude Opus 4.5 --- .github/workflows/ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afc8e8d2..f7b266d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,12 +100,11 @@ jobs: tools: dprint,cargo-shear components: clippy rust-docs rustfmt - - run: | - dprint check - cargo shear - cargo fmt --check - # cargo clippy --all-targets --all-features -- -D warnings - RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items + - run: dprint check + - run: cargo shear + - run: cargo fmt --check + # - run: cargo clippy --all-targets --all-features -- -D warnings + - run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items - uses: crate-ci/typos@85f62a8a84f939ae994ab3763f01a0296d61a7ee # v1.36.2 with: