unplugin-jsx-source 0.1.4 → 0.2.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.
Files changed (58) hide show
  1. package/README.md +39 -27
  2. package/dist/astro.cjs +4 -4
  3. package/dist/astro.d.cts +1 -2
  4. package/dist/astro.d.ts +1 -2
  5. package/dist/astro.js +3 -3
  6. package/dist/{chunk-P7PSQAUX.js → chunk-4TPYADMJ.js} +1 -1
  7. package/dist/{chunk-OWKZWNFL.js → chunk-B4TVXNJS.js} +1 -1
  8. package/dist/{chunk-YVXKU3SI.cjs → chunk-GDAWXUM7.cjs} +2 -2
  9. package/dist/chunk-K22ONW6P.cjs +149 -0
  10. package/dist/{chunk-UDE6GQN2.js → chunk-MULGLTCU.js} +4 -3
  11. package/dist/chunk-PSEGIIIQ.js +149 -0
  12. package/dist/{chunk-DDZ7JYP2.cjs → chunk-TVLQJOF2.cjs} +4 -4
  13. package/dist/{chunk-P5ROQE6I.cjs → chunk-WGYVTTK2.cjs} +2 -2
  14. package/dist/{chunk-PEWMSEKB.js → chunk-X4WJLBNU.js} +2 -2
  15. package/dist/{chunk-KCM5BTMP.cjs → chunk-YA35MEVK.cjs} +4 -3
  16. package/dist/esbuild.cjs +4 -4
  17. package/dist/esbuild.d.cts +1 -2
  18. package/dist/esbuild.d.ts +1 -2
  19. package/dist/esbuild.js +3 -3
  20. package/dist/farm.cjs +4 -4
  21. package/dist/farm.d.cts +1 -2
  22. package/dist/farm.d.ts +1 -2
  23. package/dist/farm.js +3 -3
  24. package/dist/index.cjs +4 -4
  25. package/dist/index.d.cts +4 -3
  26. package/dist/index.d.ts +1 -2
  27. package/dist/index.js +3 -3
  28. package/dist/nuxt.cjs +7 -7
  29. package/dist/nuxt.d.cts +4 -3
  30. package/dist/nuxt.d.ts +1 -2
  31. package/dist/nuxt.js +5 -5
  32. package/dist/options.cjs +2 -2
  33. package/dist/options.d.cts +15 -4
  34. package/dist/options.d.ts +15 -4
  35. package/dist/options.js +1 -1
  36. package/dist/rollup.cjs +4 -4
  37. package/dist/rollup.d.cts +1 -2
  38. package/dist/rollup.d.ts +1 -2
  39. package/dist/rollup.js +3 -3
  40. package/dist/rspack.cjs +4 -4
  41. package/dist/rspack.d.cts +1 -2
  42. package/dist/rspack.d.ts +1 -2
  43. package/dist/rspack.js +3 -3
  44. package/dist/transform.cjs +2 -2
  45. package/dist/transform.d.cts +4 -4
  46. package/dist/transform.d.ts +4 -4
  47. package/dist/transform.js +1 -1
  48. package/dist/vite.cjs +5 -5
  49. package/dist/vite.d.cts +2 -4
  50. package/dist/vite.d.ts +2 -4
  51. package/dist/vite.js +4 -4
  52. package/dist/webpack.cjs +5 -5
  53. package/dist/webpack.d.cts +1 -2
  54. package/dist/webpack.d.ts +1 -2
  55. package/dist/webpack.js +4 -4
  56. package/package.json +59 -59
  57. package/dist/chunk-I5SBNPWQ.js +0 -66
  58. package/dist/chunk-QR273UPS.cjs +0 -66
package/package.json CHANGED
@@ -1,30 +1,44 @@
1
1
  {
2
2
  "name": "unplugin-jsx-source",
3
- "type": "module",
4
- "version": "0.1.4",
3
+ "version": "0.2.0",
5
4
  "description": "",
6
- "license": "MIT",
7
- "homepage": "https://github.com/astahmer/unplugin-jsx-source#readme",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/astahmer/unplugin-jsx-source.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/astahmer/unplugin-jsx-source/issues"
14
- },
15
5
  "keywords": [
16
- "unplugin",
17
- "jsx",
18
- "source",
6
+ "annotate",
19
7
  "data-at",
20
8
  "data-source",
21
- "annotate",
22
9
  "devtools",
23
- "vite",
24
- "webpack",
10
+ "jsx",
25
11
  "rollup",
26
- "transform"
12
+ "source",
13
+ "transform",
14
+ "unplugin",
15
+ "vite",
16
+ "webpack"
17
+ ],
18
+ "homepage": "https://github.com/astahmer/unplugin-jsx-source#readme",
19
+ "bugs": {
20
+ "url": "https://github.com/astahmer/unplugin-jsx-source/issues"
21
+ },
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/astahmer/unplugin-jsx-source.git"
26
+ },
27
+ "files": [
28
+ "dist"
27
29
  ],
