@unocss/transformer-attributify-jsx 66.6.1 → 66.6.3

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.
Files changed (2) hide show
  1. package/dist/index.mjs +14 -17
  2. package/package.json +4 -5
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { toArray } from "@unocss/core";
2
- import { parse } from "@babel/parser";
3
- import _traverse from "@babel/traverse";
2
+ import { parseSync } from "oxc-parser";
3
+ import { walk } from "oxc-walker";
4
4
 
5
5
  //#region ../../virtual-shared/integration/src/env.ts
6
6
  function getEnvFlags() {
@@ -13,22 +13,19 @@ function getEnvFlags() {
13
13
  }
14
14
 
15
15
  //#endregion
16
- //#region src/resolver/babel.ts
17
- const traverse = _traverse.default || _traverse;
18
- async function attributifyJsxBabelResolver(params) {
19
- const { code, uno, isBlocked } = params;
16
+ //#region src/resolver/oxc.ts
17
+ async function attributifyJsxOxcResolver(params) {
18
+ const { code, id, uno, isBlocked } = params;
20
19
  const tasks = [];
21
- const ast = parse(code.toString(), {
22
- sourceType: "module",
23
- plugins: ["jsx", "typescript"]
24
- });
25
- if (ast.errors?.length) throw new Error(`Babel parse errors:\n${ast.errors.join("\n")}`);
26
- traverse(ast, { JSXAttribute(path) {
27
- if (path.node.value === null) {
28
- const attr = path.node.name.type === "JSXNamespacedName" ? `${path.node.name.namespace.name}:${path.node.name.name.name}` : path.node.name.name;
20
+ const ast = parseSync(id, code.toString(), { sourceType: "module" });
21
+ if (ast.errors?.length) throw new Error(`Oxc parse errors:\n${ast.errors.join("\n")}`);
22
+ walk(ast.program, { enter(node) {
23
+ if (node.type !== "JSXAttribute") return;
24
+ if (node.value === null) {
25
+ const attr = node.name.type === "JSXNamespacedName" ? `${node.name.namespace.name}:${node.name.name.name}` : node.name.name;
29
26
  if (isBlocked(attr)) return;
30
27
  tasks.push(uno.parseToken(attr).then((matched) => {
31
- if (matched) code.appendRight(path.node.end, "=\"\"");
28
+ if (matched) code.appendRight(node.end, "=\"\"");
32
29
  }));
33
30
  }
34
31
  } });
@@ -109,9 +106,9 @@ function transformerAttributifyJsx(options = {}) {
109
106
  isBlocked
110
107
  };
111
108
  try {
112
- await attributifyJsxBabelResolver(params);
109
+ await attributifyJsxOxcResolver(params);
113
110
  } catch (error) {
114
- console.warn(`[@unocss/transformer-attributify-jsx]: Babel resolver failed for "${id}", falling back to regex resolver:`, error);
111
+ console.warn(`[@unocss/transformer-attributify-jsx]: Oxc resolver failed for "${id}", falling back to regex resolver:`, error);
115
112
  await attributifyJsxRegexResolver(params);
116
113
  }
117
114
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/transformer-attributify-jsx",
3
3
  "type": "module",
4
- "version": "66.6.1",
4
+ "version": "66.6.3",
5
5
  "description": "Support valueless attributify in JSX/TSX.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -29,12 +29,11 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@babel/parser": "7.27.7",
33
- "@babel/traverse": "7.27.7",
34
- "@unocss/core": "66.6.1"
32
+ "oxc-parser": "^0.115.0",
33
+ "oxc-walker": "^0.7.0",
34
+ "@unocss/core": "66.6.3"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/babel__traverse": "^7.28.0",
38
37
  "magic-string": "^0.30.21"
39
38
  },
40
39
  "scripts": {