rollup-plugin-react-scoped-css 0.5.0 → 0.6.1
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/.eslintrc.yml +29 -0
- package/.releaserc +3 -2
- package/README.md +36 -8
- package/dist/ast-iterator.js +5 -5
- package/dist/ast-program.d.ts +5 -0
- package/dist/ast-program.js +63 -0
- package/dist/ast-transformer.d.ts +1 -1
- package/dist/ast-transformer.js +6 -6
- package/dist/ast.utils.d.ts +32 -5
- package/dist/ast.utils.js +115 -49
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -19
- package/dist/parsers/classic-parser.js +34 -53
- package/dist/parsers/new-parser.js +52 -52
- package/package.json +13 -1
- package/.github/workflows/pull-request.yml +0 -19
- package/.github/workflows/release.yml +0 -30
- package/babel.config.js +0 -3
- package/src/__mocks__/classic-compiled-jsx-with-attr.js +0 -37
- package/src/__mocks__/classic-compiled-jsx.js +0 -31
- package/src/__mocks__/new-compiled-jsx-with-attr.js +0 -101
- package/src/__mocks__/new-compiled-jsx.js +0 -64
- package/src/__mocks__/sample-code-file.js +0 -4
- package/src/ast-iterator.spec.ts +0 -19
- package/src/ast-iterator.ts +0 -27
- package/src/ast-transformer.spec.ts +0 -20
- package/src/ast-transformer.ts +0 -24
- package/src/ast.utils.spec.ts +0 -46
- package/src/ast.utils.ts +0 -48
- package/src/index.ts +0 -144
- package/src/parsers/classic-parser.ts +0 -58
- package/src/parsers/jsx-parser.model.ts +0 -10
- package/src/parsers/new-parser.ts +0 -58
|
@@ -10,84 +10,65 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
-
if (ar || !(i in from)) {
|
|
32
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
-
};
|
|
38
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
14
|
exports.ClassicJsxParser = void 0;
|
|
15
|
+
var ast_utils_1 = require("../ast.utils");
|
|
40
16
|
var ClassicJsxParser = /** @class */ (function () {
|
|
41
17
|
function ClassicJsxParser() {
|
|
42
18
|
}
|
|
43
19
|
ClassicJsxParser.prototype.isNodeReactFragment = function (node) {
|
|
44
|
-
var _a, _b, _c, _d, _e, _f;
|
|
45
|
-
return ((
|
|
46
|
-
((
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
return ((((_b = (_a = node === null || node === void 0 ? void 0 : node.callee) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.name) === "React" ||
|
|
22
|
+
((_e = (_d = (_c = node === null || node === void 0 ? void 0 : node.callee) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.object) === null || _e === void 0 ? void 0 : _e.name) === "_react") &&
|
|
23
|
+
((_h = (_g = (_f = node === null || node === void 0 ? void 0 : node.arguments) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.property) === null || _h === void 0 ? void 0 : _h.name) === "Fragment");
|
|
47
24
|
};
|
|
48
25
|
ClassicJsxParser.prototype.isNodeReactElement = function (node) {
|
|
49
|
-
var _a, _b, _c, _d;
|
|
50
|
-
return (node === null || node === void 0 ? void 0 : node.type) ===
|
|
51
|
-
((_b = (_a = node === null || node === void 0 ? void 0 : node.callee) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.name) ===
|
|
52
|
-
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
27
|
+
return ((node === null || node === void 0 ? void 0 : node.type) === "CallExpression" &&
|
|
28
|
+
(((_b = (_a = node === null || node === void 0 ? void 0 : node.callee) === null || _a === void 0 ? void 0 : _a.object) === null || _b === void 0 ? void 0 : _b.name) === "React" ||
|
|
29
|
+
((_e = (_d = (_c = node === null || node === void 0 ? void 0 : node.callee) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.object) === null || _e === void 0 ? void 0 : _e.name) === "_react") &&
|
|
30
|
+
((_g = (_f = node === null || node === void 0 ? void 0 : node.callee) === null || _f === void 0 ? void 0 : _f.property) === null || _g === void 0 ? void 0 : _g.name) === "createElement");
|
|
53
31
|
};
|
|
54
32
|
ClassicJsxParser.prototype.extendNodeWithAttributes = function (node, attr) {
|
|
55
33
|
var _this = this;
|
|
56
|
-
var _a;
|
|
57
|
-
var arg = (_a = node === null || node === void 0 ? void 0 : node.arguments) === null || _a === void 0 ? void 0 : _a[1];
|
|
58
34
|
return __assign(__assign({}, node), { arguments: node === null || node === void 0 ? void 0 : node.arguments.map(function (v, i) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
35
|
+
// Second argument is attributes so ignore others
|
|
36
|
+
if (i !== 1) {
|
|
37
|
+
return v;
|
|
38
|
+
}
|
|
39
|
+
var attrNode = _this.createAttributeNode(attr);
|
|
40
|
+
// If it's an object expression, extend it
|
|
41
|
+
if ((0, ast_utils_1.isNodeObjectExpression)(v)) {
|
|
42
|
+
return (0, ast_utils_1.extendObjectExpression)(v, attrNode);
|
|
43
|
+
}
|
|
44
|
+
// If it's an extender, hack into it
|
|
45
|
+
if ((0, ast_utils_1.isNodeExtender)(v)) {
|
|
46
|
+
return (0, ast_utils_1.hackIntoExtenderCallExpression)(v, attrNode);
|
|
47
|
+
}
|
|
48
|
+
// If it's an identifier, do Object.assign to be safe
|
|
49
|
+
if ((0, ast_utils_1.isNodeIdentifier)(v)) {
|
|
50
|
+
return (0, ast_utils_1.createObjectAssignCallExpressionWithIdentifier)(v, (0, ast_utils_1.createObjectExpressionWithAttr)(attrNode));
|
|
71
51
|
}
|
|
72
|
-
|
|
52
|
+
// Worst case override with
|
|
53
|
+
return (0, ast_utils_1.createObjectExpressionWithAttr)(attrNode);
|
|
73
54
|
}) });
|
|
74
55
|
};
|
|
75
56
|
ClassicJsxParser.prototype.createAttributeNode = function (attr) {
|
|
76
57
|
return {
|
|
77
|
-
type:
|
|
58
|
+
type: "Property",
|
|
78
59
|
method: false,
|
|
79
60
|
shorthand: false,
|
|
80
61
|
computed: false,
|
|
81
62
|
key: {
|
|
82
|
-
type:
|
|
83
|
-
name: "\"".concat(attr, "\"")
|
|
63
|
+
type: "Identifier",
|
|
64
|
+
name: "\"".concat(attr, "\""),
|
|
84
65
|
},
|
|
85
66
|
value: {
|
|
86
|
-
type:
|
|
67
|
+
type: "Literal",
|
|
87
68
|
value: true,
|
|
88
|
-
raw: "true"
|
|
69
|
+
raw: "true",
|
|
89
70
|
},
|
|
90
|
-
kind:
|
|
71
|
+
kind: "init",
|
|
91
72
|
};
|
|
92
73
|
};
|
|
93
74
|
return ClassicJsxParser;
|
|
@@ -10,83 +10,83 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
-
if (ar || !(i in from)) {
|
|
32
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
-
};
|
|
38
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
14
|
exports.NewJsxParser = void 0;
|
|
15
|
+
var ast_utils_1 = require("../ast.utils");
|
|
40
16
|
var NewJsxParser = /** @class */ (function () {
|
|
41
17
|
function NewJsxParser() {
|
|
42
18
|
}
|
|
43
19
|
NewJsxParser.prototype.isNodeReactFragment = function (node) {
|
|
44
|
-
var _a, _b, _c, _d;
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
|
+
// Always a call expression
|
|
22
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== "CallExpression") {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (((_b = (_a = node.arguments) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type) === "Identifier" &&
|
|
26
|
+
["_Fragment", "Fragment"].includes((_d = (_c = node.arguments) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (((_f = (_e = node.arguments) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.type) === "MemberExpression" &&
|
|
30
|
+
["_Fragment", "Fragment"].includes((_j = (_h = (_g = node.arguments) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.property) === null || _j === void 0 ? void 0 : _j.name)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
47
34
|
};
|
|
48
35
|
NewJsxParser.prototype.isNodeReactElement = function (node) {
|
|
49
|
-
var _a;
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
|
+
// Always a call expression
|
|
38
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== "CallExpression") {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (["_jsxDEV", "_jsx", "_jsxs", "jsxDev", "jsx", "jsxs"].includes((_a = node === null || node === void 0 ? void 0 : node.callee) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (((_b = node === null || node === void 0 ? void 0 : node.callee) === null || _b === void 0 ? void 0 : _b.type) === "SequenceExpression" &&
|
|
45
|
+
["_jsxDEV", "_jsx", "_jsxs", "jsxDev", "jsx", "jsxs"].includes((_f = (_e = (_d = (_c = node === null || node === void 0 ? void 0 : node.callee) === null || _c === void 0 ? void 0 : _c.expressions) === null || _d === void 0 ? void 0 : _d[1]) === null || _e === void 0 ? void 0 : _e.property) === null || _f === void 0 ? void 0 : _f.name)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
52
49
|
};
|
|
53
50
|
NewJsxParser.prototype.extendNodeWithAttributes = function (node, attr) {
|
|
54
51
|
var _this = this;
|
|
55
|
-
var _a;
|
|
56
|
-
var arg = (_a = node === null || node === void 0 ? void 0 : node.arguments) === null || _a === void 0 ? void 0 : _a[1];
|
|
57
52
|
return __assign(__assign({}, node), { arguments: node === null || node === void 0 ? void 0 : node.arguments.map(function (v, i) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
// Second argument is attributes so ignore others
|
|
54
|
+
if (i !== 1) {
|
|
55
|
+
return v;
|
|
56
|
+
}
|
|
57
|
+
var attrNode = _this.createAttributeNode(attr);
|
|
58
|
+
// If it's an object expression, extend it
|
|
59
|
+
if ((0, ast_utils_1.isNodeObjectExpression)(v)) {
|
|
60
|
+
return (0, ast_utils_1.extendObjectExpression)(v, attrNode);
|
|
61
|
+
}
|
|
62
|
+
// If it's an extender, hack into it
|
|
63
|
+
if ((0, ast_utils_1.isNodeExtender)(v)) {
|
|
64
|
+
return (0, ast_utils_1.hackIntoExtenderCallExpression)(v, attrNode);
|
|
65
|
+
}
|
|
66
|
+
// If it's an identifier, do Object.assign to be safe
|
|
67
|
+
if ((0, ast_utils_1.isNodeIdentifier)(v)) {
|
|
68
|
+
return (0, ast_utils_1.createObjectAssignCallExpressionWithIdentifier)(v, (0, ast_utils_1.createObjectExpressionWithAttr)(attrNode));
|
|
70
69
|
}
|
|
71
|
-
|
|
70
|
+
// Worst case override with
|
|
71
|
+
return (0, ast_utils_1.createObjectExpressionWithAttr)(attrNode);
|
|
72
72
|
}) });
|
|
73
73
|
};
|
|
74
74
|
NewJsxParser.prototype.createAttributeNode = function (attr) {
|
|
75
75
|
return {
|
|
76
|
-
type:
|
|
76
|
+
type: "Property",
|
|
77
77
|
method: false,
|
|
78
78
|
shorthand: false,
|
|
79
79
|
computed: false,
|
|
80
80
|
key: {
|
|
81
|
-
type:
|
|
82
|
-
name: "\"".concat(attr, "\"")
|
|
81
|
+
type: "Identifier",
|
|
82
|
+
name: "\"".concat(attr, "\""),
|
|
83
83
|
},
|
|
84
84
|
value: {
|
|
85
|
-
type:
|
|
85
|
+
type: "Literal",
|
|
86
86
|
value: true,
|
|
87
|
-
raw: "true"
|
|
87
|
+
raw: "true",
|
|
88
88
|
},
|
|
89
|
-
kind:
|
|
89
|
+
kind: "init",
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
return NewJsxParser;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup-plugin-react-scoped-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "A rollup plugin designed to allow scoped css to be run in react (Compatible with vite and rollup)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"build:watch": "tsc --watch",
|
|
10
|
+
"lint": "eslint '*/**/*.{js,jsx,ts,tsx}'",
|
|
10
11
|
"test": "jest"
|
|
11
12
|
},
|
|
12
13
|
"repository": {
|
|
@@ -39,16 +40,27 @@
|
|
|
39
40
|
"rollup": "^2.56.2"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
43
|
+
"@babel/core": "^7.16.0",
|
|
42
44
|
"@babel/preset-env": "^7.15.0",
|
|
45
|
+
"@babel/preset-react": "^7.16.0",
|
|
43
46
|
"@babel/preset-typescript": "^7.15.0",
|
|
44
47
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
45
48
|
"@semantic-release/git": "^10.0.1",
|
|
49
|
+
"@semantic-release/github": "^8.0.2",
|
|
46
50
|
"@semantic-release/npm": "^8.0.3",
|
|
47
51
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
48
52
|
"@types/escodegen": "0.0.7",
|
|
49
53
|
"@types/estree": "0.0.50",
|
|
50
54
|
"@types/jest": "^27.0.1",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
56
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
51
57
|
"acorn": "^8.6.0",
|
|
58
|
+
"eslint": "^8.3.0",
|
|
59
|
+
"eslint-config-prettier": "^8.3.0",
|
|
60
|
+
"eslint-plugin-import": "^2.25.3",
|
|
61
|
+
"eslint-plugin-node": "^11.1.0",
|
|
62
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
63
|
+
"eslint-plugin-react": "^7.27.1",
|
|
52
64
|
"jest": "^27.0.6",
|
|
53
65
|
"semantic-release": "^18.0.1"
|
|
54
66
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: Pull Request Workflow
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
- pull_request
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
build:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- name: Use Node.js 16.x
|
|
13
|
-
uses: actions/setup-node@v2
|
|
14
|
-
with:
|
|
15
|
-
node-version: 16.x
|
|
16
|
-
cache: 'npm'
|
|
17
|
-
- run: npm ci
|
|
18
|
-
- run: npm run build --if-present
|
|
19
|
-
- run: npm test
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: Release Workflow
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- 'main'
|
|
7
|
-
paths-ignore:
|
|
8
|
-
- '.github/**'
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
release:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v2
|
|
16
|
-
- name: Use Node.js 16.x
|
|
17
|
-
uses: actions/setup-node@v2
|
|
18
|
-
with:
|
|
19
|
-
node-version: 16.x
|
|
20
|
-
registry-url: 'https://registry.npmjs.org'
|
|
21
|
-
cache: 'npm'
|
|
22
|
-
- run: npm ci
|
|
23
|
-
- run: npm run build --if-present
|
|
24
|
-
- name: Release
|
|
25
|
-
env:
|
|
26
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
28
|
-
run: npx semantic-release
|
|
29
|
-
|
|
30
|
-
|
package/babel.config.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import "./App.css";
|
|
2
|
-
import "./App.scoped.css";
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
import logo from "./logo.svg";
|
|
5
|
-
import Sub from "./Sub";
|
|
6
|
-
function App() {
|
|
7
|
-
const [count, setCount] = useState(0);
|
|
8
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
9
|
-
className: "App",
|
|
10
|
-
"data-v-123456": true
|
|
11
|
-
}, React.createElement("header", {
|
|
12
|
-
className: "App-header",
|
|
13
|
-
"data-v-123456": true
|
|
14
|
-
}, React.createElement("img", {
|
|
15
|
-
src: logo,
|
|
16
|
-
className: "App-logo",
|
|
17
|
-
alt: "logo",
|
|
18
|
-
"data-v-123456": true
|
|
19
|
-
}), React.createElement("p", { "data-v-123456": true }, "Hello Vite + React!"), React.createElement("p", { "data-v-123456": true }, React.createElement("button", {
|
|
20
|
-
type: "button",
|
|
21
|
-
onClick: () => setCount(count2 => count2 + 1),
|
|
22
|
-
"data-v-123456": true
|
|
23
|
-
}, "count is: ", count)), React.createElement("p", { "data-v-123456": true }, "Edit ", React.createElement("code", { "data-v-123456": true }, "App.jsx"), " and save to test HMR updates."), React.createElement("p", { "data-v-123456": true }, React.createElement("a", {
|
|
24
|
-
className: "App-link",
|
|
25
|
-
href: "https://reactjs.org",
|
|
26
|
-
target: "_blank",
|
|
27
|
-
rel: "noopener noreferrer",
|
|
28
|
-
"data-v-123456": true
|
|
29
|
-
}, "Learn React"), " | ", React.createElement("a", {
|
|
30
|
-
className: "App-link",
|
|
31
|
-
href: "https://vitejs.dev/guide/features.html",
|
|
32
|
-
target: "_blank",
|
|
33
|
-
rel: "noopener noreferrer",
|
|
34
|
-
"data-v-123456": true
|
|
35
|
-
}, "Vite Docs"))), React.createElement(Sub, { "data-v-123456": true })));
|
|
36
|
-
}
|
|
37
|
-
export default App;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import "./App.css";
|
|
2
|
-
import "./App.scoped.css";
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
import logo from "./logo.svg";
|
|
5
|
-
import Sub from "./Sub";
|
|
6
|
-
function App() {
|
|
7
|
-
const [count, setCount] = useState(0);
|
|
8
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
9
|
-
className: "App"
|
|
10
|
-
}, /* @__PURE__ */ React.createElement("header", {
|
|
11
|
-
className: "App-header"
|
|
12
|
-
}, /* @__PURE__ */ React.createElement("img", {
|
|
13
|
-
src: logo,
|
|
14
|
-
className: "App-logo",
|
|
15
|
-
alt: "logo"
|
|
16
|
-
}), /* @__PURE__ */ React.createElement("p", null, "Hello Vite + React!"), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("button", {
|
|
17
|
-
type: "button",
|
|
18
|
-
onClick: () => setCount((count2) => count2 + 1)
|
|
19
|
-
}, "count is: ", count)), /* @__PURE__ */ React.createElement("p", null, "Edit ", /* @__PURE__ */ React.createElement("code", null, "App.jsx"), " and save to test HMR updates."), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("a", {
|
|
20
|
-
className: "App-link",
|
|
21
|
-
href: "https://reactjs.org",
|
|
22
|
-
target: "_blank",
|
|
23
|
-
rel: "noopener noreferrer"
|
|
24
|
-
}, "Learn React"), " | ", /* @__PURE__ */ React.createElement("a", {
|
|
25
|
-
className: "App-link",
|
|
26
|
-
href: "https://vitejs.dev/guide/features.html",
|
|
27
|
-
target: "_blank",
|
|
28
|
-
rel: "noopener noreferrer"
|
|
29
|
-
}, "Vite Docs"))), /* @__PURE__ */ React.createElement(Sub, null)));
|
|
30
|
-
}
|
|
31
|
-
export default App;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
j as jsxRuntime,
|
|
3
|
-
r as react,
|
|
4
|
-
R as ReactDOM,
|
|
5
|
-
a as React
|
|
6
|
-
} from "./vendor.1137a3d7.js";
|
|
7
|
-
var index = "body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n";
|
|
8
|
-
var App$1 = ".sub {\n color: green;\n}";
|
|
9
|
-
var App_scoped = ".App {\n text-align: center;\n}\n\n.sub {\n color: blue !important;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\nbutton {\n font-size: calc(10px + 2vmin);\n}\n";
|
|
10
|
-
var logo = "/assets/logo.ecc203fb.svg";
|
|
11
|
-
var Sub_scoped = ".sub {\n color: red;\n}\n.sub__test {\n margin: 0;\n}\n.sub h2 {\n font-weight: 300;\n font-size: 3rem;\n}\n\nh2 {\n font-size: 10rem;\n}\n\n.drawer {\n width: 400px;\n}\n.drawer__list-item {\n padding: 0;\n}\n.drawer__list-item-icon {\n margin-right: 1rem;\n}\n.drawer__link {\n display: flex;\n width: 300px;\n padding: 1rem;\n align-items: center;\n text-decoration: none;\n border: 0;\n outline: 0;\n background: transparent;\n font-family: \"Quicksand\", \"Roboto\", sans-serif;\n font-size: 1rem;\n font-weight: 400;\n}\n.drawer__link:hover {\n background-color: #fafafa;\n}";
|
|
12
|
-
const jsx = jsxRuntime.exports.jsx;
|
|
13
|
-
const jsxs = jsxRuntime.exports.jsxs;
|
|
14
|
-
const Fragment = jsxRuntime.exports.Fragment;
|
|
15
|
-
function Sub() {
|
|
16
|
-
return jsx("div", {
|
|
17
|
-
className: "sub",
|
|
18
|
-
children: jsx("h2", {
|
|
19
|
-
children: "Sub",
|
|
20
|
-
"data-v-123456": true
|
|
21
|
-
}),
|
|
22
|
-
"data-v-123456": true
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function App() {
|
|
26
|
-
const [count, setCount] = react.exports.useState(0);
|
|
27
|
-
return jsx(Fragment, {
|
|
28
|
-
children: jsxs("div", {
|
|
29
|
-
className: "App",
|
|
30
|
-
children: [
|
|
31
|
-
jsxs("header", {
|
|
32
|
-
className: "App-header",
|
|
33
|
-
children: [
|
|
34
|
-
jsx("img", {
|
|
35
|
-
src: logo,
|
|
36
|
-
className: "App-logo",
|
|
37
|
-
alt: "logo",
|
|
38
|
-
"data-v-123456": true
|
|
39
|
-
}),
|
|
40
|
-
jsx("p", {
|
|
41
|
-
children: "Hello Vite + React!",
|
|
42
|
-
"data-v-123456": true
|
|
43
|
-
}),
|
|
44
|
-
jsx("p", {
|
|
45
|
-
children: jsxs("button", {
|
|
46
|
-
type: "button",
|
|
47
|
-
onClick: () => setCount(count2 => count2 + 1),
|
|
48
|
-
children: [
|
|
49
|
-
"count is: ",
|
|
50
|
-
count
|
|
51
|
-
],
|
|
52
|
-
"data-v-123456": true
|
|
53
|
-
}),
|
|
54
|
-
"data-v-123456": true
|
|
55
|
-
}),
|
|
56
|
-
jsxs("p", {
|
|
57
|
-
children: [
|
|
58
|
-
"Edit ",
|
|
59
|
-
jsx("code", {
|
|
60
|
-
children: "App.jsx",
|
|
61
|
-
"data-v-123456": true
|
|
62
|
-
}),
|
|
63
|
-
" and save to test HMR updates."
|
|
64
|
-
],
|
|
65
|
-
"data-v-123456": true
|
|
66
|
-
}),
|
|
67
|
-
jsxs("p", {
|
|
68
|
-
children: [
|
|
69
|
-
jsx("a", {
|
|
70
|
-
className: "App-link",
|
|
71
|
-
href: "https://reactjs.org",
|
|
72
|
-
target: "_blank",
|
|
73
|
-
rel: "noopener noreferrer",
|
|
74
|
-
children: "Learn React",
|
|
75
|
-
"data-v-123456": true
|
|
76
|
-
}),
|
|
77
|
-
" | ",
|
|
78
|
-
jsx("a", {
|
|
79
|
-
className: "App-link",
|
|
80
|
-
href: "https://vitejs.dev/guide/features.html",
|
|
81
|
-
target: "_blank",
|
|
82
|
-
rel: "noopener noreferrer",
|
|
83
|
-
children: "Vite Docs",
|
|
84
|
-
"data-v-123456": true
|
|
85
|
-
})
|
|
86
|
-
],
|
|
87
|
-
"data-v-123456": true
|
|
88
|
-
})
|
|
89
|
-
],
|
|
90
|
-
"data-v-123456": true
|
|
91
|
-
}),
|
|
92
|
-
jsx(Fragment, { children: jsx(Sub, { "data-v-123456": true }) })
|
|
93
|
-
],
|
|
94
|
-
"data-v-123456": true
|
|
95
|
-
})
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
ReactDOM.render(jsx(React.StrictMode, {
|
|
99
|
-
children: jsx(App, { "data-v-123456": true }),
|
|
100
|
-
"data-v-123456": true
|
|
101
|
-
}), document.getElementById("root"));
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { j as jsxRuntime, r as react, R as ReactDOM, a as React } from "./vendor.1137a3d7.js";
|
|
2
|
-
var index = "body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n";
|
|
3
|
-
var App$1 = ".sub {\n color: green;\n}";
|
|
4
|
-
var App_scoped = ".App {\n text-align: center;\n}\n\n.sub {\n color: blue !important;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n\nbutton {\n font-size: calc(10px + 2vmin);\n}\n";
|
|
5
|
-
var logo = "/assets/logo.ecc203fb.svg";
|
|
6
|
-
var Sub_scoped = '.sub {\n color: red;\n}\n.sub__test {\n margin: 0;\n}\n.sub h2 {\n font-weight: 300;\n font-size: 3rem;\n}\n\nh2 {\n font-size: 10rem;\n}\n\n.drawer {\n width: 400px;\n}\n.drawer__list-item {\n padding: 0;\n}\n.drawer__list-item-icon {\n margin-right: 1rem;\n}\n.drawer__link {\n display: flex;\n width: 300px;\n padding: 1rem;\n align-items: center;\n text-decoration: none;\n border: 0;\n outline: 0;\n background: transparent;\n font-family: "Quicksand", "Roboto", sans-serif;\n font-size: 1rem;\n font-weight: 400;\n}\n.drawer__link:hover {\n background-color: #fafafa;\n}';
|
|
7
|
-
const jsx = jsxRuntime.exports.jsx;
|
|
8
|
-
const jsxs = jsxRuntime.exports.jsxs;
|
|
9
|
-
const Fragment = jsxRuntime.exports.Fragment;
|
|
10
|
-
function Sub() {
|
|
11
|
-
return /* @__PURE__ */ jsx("div", {
|
|
12
|
-
className: "sub",
|
|
13
|
-
children: /* @__PURE__ */ jsx("h2", {
|
|
14
|
-
children: "Sub"
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
function App() {
|
|
19
|
-
const [count, setCount] = react.exports.useState(0);
|
|
20
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
21
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
22
|
-
className: "App",
|
|
23
|
-
children: [/* @__PURE__ */ jsxs("header", {
|
|
24
|
-
className: "App-header",
|
|
25
|
-
children: [/* @__PURE__ */ jsx("img", {
|
|
26
|
-
src: logo,
|
|
27
|
-
className: "App-logo",
|
|
28
|
-
alt: "logo"
|
|
29
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
30
|
-
children: "Hello Vite + React!"
|
|
31
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
32
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
33
|
-
type: "button",
|
|
34
|
-
onClick: () => setCount((count2) => count2 + 1),
|
|
35
|
-
children: ["count is: ", count]
|
|
36
|
-
})
|
|
37
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
38
|
-
children: ["Edit ", /* @__PURE__ */ jsx("code", {
|
|
39
|
-
children: "App.jsx"
|
|
40
|
-
}), " and save to test HMR updates."]
|
|
41
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
42
|
-
children: [/* @__PURE__ */ jsx("a", {
|
|
43
|
-
className: "App-link",
|
|
44
|
-
href: "https://reactjs.org",
|
|
45
|
-
target: "_blank",
|
|
46
|
-
rel: "noopener noreferrer",
|
|
47
|
-
children: "Learn React"
|
|
48
|
-
}), " | ", /* @__PURE__ */ jsx("a", {
|
|
49
|
-
className: "App-link",
|
|
50
|
-
href: "https://vitejs.dev/guide/features.html",
|
|
51
|
-
target: "_blank",
|
|
52
|
-
rel: "noopener noreferrer",
|
|
53
|
-
children: "Vite Docs"
|
|
54
|
-
})]
|
|
55
|
-
})]
|
|
56
|
-
}), /* @__PURE__ */ jsx(Fragment, {
|
|
57
|
-
children: /* @__PURE__ */ jsx(Sub, {})
|
|
58
|
-
})]
|
|
59
|
-
})
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
ReactDOM.render(/* @__PURE__ */ jsx(React.StrictMode, {
|
|
63
|
-
children: /* @__PURE__ */ jsx(App, {})
|
|
64
|
-
}), document.getElementById("root"));
|
package/src/ast-iterator.spec.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import { parse } from "acorn";
|
|
4
|
-
import { astIterator } from "./ast-iterator";
|
|
5
|
-
|
|
6
|
-
describe('astIterator', () => {
|
|
7
|
-
it('should iterate through all nodes', async () => {
|
|
8
|
-
let iterationCount = 0;
|
|
9
|
-
const file = await readFile(resolve(__dirname, './__mocks__/sample-code-file.js'), { encoding: 'utf-8' })
|
|
10
|
-
const ast = parse(file, { sourceType: 'module', ecmaVersion: 2022 });
|
|
11
|
-
|
|
12
|
-
for (const node of astIterator(ast)) {
|
|
13
|
-
iterationCount++;
|
|
14
|
-
expect(node).toBeTruthy();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
expect(iterationCount).toBe(28);
|
|
18
|
-
});
|
|
19
|
-
})
|
package/src/ast-iterator.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const isNode = (obj: any) => {
|
|
3
|
-
return typeof obj === 'object' &&
|
|
4
|
-
typeof (obj as any)?.end === 'number' &&
|
|
5
|
-
typeof (obj as any)?.start === 'number' &&
|
|
6
|
-
typeof (obj as any)?.type === 'string'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const astIterator = function* (ast: any): IterableIterator<any> {
|
|
10
|
-
if (!ast) { return }
|
|
11
|
-
|
|
12
|
-
for (let key of Object.keys(ast)) {
|
|
13
|
-
// Skip useless keys
|
|
14
|
-
if (['end', 'start', 'type'].includes(key)) { continue; }
|
|
15
|
-
|
|
16
|
-
// If key value is an array, iterate over it
|
|
17
|
-
if (Array.isArray(ast[key])) {
|
|
18
|
-
for (let nodeIndex in ast[key]) {
|
|
19
|
-
yield *astIterator(ast[key][nodeIndex])
|
|
20
|
-
}
|
|
21
|
-
} else if(isNode(ast[key])) {
|
|
22
|
-
yield *astIterator(ast[key])
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
yield ast
|
|
27
|
-
}
|