@wsxjs/wsx-vite-plugin 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wsxjs/wsx-vite-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Vite plugin for WSX Framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@babel/plugin-transform-class-static-block": "^7.28.0",
|
|
32
32
|
"@babel/preset-typescript": "^7.28.5",
|
|
33
33
|
"@babel/types": "^7.28.1",
|
|
34
|
-
"@wsxjs/wsx-core": "0.0.
|
|
34
|
+
"@wsxjs/wsx-core": "0.0.13"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/traverse": "^7.28.5",
|
|
@@ -48,6 +48,7 @@ export default function babelPluginWSXState(): PluginObj<WSXStatePluginPass> {
|
|
|
48
48
|
|
|
49
49
|
for (const member of classBody.body) {
|
|
50
50
|
// Debug: log member type
|
|
51
|
+
|
|
51
52
|
console.info(
|
|
52
53
|
` - Member type: ${member.type}, key: ${member.type === "ClassProperty" || member.type === "ClassPrivateProperty" ? (member.key as any)?.name : "N/A"}`
|
|
53
54
|
);
|
|
@@ -100,8 +101,24 @@ export default function babelPluginWSXState(): PluginObj<WSXStatePluginPass> {
|
|
|
100
101
|
}
|
|
101
102
|
);
|
|
102
103
|
|
|
103
|
-
if (hasStateDecorator
|
|
104
|
+
if (hasStateDecorator) {
|
|
104
105
|
const key = member.key.name;
|
|
106
|
+
|
|
107
|
+
// @state decorator requires an initial value
|
|
108
|
+
// This is opinionated: we need the value to determine if it's primitive or object/array
|
|
109
|
+
if (!member.value) {
|
|
110
|
+
throw path.buildCodeFrameError(
|
|
111
|
+
`@state decorator on property '${key}' requires an initial value.\n` +
|
|
112
|
+
`\n` +
|
|
113
|
+
`Examples:\n` +
|
|
114
|
+
` @state private ${key} = ""; // for string\n` +
|
|
115
|
+
` @state private ${key} = 0; // for number\n` +
|
|
116
|
+
` @state private ${key} = {}; // for object\n` +
|
|
117
|
+
` @state private ${key} = []; // for array\n` +
|
|
118
|
+
` @state private ${key} = undefined; // for optional\n`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
105
122
|
const initialValue = member.value as t.Expression;
|
|
106
123
|
|
|
107
124
|
// Determine if it's an object/array
|