30
+ "type": "module",
31
+ "main": "dist/index.cjs",
32
+ "module": "dist/index.js",
33
+ "types": "dist/index.d.ts",
34
+ "typesVersions": {
35
+ "*": {
36
+ "*": [
37
+ "./dist/*",
38
+ "./*"
39
+ ]
40
+ }
41
+ },
28
42
  "exports": {
29
43
  ".": {
30
44
  "import": "./dist/index.js",
@@ -68,20 +82,29 @@
68
82
  },
69
83
  "./*": "./*"
70
84
  },
71
- "main": "dist/index.cjs",
72
- "module": "dist/index.js",
73
- "types": "dist/index.d.ts",
74
- "typesVersions": {
75
- "*": {
76
- "*": [
77
- "./dist/*",
78
- "./*"
79
- ]
80
- }
85
+ "dependencies": {
86
+ "@oxc-project/types": "^0.121.0",
87
+ "magic-string": "^0.30.21",
88
+ "oxc-parser": "^0.121.0",
89
+ "unplugin": "^3.0.0",
90
+ "unplugin-utils": "^0.3.1"
91
+ },
92
+ "devDependencies": {
93
+ "@nuxt/kit": "^4.4.2",
94
+ "@nuxt/schema": "^4.4.2",
95
+ "@types/node": "^25.5.0",
96
+ "bumpp": "^11.0.1",
97
+ "nodemon": "^3.1.14",
98
+ "oxfmt": "^0.42.0",
99
+ "oxlint": "^1.57.0",
100
+ "rollup": "^4.60.0",
101
+ "tsup": "^8.5.1",
102
+ "tsx": "^4.21.0",
103
+ "typescript": "^6.0.2",
104
+ "vite": "^8.0.3",
105
+ "vitest": "^4.1.1",
106
+ "webpack": "^5.105.4"
81
107
  },
82
- "files": [
83
- "dist"
84
- ],
85
108
  "peerDependencies": {
86
109
  "@farmfe/core": ">=1",
87
110
  "@nuxt/kit": "^3",
@@ -114,38 +137,15 @@
114
137
  "optional": true
115
138
  }
116
139
  },
