@vizejs/babel-plugin 0.716.0 → 0.718.0
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/dist/index.cjs +9 -0
- package/dist/index.d.cts +9 -4
- package/dist/index.d.mts +9 -4
- package/dist/index.mjs +9 -0
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -26,9 +26,11 @@ convert_source_map = __toESM(convert_source_map, 1);
|
|
|
26
26
|
let _jridgewell_remapping = require("@jridgewell/remapping");
|
|
27
27
|
_jridgewell_remapping = __toESM(_jridgewell_remapping, 1);
|
|
28
28
|
//#region src/ast.ts
|
|
29
|
+
/** Narrows a structurally typed value to a Babel-compatible AST node. */
|
|
29
30
|
function isNode(value) {
|
|
30
31
|
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
31
32
|
}
|
|
33
|
+
/** Reports whether a Babel AST contains JSX syntax. */
|
|
32
34
|
function hasJsx(ast, keys) {
|
|
33
35
|
const pending = [ast];
|
|
34
36
|
while (pending.length > 0) {
|
|
@@ -43,6 +45,7 @@ function hasJsx(ast, keys) {
|
|
|
43
45
|
}
|
|
44
46
|
return false;
|
|
45
47
|
}
|
|
48
|
+
/** Enables parser plugins implied by a JavaScript or TypeScript filename. */
|
|
46
49
|
function enableSyntax(filename, parser) {
|
|
47
50
|
const plugins = parser.plugins ??= [];
|
|
48
51
|
const has = (name) => plugins.some((p) => (Array.isArray(p) ? p[0] : p) === name);
|
|
@@ -102,6 +105,7 @@ function getCompiler() {
|
|
|
102
105
|
}
|
|
103
106
|
//#endregion
|
|
104
107
|
//#region src/options.ts
|
|
108
|
+
/** Validates Babel adapter options and materializes every default. */
|
|
105
109
|
function normalizeOptions(value) {
|
|
106
110
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError("Vize Babel options must be an object");
|
|
107
111
|
for (const key of Object.keys(value)) if (![
|
|
@@ -149,6 +153,7 @@ function captureReservations(file) {
|
|
|
149
153
|
authoredBindings
|
|
150
154
|
};
|
|
151
155
|
}
|
|
156
|
+
/** Restores identifiers reserved by earlier Babel hooks after native recompilation. */
|
|
152
157
|
function restoreReservations(file, reserved) {
|
|
153
158
|
if (!reserved) return;
|
|
154
159
|
const names = new Set(reserved.names);
|
|
@@ -165,6 +170,7 @@ function restoreReservations(file, reserved) {
|
|
|
165
170
|
}
|
|
166
171
|
//#endregion
|
|
167
172
|
//#region src/source-map.ts
|
|
173
|
+
/** Composes native compiler mappings with the map already owned by Babel. */
|
|
168
174
|
function composeInputMap(nativeMap, printedMap) {
|
|
169
175
|
if (!nativeMap || !printedMap) throw new Error("The native JSX compiler did not provide the requested original-source map");
|
|
170
176
|
const parsed = JSON.parse(nativeMap);
|
|
@@ -174,9 +180,11 @@ function composeInputMap(nativeMap, printedMap) {
|
|
|
174
180
|
}
|
|
175
181
|
//#endregion
|
|
176
182
|
//#region src/sfc.ts
|
|
183
|
+
/** Reports whether a source filename denotes a Vue SFC. */
|
|
177
184
|
function isVueSfc(filename) {
|
|
178
185
|
return /\.vue$/iu.test(filename);
|
|
179
186
|
}
|
|
187
|
+
/** Compiles one Vue SFC into the structurally typed Babel AST contract. */
|
|
180
188
|
function compileSfcForBabel(source, filename, parserOptions, parse, options) {
|
|
181
189
|
const native = getCompiler();
|
|
182
190
|
const scopeId = native.generateSfcScopeId(filename, options.root, options.isProduction, source);
|
|
@@ -211,6 +219,7 @@ function compileSfcForBabel(source, filename, parserOptions, parse, options) {
|
|
|
211
219
|
}
|
|
212
220
|
};
|
|
213
221
|
}
|
|
222
|
+
/** Replaces a Babel file's source, map, metadata, and warnings with compiled SFC output. */
|
|
214
223
|
function installSfcFileState(file, compiled) {
|
|
215
224
|
file.code = compiled.code;
|
|
216
225
|
if (file.opts.sourceMaps) {
|
package/dist/index.d.cts
CHANGED
|
@@ -3,18 +3,22 @@ import { JsxCompileResultNapi, StyleBlockNapi } from "@vizejs/native";
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/** JSX output defaults; component directive prologues can select another mode. */
|
|
5
5
|
interface VizeBabelOptions {
|
|
6
|
+
/** JSX lowering mode used unless a component directive overrides it. @default "vdom" */
|
|
6
7
|
jsxMode?: "vdom" | "vapor";
|
|
8
|
+
/** Compatibility strategy used for Babel-owned JSX transforms. @default "native" */
|
|
7
9
|
jsxCompat?: "native" | "babel";
|
|
10
|
+
/** Emit server-rendering output. @default false */
|
|
8
11
|
ssr?: boolean;
|
|
9
|
-
/** Explicitly hand extracted CSS to a bundler through Babel file metadata. */
|
|
12
|
+
/** Explicitly hand extracted CSS to a bundler through Babel file metadata. @default "error" */
|
|
10
13
|
scopedStyles?: "error" | "metadata";
|
|
11
|
-
/** How standalone Babel transforms handle Vue SFC style blocks. */
|
|
14
|
+
/** How standalone Babel transforms handle Vue SFC style blocks. @default "inject" */
|
|
12
15
|
sfcStyles?: "inject" | "metadata" | "error";
|
|
13
|
-
/** Root used to make SFC scope IDs stable across machines. */
|
|
16
|
+
/** Root used to make SFC scope IDs stable across machines. @default process.cwd() */
|
|
14
17
|
root?: string;
|
|
15
|
-
/** Enables production SFC output and content-sensitive production scope IDs. */
|
|
18
|
+
/** Enables production SFC output and content-sensitive production scope IDs. @default NODE_ENV === "production" */
|
|
16
19
|
isProduction?: boolean;
|
|
17
20
|
}
|
|
21
|
+
/** Metadata recorded for a native JSX transform. */
|
|
18
22
|
interface VizeBabelMetadata {
|
|
19
23
|
defaultMode: "vdom" | "vapor";
|
|
20
24
|
ssr: boolean;
|
|
@@ -22,6 +26,7 @@ interface VizeBabelMetadata {
|
|
|
22
26
|
warnings: string[];
|
|
23
27
|
scopedStyles: JsxCompileResultNapi["scopedStyles"];
|
|
24
28
|
}
|
|
29
|
+
/** Metadata recorded for a native SFC transform. */
|
|
25
30
|
interface VizeBabelSfcMetadata {
|
|
26
31
|
defaultMode: "vdom" | "vapor";
|
|
27
32
|
ssr: boolean;
|
package/dist/index.d.mts
CHANGED
|
@@ -3,18 +3,22 @@ import { JsxCompileResultNapi, StyleBlockNapi } from "@vizejs/native";
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
4
|
/** JSX output defaults; component directive prologues can select another mode. */
|
|
5
5
|
interface VizeBabelOptions {
|
|
6
|
+
/** JSX lowering mode used unless a component directive overrides it. @default "vdom" */
|
|
6
7
|
jsxMode?: "vdom" | "vapor";
|
|
8
|
+
/** Compatibility strategy used for Babel-owned JSX transforms. @default "native" */
|
|
7
9
|
jsxCompat?: "native" | "babel";
|
|
10
|
+
/** Emit server-rendering output. @default false */
|
|
8
11
|
ssr?: boolean;
|
|
9
|
-
/** Explicitly hand extracted CSS to a bundler through Babel file metadata. */
|
|
12
|
+
/** Explicitly hand extracted CSS to a bundler through Babel file metadata. @default "error" */
|
|
10
13
|
scopedStyles?: "error" | "metadata";
|
|
11
|
-
/** How standalone Babel transforms handle Vue SFC style blocks. */
|
|
14
|
+
/** How standalone Babel transforms handle Vue SFC style blocks. @default "inject" */
|
|
12
15
|
sfcStyles?: "inject" | "metadata" | "error";
|
|
13
|
-
/** Root used to make SFC scope IDs stable across machines. */
|
|
16
|
+
/** Root used to make SFC scope IDs stable across machines. @default process.cwd() */
|
|
14
17
|
root?: string;
|
|
15
|
-
/** Enables production SFC output and content-sensitive production scope IDs. */
|
|
18
|
+
/** Enables production SFC output and content-sensitive production scope IDs. @default NODE_ENV === "production" */
|
|
16
19
|
isProduction?: boolean;
|
|
17
20
|
}
|
|
21
|
+
/** Metadata recorded for a native JSX transform. */
|
|
18
22
|
interface VizeBabelMetadata {
|
|
19
23
|
defaultMode: "vdom" | "vapor";
|
|
20
24
|
ssr: boolean;
|
|
@@ -22,6 +26,7 @@ interface VizeBabelMetadata {
|
|
|
22
26
|
warnings: string[];
|
|
23
27
|
scopedStyles: JsxCompileResultNapi["scopedStyles"];
|
|
24
28
|
}
|
|
29
|
+
/** Metadata recorded for a native SFC transform. */
|
|
25
30
|
interface VizeBabelSfcMetadata {
|
|
26
31
|
defaultMode: "vdom" | "vapor";
|
|
27
32
|
ssr: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,11 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import convertSourceMap from "convert-source-map";
|
|
3
3
|
import remapping from "@jridgewell/remapping";
|
|
4
4
|
//#region src/ast.ts
|
|
5
|
+
/** Narrows a structurally typed value to a Babel-compatible AST node. */
|
|
5
6
|
function isNode(value) {
|
|
6
7
|
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
7
8
|
}
|
|
9
|
+
/** Reports whether a Babel AST contains JSX syntax. */
|
|
8
10
|
function hasJsx(ast, keys) {
|
|
9
11
|
const pending = [ast];
|
|
10
12
|
while (pending.length > 0) {
|
|
@@ -19,6 +21,7 @@ function hasJsx(ast, keys) {
|
|
|
19
21
|
}
|
|
20
22
|
return false;
|
|
21
23
|
}
|
|
24
|
+
/** Enables parser plugins implied by a JavaScript or TypeScript filename. */
|
|
22
25
|
function enableSyntax(filename, parser) {
|
|
23
26
|
const plugins = parser.plugins ??= [];
|
|
24
27
|
const has = (name) => plugins.some((p) => (Array.isArray(p) ? p[0] : p) === name);
|
|
@@ -78,6 +81,7 @@ function getCompiler() {
|
|
|
78
81
|
}
|
|
79
82
|
//#endregion
|
|
80
83
|
//#region src/options.ts
|
|
84
|
+
/** Validates Babel adapter options and materializes every default. */
|
|
81
85
|
function normalizeOptions(value) {
|
|
82
86
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError("Vize Babel options must be an object");
|
|
83
87
|
for (const key of Object.keys(value)) if (![
|
|
@@ -125,6 +129,7 @@ function captureReservations(file) {
|
|
|
125
129
|
authoredBindings
|
|
126
130
|
};
|
|
127
131
|
}
|
|
132
|
+
/** Restores identifiers reserved by earlier Babel hooks after native recompilation. */
|
|
128
133
|
function restoreReservations(file, reserved) {
|
|
129
134
|
if (!reserved) return;
|
|
130
135
|
const names = new Set(reserved.names);
|
|
@@ -141,6 +146,7 @@ function restoreReservations(file, reserved) {
|
|
|
141
146
|
}
|
|
142
147
|
//#endregion
|
|
143
148
|
//#region src/source-map.ts
|
|
149
|
+
/** Composes native compiler mappings with the map already owned by Babel. */
|
|
144
150
|
function composeInputMap(nativeMap, printedMap) {
|
|
145
151
|
if (!nativeMap || !printedMap) throw new Error("The native JSX compiler did not provide the requested original-source map");
|
|
146
152
|
const parsed = JSON.parse(nativeMap);
|
|
@@ -150,9 +156,11 @@ function composeInputMap(nativeMap, printedMap) {
|
|
|
150
156
|
}
|
|
151
157
|
//#endregion
|
|
152
158
|
//#region src/sfc.ts
|
|
159
|
+
/** Reports whether a source filename denotes a Vue SFC. */
|
|
153
160
|
function isVueSfc(filename) {
|
|
154
161
|
return /\.vue$/iu.test(filename);
|
|
155
162
|
}
|
|
163
|
+
/** Compiles one Vue SFC into the structurally typed Babel AST contract. */
|
|
156
164
|
function compileSfcForBabel(source, filename, parserOptions, parse, options) {
|
|
157
165
|
const native = getCompiler();
|
|
158
166
|
const scopeId = native.generateSfcScopeId(filename, options.root, options.isProduction, source);
|
|
@@ -187,6 +195,7 @@ function compileSfcForBabel(source, filename, parserOptions, parse, options) {
|
|
|
187
195
|
}
|
|
188
196
|
};
|
|
189
197
|
}
|
|
198
|
+
/** Replaces a Babel file's source, map, metadata, and warnings with compiled SFC output. */
|
|
190
199
|
function installSfcFileState(file, compiled) {
|
|
191
200
|
file.code = compiled.code;
|
|
192
201
|
if (file.opts.sourceMaps) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/babel-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.718.0",
|
|
4
4
|
"description": "Vue JSX and TSX compilation through the shared Vize compiler",
|
|
5
5
|
"homepage": "https://github.com/ubugeeei-prod/vize",
|
|
6
6
|
"bugs": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@jridgewell/remapping": "2.3.5",
|
|
40
|
-
"@vizejs/native": "0.
|
|
40
|
+
"@vizejs/native": "0.718.0",
|
|
41
41
|
"convert-source-map": "2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "8.0
|
|
44
|
+
"@babel/core": "8.1.0",
|
|
45
45
|
"@types/convert-source-map": "2.0.3",
|
|
46
46
|
"@types/node": "25.9.2",
|
|
47
|
-
"playwright": "1.
|
|
47
|
+
"playwright": "1.65.0",
|
|
48
48
|
"typescript": "6.0.3",
|
|
49
49
|
"vite-plus": "0.1.24",
|
|
50
50
|
"vue": "3.6.0-rc.11"
|