Skip to content

Commit afd1dc0

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 afd1dc0

4 files changed

Lines changed: 1423 additions & 29 deletions

File tree

crates/pack-schema/src/lib.rs

Lines changed: 11 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")]
@@ -907,9 +907,9 @@ pub struct SchemaExperimentalConfig {
907907
// Schema generation
908908
// ---------------------------------------------------------------------------
909909

910-
/// Generate JSON Schema for ProjectOptions
910+
/// Generate JSON Schema for CompleteConfig
911911
pub fn generate_schema() -> serde_json::Value {
912-
let schema = schema_for!(ProjectOptions);
912+
let schema = schema_for!(CompleteConfig);
913913
serde_json::to_value(schema).unwrap()
914914
}
915915

@@ -1036,7 +1036,7 @@ mod tests {
10361036
}
10371037
"#;
10381038

1039-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1039+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
10401040
assert!(config.entry.is_some());
10411041
assert!(config.output.is_some());
10421042
assert!(config.optimization.is_some());
@@ -1082,7 +1082,7 @@ mod tests {
10821082
}
10831083
}
10841084
"#;
1085-
let config: ProjectOptions = serde_json::from_str(json_true).unwrap();
1085+
let config: CompleteConfig = serde_json::from_str(json_true).unwrap();
10861086
let optimization = config.optimization.as_ref().unwrap();
10871087
assert_eq!(optimization.concatenate_modules, Some(true));
10881088

@@ -1094,7 +1094,7 @@ mod tests {
10941094
}
10951095
}
10961096
"#;
1097-
let config: ProjectOptions = serde_json::from_str(json_false).unwrap();
1097+
let config: CompleteConfig = serde_json::from_str(json_false).unwrap();
10981098
let optimization = config.optimization.as_ref().unwrap();
10991099
assert_eq!(optimization.concatenate_modules, Some(false));
11001100

@@ -1106,7 +1106,7 @@ mod tests {
11061106
}
11071107
}
11081108
"#;
1109-
let config: ProjectOptions = serde_json::from_str(json_none).unwrap();
1109+
let config: CompleteConfig = serde_json::from_str(json_none).unwrap();
11101110
let optimization = config.optimization.as_ref().unwrap();
11111111
assert_eq!(optimization.concatenate_modules, None);
11121112
}
@@ -1126,7 +1126,7 @@ mod tests {
11261126
}
11271127
}
11281128
"#;
1129-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1129+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11301130
let rules = config.module.as_ref().unwrap().rules.as_ref().unwrap();
11311131

11321132
// Check full rule
@@ -1151,14 +1151,14 @@ mod tests {
11511151
#[test]
11521152
fn test_output_type_kebab_case() {
11531153
let json = r#"{ "output": { "type": "standalone" } }"#;
1154-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1154+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11551155
assert!(matches!(
11561156
config.output.as_ref().unwrap().output_type,
11571157
Some(SchemaOutputType::Standalone)
11581158
));
11591159

11601160
let json = r#"{ "output": { "type": "export" } }"#;
1161-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1161+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11621162
assert!(matches!(
11631163
config.output.as_ref().unwrap().output_type,
11641164
Some(SchemaOutputType::Export)
@@ -1176,7 +1176,7 @@ mod tests {
11761176
}
11771177
}
11781178
"#;
1179-
let config: ProjectOptions = serde_json::from_str(json).unwrap();
1179+
let config: CompleteConfig = serde_json::from_str(json).unwrap();
11801180
let plugins = config
11811181
.experimental
11821182
.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)