117
- "dependencies": {
118
- "@babel/generator": "^7.26.9",
119
- "@babel/parser": "^7.26.9",
120
- "@babel/traverse": "^7.26.9",
121
- "@babel/types": "^7.26.9",
122
- "unplugin": "^2.1.2",
123
- "unplugin-utils": "^0.2.4"
124
- },
125
- "devDependencies": {
126
- "@antfu/eslint-config": "^4.2.0",
127
- "@biomejs/biome": "1.9.4",
128
- "@nuxt/kit": "^3.15.4",
129
- "@nuxt/schema": "^3.15.4",
130
- "@types/babel__generator": "^7.6.8",
131
- "@types/babel__traverse": "^7.20.6",
132
- "@types/node": "^22.13.1",
133
- "bumpp": "^10.0.2",
134
- "eslint": "^9.20.0",
135
- "nodemon": "^3.1.9",
136
- "rollup": "^4.34.6",
137
- "tsup": "^8.3.6",
138
- "tsx": "^4.19.2",
139
- "typescript": "^5.7.3",
140
- "vite": "^6.1.0",
141
- "vitest": "^3.0.5",
142
- "webpack": "^5.97.1"
140
+ "engines": {
141
+ "node": "^20.19.0 || >=22.12.0"
143
142
  },
144
143
  "scripts": {
145
144
  "build": "tsup",
146
145
  "dev": "tsup --watch src",
147
- "lint": "eslint .",
148
- "play": "npm -C playground run dev",
146
+ "fmt": "oxfmt --write .",
147
+ "lint": "oxlint . && oxfmt --check .",
148
+ "play": "pnpm -C playground run dev",
149
149
  "release": "bumpp && pnpm publish",
150
150
  "start": "tsx src/index.ts",
151
151
  "test": "vitest"
@@ -1,66 +0,0 @@
1
- import {
2
- __spreadValues
3
- } from "./chunk-5JBD5THX.js";
4
-
5
- // src/transform.ts
6
- import { parse } from "@babel/parser";
7
- import _traverse from "@babel/traverse";
8
- import _generate from "@babel/generator";
9
- import * as t from "@babel/types";
10
- var traverse = _traverse.default || _traverse;
11
- var generate = _generate.default || _generate;
12
- var transform = (code, id, opt) => {
13
- const ast = parse(code, __spreadValues({
14
- sourceType: "module",
15
- plugins: ["jsx", "typescript"]
16
- }, opt.parserOptions));
17
- traverse(ast, {
18
- JSXOpeningElement(path) {
19
- if (path.node.name.type === "JSXIdentifier" && path.node.loc && !path.isJSXFragment() && path.node.name.name !== "Fragment") {
20
- const newAttributes = [];
21
- if (opt.attributes.at && !path.node.attributes.some(
22
- (a) => a.type === "JSXAttribute" && a.name.name === opt.attributes.at
23
- )) {
24
- const fileName = opt.transformFileName(id, path.node.loc);
25
- const dataAtAttr = t.jsxAttribute(
26
- t.jsxIdentifier(opt.attributes.at),
27
- t.stringLiteral(fileName)
28
- );
29
- newAttributes.push(dataAtAttr);
30
- }
31
- if (opt.attributes.in && !path.node.attributes.some(
32
- (a) => a.type === "JSXAttribute" && a.name.name === opt.attributes.in
33
- )) {
34
- const assertHasName = (p) => p.isVariableDeclarator() || p.isFunctionDeclaration();
35
- const parent = path.findParent(assertHasName);
36
- if (parent && assertHasName(parent) && parent.node.id && "name" in parent.node.id) {
37
- const dataInAttr = t.jsxAttribute(
38
- t.jsxIdentifier(opt.attributes.in),
39
- t.stringLiteral(parent.node.id.name)
40
- );
41
- newAttributes.push(dataInAttr);
42
- }
43
- }
44
- if (opt.attributes.kind && !path.node.attributes.some(
45
- (a) => a.type === "JSXAttribute" && a.name.name === opt.attributes.kind
46
- ) && path.node.name.name[0].toUpperCase() === path.node.name.name[0]) {
47
- const dataKindAttr = t.jsxAttribute(
48
- t.jsxIdentifier(opt.attributes.kind),
49
- t.stringLiteral(path.node.name.name)
50
- );
51
- newAttributes.push(dataKindAttr);
52
- }
53
- path.node.attributes.push(...newAttributes);
54
- }
55
- }
56
- });
57
- const { code: transformedCode } = generate(ast, { filename: id }, code);
58
- return {
59
- code: transformedCode,
60
- map: null
61
- };
62
- };
63
-
64
- export {
65
- transform
66
- };
@@ -1,66 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
- var _chunkP4DSWCF6cjs = require('./chunk-P4DSWCF6.cjs');
4
-
5
- // src/transform.ts
6
- var _parser = require('@babel/parser');
7
- var _traverse2 = require('@babel/traverse'); var _traverse3 = _interopRequireDefault(_traverse2);
8
- var _generator = require('@babel/generator'); var _generator2 = _interopRequireDefault(_generator);
9
- var _types = require('@babel/types'); var t = _interopRequireWildcard(_types);
10
- var traverse = _traverse3.default.default || _traverse3.default;
11
- var generate = _generator2.default.default || _generator2.default;
12
- var transform = (code, id, opt) => {
13
- const ast = _parser.parse.call(void 0, code, _chunkP4DSWCF6cjs.__spreadValues.call(void 0, {
14
- sourceType: "module",
15
- plugins: ["jsx", "typescript"]
16
- }, opt.parserOptions));
17
- traverse(ast, {
18
- JSXOpeningElement(path) {
19
- if (path.node.name.type === "JSXIdentifier" && path.node.loc && !path.isJSXFragment() && path.node.name.name !== "Fragment") {
20
- const newAttributes = [];
21
- if (opt.attributes.at && !path.node.attributes.some(
22
- (a) => a.type === "JSXAttribute" && a.name.name === opt.attributes.at
23
- )) {
24
- const fileName = opt.transformFileName(id, path.node.loc);
25
- const dataAtAttr = t.jsxAttribute(
26
- t.jsxIdentifier(opt.attributes.at),
27
- t.stringLiteral(fileName)
28
- );
29
- newAttributes.push(dataAtAttr);
30
- }
31
- if (opt.attributes.in && !path.node.attributes.some(
32
- (a) => a.type === "JSXAttribute" && a.name.name === opt.attributes.in
33
- )) {
34
- const assertHasName = (p) => p.isVariableDeclarator() || p.isFunctionDeclaration();
35
- const parent = path.findParent(assertHasName);
36
- if (parent && assertHasName(parent) && parent.node.id && "name" in parent.node.id) {
37
- const dataInAttr = t.jsxAttribute(
38
- t.jsxIdentifier(opt.attributes.in),
39
- t.stringLiteral(parent.node.id.name)
40
- );
41
- newAttributes.push(dataInAttr);
42
- }
43
- }
44
- if (opt.attributes.kind && !path.node.attributes.some(
45
- (a) => a.type === "JSXAttribute" && a.name.name === opt.attributes.kind
46
- ) && path.node.name.name[0].toUpperCase() === path.node.name.name[0]) {
47
- const dataKindAttr = t.jsxAttribute(
48
- t.jsxIdentifier(opt.attributes.kind),
49
- t.stringLiteral(path.node.name.name)
50
- );
51
- newAttributes.push(dataKindAttr);
52
- }
53
- path.node.attributes.push(...newAttributes);
54
- }
55
- }
56
- });
57
- const { code: transformedCode } = generate(ast, { filename: id }, code);
58
- return {
59
- code: transformedCode,
60
- map: null
61
- };
62
- };
63
-
64
-
65
-
66
- exports.transform = transform;