@vxrn/compiler 1.14.4 → 1.14.5
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/cjs/cache.cjs +65 -44
- package/dist/cjs/configure.cjs +16 -14
- package/dist/cjs/constants.cjs +55 -53
- package/dist/cjs/index.cjs +217 -136
- package/dist/cjs/refresh-runtime.cjs +284 -125
- package/dist/cjs/transformBabel.cjs +180 -95
- package/dist/cjs/transformSWC.cjs +188 -131
- package/dist/cjs/types.cjs +7 -5
- package/dist/esm/cache.mjs +49 -30
- package/dist/esm/cache.mjs.map +1 -1
- package/dist/esm/configure.mjs +4 -4
- package/dist/esm/constants.mjs +43 -43
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/index.js +182 -103
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +182 -103
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/refresh-runtime.mjs +272 -115
- package/dist/esm/refresh-runtime.mjs.map +1 -1
- package/dist/esm/transformBabel.mjs +151 -68
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformSWC.mjs +171 -116
- package/dist/esm/transformSWC.mjs.map +1 -1
- package/package.json +4 -4
package/dist/cjs/cache.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var cache_exports = {};
|
|
22
24
|
__export(cache_exports, {
|
|
@@ -26,10 +28,10 @@ __export(cache_exports, {
|
|
|
26
28
|
setCachedTransform: () => setCachedTransform
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(cache_exports);
|
|
29
|
-
var import_node_crypto = require("node:crypto")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
var import_node_crypto = require("node:crypto");
|
|
32
|
+
var import_node_fs = require("node:fs");
|
|
33
|
+
var import_node_path = require("node:path");
|
|
34
|
+
var import_configure = require("./configure.cjs");
|
|
33
35
|
const stats = {
|
|
34
36
|
hits: 0,
|
|
35
37
|
misses: 0,
|
|
@@ -37,9 +39,12 @@ const stats = {
|
|
|
37
39
|
};
|
|
38
40
|
function getCacheDir() {
|
|
39
41
|
const cacheDir = (0, import_node_path.join)(process.cwd(), "node_modules", ".vxrn", "compiler-cache");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if (!(0, import_node_fs.existsSync)(cacheDir)) {
|
|
43
|
+
(0, import_node_fs.mkdirSync)(cacheDir, {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return cacheDir;
|
|
43
48
|
}
|
|
44
49
|
function getConfigFingerprint() {
|
|
45
50
|
return (0, import_node_crypto.createHash)("sha1").update(JSON.stringify({
|
|
@@ -50,45 +55,59 @@ function getConfigFingerprint() {
|
|
|
50
55
|
})).digest("hex").slice(0, 8);
|
|
51
56
|
}
|
|
52
57
|
function getCacheKey(filePath, environment) {
|
|
53
|
-
|
|
58
|
+
const hash = (0, import_node_crypto.createHash)("sha1").update(`${environment}:${filePath}:${getConfigFingerprint()}`).digest("hex");
|
|
59
|
+
return hash;
|
|
54
60
|
}
|
|
55
61
|
function getContentHash(code) {
|
|
56
62
|
return (0, import_node_crypto.createHash)("sha1").update(code).digest("hex").slice(0, 16);
|
|
57
63
|
}
|
|
58
64
|
function getCachedTransform(filePath, code, environment) {
|
|
59
65
|
try {
|
|
60
|
-
const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (!(0, import_node_fs.existsSync)(cachePath))
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath;
|
|
67
|
+
const cacheDir = getCacheDir();
|
|
68
|
+
const cacheKey = getCacheKey(cleanPath, environment);
|
|
69
|
+
const cachePath = (0, import_node_path.join)(cacheDir, `${cacheKey}.json`);
|
|
70
|
+
if (!(0, import_node_fs.existsSync)(cachePath)) {
|
|
71
|
+
stats.misses++;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const cached = JSON.parse((0, import_node_fs.readFileSync)(cachePath, "utf-8"));
|
|
75
|
+
const currentMtime = (0, import_node_fs.statSync)(cleanPath).mtimeMs;
|
|
76
|
+
if (cached.mtime !== currentMtime) {
|
|
77
|
+
stats.misses++;
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
68
80
|
const currentHash = getContentHash(code);
|
|
69
|
-
|
|
81
|
+
if (cached.hash !== currentHash) {
|
|
82
|
+
stats.misses++;
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
stats.hits++;
|
|
86
|
+
return {
|
|
70
87
|
code: cached.code,
|
|
71
88
|
map: cached.map
|
|
72
|
-
}
|
|
73
|
-
} catch {
|
|
74
|
-
|
|
89
|
+
};
|
|
90
|
+
} catch (err) {
|
|
91
|
+
stats.misses++;
|
|
92
|
+
return null;
|
|
75
93
|
}
|
|
76
94
|
}
|
|
77
95
|
function setCachedTransform(filePath, code, result, environment) {
|
|
78
96
|
try {
|
|
79
|
-
const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(0, import_node_fs.writeFileSync)(cachePath, JSON.stringify(entry), "utf-8")
|
|
97
|
+
const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath;
|
|
98
|
+
const cacheDir = getCacheDir();
|
|
99
|
+
const cacheKey = getCacheKey(cleanPath, environment);
|
|
100
|
+
const cachePath = (0, import_node_path.join)(cacheDir, `${cacheKey}.json`);
|
|
101
|
+
const mtime = (0, import_node_fs.statSync)(cleanPath).mtimeMs;
|
|
102
|
+
const hash = getContentHash(code);
|
|
103
|
+
const entry = {
|
|
104
|
+
mtime,
|
|
105
|
+
hash,
|
|
106
|
+
code: result.code,
|
|
107
|
+
map: result.map
|
|
108
|
+
};
|
|
109
|
+
(0, import_node_fs.writeFileSync)(cachePath, JSON.stringify(entry), "utf-8");
|
|
110
|
+
stats.writes++;
|
|
92
111
|
} catch (err) {
|
|
93
112
|
console.warn(`[cache] Failed to write cache for ${filePath}:`, err);
|
|
94
113
|
}
|
|
@@ -99,7 +118,9 @@ function getCacheStats() {
|
|
|
99
118
|
};
|
|
100
119
|
}
|
|
101
120
|
function logCacheStats() {
|
|
102
|
-
if (!process.env.DEBUG_COMPILER_PERF)
|
|
121
|
+
if (!process.env.DEBUG_COMPILER_PERF) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
103
124
|
const total = stats.hits + stats.misses;
|
|
104
125
|
if (total === 0) return;
|
|
105
126
|
const hitRate = (stats.hits / total * 100).toFixed(1);
|
package/dist/cjs/configure.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var configure_exports = {};
|
|
22
24
|
__export(configure_exports, {
|
|
@@ -25,10 +27,10 @@ __export(configure_exports, {
|
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(configure_exports);
|
|
27
29
|
const configuration = {
|
|
28
|
-
enableNativewind:
|
|
29
|
-
enableReanimated:
|
|
30
|
-
enableCompiler:
|
|
31
|
-
enableNativeCSS:
|
|
30
|
+
enableNativewind: false,
|
|
31
|
+
enableReanimated: false,
|
|
32
|
+
enableCompiler: false,
|
|
33
|
+
enableNativeCSS: false
|
|
32
34
|
};
|
|
33
35
|
function configureVXRNCompilerPlugin(_) {
|
|
34
36
|
Object.assign(configuration, _);
|
package/dist/cjs/constants.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var constants_exports = {};
|
|
22
24
|
__export(constants_exports, {
|
|
@@ -29,47 +31,47 @@ __export(constants_exports, {
|
|
|
29
31
|
module.exports = __toCommonJS(constants_exports);
|
|
30
32
|
var import_utils = require("@vxrn/utils");
|
|
31
33
|
const {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
".mdx": {
|
|
69
|
-
syntax: "ecmascript",
|
|
70
|
-
jsx: !0,
|
|
71
|
-
importAttributes: !0,
|
|
72
|
-
explicitResourceManagement: !0
|
|
73
|
-
}
|
|
34
|
+
debug
|
|
35
|
+
} = (0, import_utils.createDebugger)("vxrn:compiler-plugin");
|
|
36
|
+
const runtimePublicPath = "/@react-refresh";
|
|
37
|
+
const asyncGeneratorRegex = /(async \*|async function\*|for await)/;
|
|
38
|
+
const parsers = {
|
|
39
|
+
".tsx": {
|
|
40
|
+
syntax: "typescript",
|
|
41
|
+
tsx: true,
|
|
42
|
+
decorators: true
|
|
43
|
+
},
|
|
44
|
+
".ts": {
|
|
45
|
+
syntax: "typescript",
|
|
46
|
+
tsx: false,
|
|
47
|
+
decorators: true
|
|
48
|
+
},
|
|
49
|
+
".jsx": {
|
|
50
|
+
syntax: "ecmascript",
|
|
51
|
+
jsx: true,
|
|
52
|
+
importAttributes: true,
|
|
53
|
+
explicitResourceManagement: true
|
|
54
|
+
},
|
|
55
|
+
".js": {
|
|
56
|
+
syntax: "ecmascript",
|
|
57
|
+
importAttributes: true,
|
|
58
|
+
explicitResourceManagement: true
|
|
59
|
+
},
|
|
60
|
+
".mjs": {
|
|
61
|
+
syntax: "ecmascript",
|
|
62
|
+
importAttributes: true,
|
|
63
|
+
explicitResourceManagement: true
|
|
64
|
+
},
|
|
65
|
+
".cjs": {
|
|
66
|
+
syntax: "ecmascript",
|
|
67
|
+
importAttributes: true,
|
|
68
|
+
explicitResourceManagement: true
|
|
74
69
|
},
|
|
75
|
-
|
|
70
|
+
".mdx": {
|
|
71
|
+
syntax: "ecmascript",
|
|
72
|
+
jsx: true,
|
|
73
|
+
importAttributes: true,
|
|
74
|
+
explicitResourceManagement: true
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const validParsers = /* @__PURE__ */new Set([...Object.keys(parsers), ".css"]);
|