@dom-expressions/jsx-compiler 0.50.0-next.16 → 0.50.0-next.17
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/index.js +20 -56
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -13,12 +13,6 @@ function transform(code, options) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const nativeOptions = validateOptions(code, options);
|
|
16
|
-
if (nativeOptions?.skip) {
|
|
17
|
-
return {
|
|
18
|
-
code,
|
|
19
|
-
map: null
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
16
|
const result = native.transform(code, nativeOptions);
|
|
23
17
|
return {
|
|
24
18
|
code: result.code,
|
|
@@ -46,6 +40,8 @@ const nativeOptionKeys = new Set([
|
|
|
46
40
|
"effectWrapper",
|
|
47
41
|
"wrapConditionals",
|
|
48
42
|
"memoWrapper",
|
|
43
|
+
"requireImportSource",
|
|
44
|
+
"validate",
|
|
49
45
|
"staticMarker",
|
|
50
46
|
"omitNestedClosingTags",
|
|
51
47
|
"omitLastClosingTag",
|
|
@@ -63,63 +59,40 @@ function validateOptions(code, options) {
|
|
|
63
59
|
);
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
const wrapperless = options.wrapConditionals === false || options.memoWrapper === false;
|
|
67
|
-
if (wrapperless) {
|
|
68
|
-
if (options.wrapConditionals !== false || options.memoWrapper !== false) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
"@dom-expressions/jsx-compiler only supports wrapperless mode when `wrapConditionals: false` and `memoWrapper: false` are used together"
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
62
|
const nativeOptions = {};
|
|
76
63
|
for (const [key, value] of Object.entries(options)) {
|
|
77
|
-
if (key === "
|
|
78
|
-
if (value
|
|
79
|
-
if (typeof value !== "string") {
|
|
64
|
+
if (key === "effectWrapper" || key === "memoWrapper") {
|
|
65
|
+
if (typeof value !== "string" && typeof value !== "boolean") {
|
|
80
66
|
throw new TypeError(
|
|
81
|
-
|
|
67
|
+
`@dom-expressions/jsx-compiler \`${key}\` option must be a string import name or false`
|
|
82
68
|
);
|
|
83
69
|
}
|
|
84
|
-
|
|
85
|
-
return { skip: true };
|
|
86
|
-
}
|
|
70
|
+
nativeOptions[key] = value;
|
|
87
71
|
continue;
|
|
88
72
|
}
|
|
89
|
-
if (key === "
|
|
90
|
-
if (value
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
if (key === "requireImportSource") {
|
|
74
|
+
if (value !== false && typeof value !== "string") {
|
|
75
|
+
throw new TypeError(
|
|
76
|
+
"@dom-expressions/jsx-compiler `requireImportSource` option must be false or a string"
|
|
77
|
+
);
|
|
94
78
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
79
|
+
if (value !== false) nativeOptions.requireImportSource = value;
|
|
80
|
+
continue;
|
|
98
81
|
}
|
|
99
82
|
if (key === "wrapConditionals") {
|
|
100
|
-
if (value
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
throw new TypeError(
|
|
106
|
-
"@dom-expressions/jsx-compiler `wrapConditionals` option must be boolean"
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
if (key === "memoWrapper") {
|
|
110
|
-
if (value === "memo") continue;
|
|
111
|
-
if (value === false) {
|
|
112
|
-
nativeOptions.memoWrapper = false;
|
|
113
|
-
continue;
|
|
83
|
+
if (typeof value !== "boolean") {
|
|
84
|
+
throw new TypeError(
|
|
85
|
+
"@dom-expressions/jsx-compiler `wrapConditionals` option must be boolean"
|
|
86
|
+
);
|
|
114
87
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
);
|
|
88
|
+
nativeOptions.wrapConditionals = value;
|
|
89
|
+
continue;
|
|
118
90
|
}
|
|
119
91
|
if (key === "validate") {
|
|
120
92
|
if (typeof value !== "boolean") {
|
|
121
93
|
throw new TypeError("@dom-expressions/jsx-compiler `validate` option must be boolean");
|
|
122
94
|
}
|
|
95
|
+
nativeOptions.validate = value;
|
|
123
96
|
continue;
|
|
124
97
|
}
|
|
125
98
|
if (nativeOptionKeys.has(key)) {
|
|
@@ -139,15 +112,6 @@ function validateOptions(code, options) {
|
|
|
139
112
|
return nativeOptions;
|
|
140
113
|
}
|
|
141
114
|
|
|
142
|
-
function hasJsxImportSource(code, source) {
|
|
143
|
-
const pattern = /@jsxImportSource\s+([^\s*]+)/g;
|
|
144
|
-
let match;
|
|
145
|
-
while ((match = pattern.exec(code))) {
|
|
146
|
-
if (match[1] === source) return true;
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
115
|
function validateRenderers(renderers) {
|
|
152
116
|
if (renderers == null) return;
|
|
153
117
|
if (!Array.isArray(renderers)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dom-expressions/jsx-compiler",
|
|
3
3
|
"description": "A JSX to DOM Expressions compiler implemented with Oxc",
|
|
4
|
-
"version": "0.50.0-next.
|
|
4
|
+
"version": "0.50.0-next.17",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@napi-rs/cli": "^3.6.2"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@dom-expressions/jsx-compiler-darwin-x64": "0.50.0-next.
|
|
42
|
-
"@dom-expressions/jsx-compiler-darwin-arm64": "0.50.0-next.
|
|
43
|
-
"@dom-expressions/jsx-compiler-linux-x64-gnu": "0.50.0-next.
|
|
44
|
-
"@dom-expressions/jsx-compiler-linux-arm64-gnu": "0.50.0-next.
|
|
45
|
-
"@dom-expressions/jsx-compiler-win32-x64-msvc": "0.50.0-next.
|
|
41
|
+
"@dom-expressions/jsx-compiler-darwin-x64": "0.50.0-next.17",
|
|
42
|
+
"@dom-expressions/jsx-compiler-darwin-arm64": "0.50.0-next.17",
|
|
43
|
+
"@dom-expressions/jsx-compiler-linux-x64-gnu": "0.50.0-next.17",
|
|
44
|
+
"@dom-expressions/jsx-compiler-linux-arm64-gnu": "0.50.0-next.17",
|
|
45
|
+
"@dom-expressions/jsx-compiler-win32-x64-msvc": "0.50.0-next.17"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "napi build --release --strip --manifest-path ./Cargo.toml",
|