Skip to content

Commit d594f0d

Browse files
committed
refactor(pack): align pack-schema to latest pack-core Config
- Rename ProjectOptions to CompleteConfig - Remove API-level fields from schema - Add SchemaReactConfig and SchemaProviderConfigValue types - Add missing OutputConfig fields: css_filename, css_chunk_filename, asset_module_filename, public_path - Fix OutputType serde to kebab-case - Fix swc_plugins type to Vec<(String, Value)> tuples - Remove stale mdx_rs and conditions fields - Enhance SchemaConfigConditionItem to support all/any/not/base - Box large enum variants for clippy - Add and update tests
1 parent 6103a61 commit d594f0d

4 files changed

Lines changed: 1429 additions & 29 deletions

File tree

crates/pack-schema/src/lib.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::collections::HashMap;
66
/// This represents the JSON config file structure, aligned with pack-core's `Config` struct.
77
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
88
#[serde(rename_all = "camelCase")]
9-
pub struct ProjectOptions {
9+
pub struct CompleteConfig {
1010
/// Build mode (development, production)
1111
#[serde(skip_serializing_if = "Option::is_none")]
1212
#[schemars(description = "Build mode")]
@@ -720,6 +720,8 @@ pub enum SchemaConfigConditionItem {
720720
)]
721721
content_type: Option<SchemaConfigConditionContentType>,
722722
},
723+
/// Built-in condition (e.g., "server", "client", "edge")
724+
Builtin(String),
723725
}
724726

725727
/// Configuration condition path
@@ -907,9 +909,9 @@ pub struct SchemaExperimentalConfig {
907909
// Schema generation
908910
// ---------------------------------------------------------------------------
909911

910-
/// Generate JSON Schema for ProjectOptions
912+
/// Generate JSON Schema for CompleteConfig
911913
pub fn generate_schema() -> serde_json::Value {
912-
let schema = schema_for!(ProjectOptions);
914+
let schema = schema_for!(CompleteConfig);
913915
serde_json::to_value(schema).unwrap()
914916
}
915917

@@ -1036,7 +1038,7 @@ mod tests {
10361038
}
10371039
"#;
10381040

1039-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1041+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
10401042
assert!(config.entry.is_some());
10411043
assert!(config.output.is_some());
10421044
assert!(config.optimization.is_some());
@@ -1082,7 +1084,7 @@ mod tests {
10821084
}
10831085
}
10841086
"#;
1085-
let config: ProjectOptions = serde_json::from_str(json_true).unwrap();
1087+
let config: CompleteConfig = serde_json::from_str(json_true).unwrap();
10861088
let optimization = config.optimization.as_ref().unwrap();
10871089
assert_eq!(optimization.concatenate_modules, Some(true));
10881090

@@ -1094,7 +1096,7 @@ mod tests {
10941096
}
10951097
}
10961098
"#;
1097-
let config: ProjectOptions = serde_json::from_str(json_false).unwrap();
1099+
let config: CompleteConfig = serde_json::from_str(json_false).unwrap();
10981100
let optimization = config.optimization.as_ref().unwrap();
10991101
assert_eq!(optimization.concatenate_modules, Some(false));
11001102

@@ -1106,7 +1108,7 @@ mod tests {
11061108
}
11071109
}
11081110
"#;
1109-
let config: ProjectOptions = serde_json::from_str(json_none).unwrap();
1111+
let config: CompleteConfig = serde_json::from_str(json_none).unwrap();
11101112
let optimization = config.optimization.as_ref().unwrap();
11111113
assert_eq!(optimization.concatenate_modules, None);
11121114
}
@@ -1126,7 +1128,7 @@ mod tests {
11261128
}
11271129
}
11281130
"#;
1129-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1131+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11301132
let rules = config.module.as_ref().unwrap().rules.as_ref().unwrap();
11311133

11321134
// Check full rule
@@ -1151,14 +1153,14 @@ mod tests {
11511153
#[test]
11521154
fn test_output_type_kebab_case() {
11531155
let json = r#"{ "output": { "type": "standalone" } }"#;
1154-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1156+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11551157
assert!(matches!(
11561158
config.output.as_ref().unwrap().output_type,
11571159
Some(SchemaOutputType::Standalone)
11581160
));
11591161

11601162
let json = r#"{ "output": { "type": "export" } }"#;
1161-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1163+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11621164
assert!(matches!(
11631165
config.output.as_ref().unwrap().output_type,
11641166
Some(SchemaOutputType::Export)
@@ -1176,7 +1178,7 @@ mod tests {
11761178
}
11771179
}
11781180
"#;
1179-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1181+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11801182
let plugins = config
11811183
.experimental
11821184
.as_ref()

packages/pack/docs/features-list.json

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@
158158
},
159159
{
160160
"featureLevel2": "`node`",
161-
"featureStatus": "🟠",
162-
"featureDetails": "",
161+
"featureStatus": "",
162+
"featureDetails": "[Webpack `target` string](https://webpack.js.org/configuration/target/#string)",
163163
"remarks": ""
164164
}
165165
]
@@ -423,17 +423,6 @@
423423
}
424424
]
425425
},
426-
{
427-
"featureLevel1": "Lazy Compiling",
428-
"children": [
429-
{
430-
"featureLevel2": "",
431-
"featureStatus": "🟠",
432-
"featureDetails": "",
433-
"remarks": ""
434-
}
435-
]
436-
},
437426
{
438427
"featureLevel1": "Webpack partially compatible mode",
439428
"children": [
@@ -518,8 +507,8 @@
518507
"children": [
519508
{
520509
"featureLevel2": "",
521-
"featureStatus": "🟠",
522-
"featureDetails": "",
510+
"featureStatus": "",
511+
"featureDetails": "Enabled on dev",
523512
"remarks": ""
524513
}
525514
]

packages/pack/docs/features-list.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
| | `copy` || [Mako `config.copy`](https://makojs.dev/docs/config#copy) | |
2727
| | `standalone` || | |
2828
| Target | `browserslist` || [Webpack `target` string](https://webpack.js.org/configuration/target/#string) | |
29-
| | `node` | 🟠 | | |
29+
| | `node` | | [Webpack `target` string](https://webpack.js.org/configuration/target/#string) | |
3030
| Sourcemap | || [Webpack `devtool` configuration](https://webpack.js.org/configuration/devtool/) | |
3131
| Define | || [Webpack `DefinePlugin`](https://webpack.js.org/plugins/define-plugin/) | |
3232
| Providers | || [Webpack `ProvidePlugin`](https://webpack.js.org/plugins/provide-plugin/#root) | |
@@ -58,15 +58,14 @@
5858
| Module Federation | || | |
5959
| HMR | || | |
6060
| Dev Server | || | |
61-
| Lazy Compiling | | 🟠 | | |
6261
| Webpack partially compatible mode | || [Webpack compat example](https://github.com/utooland/utoo/tree/next/examples/webpack-compat) | Made it easy to migrate from webpack-based projects |
6362
| Node Polyfill | || [Webpack Node Polyfill Plugin](https://github.com/Richienb/node-polyfill-webpack-plugin) | Automatically polyfills Node.js built-in modules for browser builds |
6463
| CSR | || | |
6564
| SSR | || | |
6665
| RSC | || | |
6766
| Server Action | || | |
6867
| Edge Runtime | || | |
69-
| Persistent Caching | | 🟠 | | |
68+
| Persistent Caching | | | Enabled on dev | |
7069
| Bundler Tracing Log | `log file` || | |
7170
| | `log viewer` | 🟠 | | |
7271

0 commit comments

Comments
 (0)