@vxrn/compiler 1.12.2 → 1.12.4
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/esm/index.js +181 -188
- package/dist/esm/index.js.map +1 -6
- package/package.json +4 -4
- package/dist/cjs/cache.js +0 -86
- package/dist/cjs/cache.js.map +0 -6
- package/dist/cjs/configure.js +0 -30
- package/dist/cjs/configure.js.map +0 -6
- package/dist/cjs/constants.js +0 -56
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/index.js +0 -297
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/refresh-runtime.js +0 -300
- package/dist/cjs/refresh-runtime.js.map +0 -6
- package/dist/cjs/transformBabel.js +0 -153
- package/dist/cjs/transformBabel.js.map +0 -6
- package/dist/cjs/transformSWC.js +0 -256
- package/dist/cjs/transformSWC.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/esm/cache.js +0 -73
- package/dist/esm/cache.js.map +0 -6
- package/dist/esm/configure.js +0 -14
- package/dist/esm/configure.js.map +0 -6
- package/dist/esm/constants.js +0 -40
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/refresh-runtime.js +0 -284
- package/dist/esm/refresh-runtime.js.map +0 -6
- package/dist/esm/transformBabel.js +0 -133
- package/dist/esm/transformBabel.js.map +0 -6
- package/dist/esm/transformSWC.js +0 -246
- package/dist/esm/transformSWC.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
package/dist/cjs/transformSWC.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var transformSWC_exports = {};
|
|
16
|
-
__export(transformSWC_exports, {
|
|
17
|
-
transformSWC: () => transformSWC,
|
|
18
|
-
transformSWCStripJSX: () => transformSWCStripJSX
|
|
19
|
-
});
|
|
20
|
-
module.exports = __toCommonJS(transformSWC_exports);
|
|
21
|
-
var import_node_path = require("node:path"), import_core = require("@swc/core"), import_ts_deepmerge = require("ts-deepmerge"), import_configure = require("./configure"), import_constants = require("./constants");
|
|
22
|
-
const ignoreId = new RegExp(`node_modules\\${import_node_path.sep}(\\.vite|vite)\\${import_node_path.sep}`);
|
|
23
|
-
async function transformSWC(id, code, options, swcOptions) {
|
|
24
|
-
if (ignoreId.test(id) || (id = id.split("?")[0].replace(process.cwd(), ""), id === import_constants.runtimePublicPath))
|
|
25
|
-
return;
|
|
26
|
-
const parser = getParser(id, options.forceJSX);
|
|
27
|
-
if (!parser)
|
|
28
|
-
return;
|
|
29
|
-
const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX && !id.includes("node_modules"), reactConfig = {
|
|
30
|
-
refresh,
|
|
31
|
-
development: !options.forceJSX && !options.production,
|
|
32
|
-
runtime: "automatic",
|
|
33
|
-
importSource: "react",
|
|
34
|
-
...import_configure.configuration.enableNativewind && !id.includes("node_modules") ? {
|
|
35
|
-
importSource: "nativewind"
|
|
36
|
-
// pragma: 'createInteropElement',
|
|
37
|
-
// pragmaFrag: '_InteropFragment',
|
|
38
|
-
// swc doesnt actually change the import right
|
|
39
|
-
// runtime: 'classic',
|
|
40
|
-
} : {}
|
|
41
|
-
}, transformOptions = (() => {
|
|
42
|
-
if (options.environment === "client" || options.environment === "ssr")
|
|
43
|
-
return {
|
|
44
|
-
sourceMaps: shouldSourceMap(),
|
|
45
|
-
jsc: {
|
|
46
|
-
target: "es2020",
|
|
47
|
-
parser,
|
|
48
|
-
transform: {
|
|
49
|
-
useDefineForClassFields: !0,
|
|
50
|
-
react: reactConfig
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const opts = options.es5 || !process.env.VXRN_USE_BABEL_FOR_GENERATORS && import_constants.asyncGeneratorRegex.test(code) ? {
|
|
55
|
-
jsc: {
|
|
56
|
-
parser,
|
|
57
|
-
target: "es5",
|
|
58
|
-
transform: {
|
|
59
|
-
useDefineForClassFields: !0,
|
|
60
|
-
react: reactConfig
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} : {
|
|
64
|
-
...!options.forceJSX && { env: SWC_ENV },
|
|
65
|
-
jsc: {
|
|
66
|
-
...options.forceJSX && { target: "esnext" },
|
|
67
|
-
parser,
|
|
68
|
-
transform: {
|
|
69
|
-
useDefineForClassFields: !0,
|
|
70
|
-
react: reactConfig
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
sourceMaps: shouldSourceMap(),
|
|
76
|
-
module: {
|
|
77
|
-
importInterop: "none",
|
|
78
|
-
type: "nodenext"
|
|
79
|
-
},
|
|
80
|
-
...options.mode === "serve-cjs" && {
|
|
81
|
-
module: {
|
|
82
|
-
importInterop: "none",
|
|
83
|
-
type: "commonjs",
|
|
84
|
-
strict: !0
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
...opts
|
|
88
|
-
};
|
|
89
|
-
})(), finalOptions = (0, import_ts_deepmerge.merge)(
|
|
90
|
-
{
|
|
91
|
-
filename: id,
|
|
92
|
-
swcrc: !1,
|
|
93
|
-
configFile: !1,
|
|
94
|
-
...transformOptions
|
|
95
|
-
},
|
|
96
|
-
swcOptions || {}
|
|
97
|
-
), result = await (async () => {
|
|
98
|
-
try {
|
|
99
|
-
return (0, import_constants.debug)?.(
|
|
100
|
-
`transformSWC ${id} using options:
|
|
101
|
-
${JSON.stringify(finalOptions, null, 2)}`
|
|
102
|
-
), await (0, import_core.transform)(code, finalOptions);
|
|
103
|
-
} catch (e) {
|
|
104
|
-
const message = e.message, fileStartIndex = message.indexOf("\u256D\u2500[");
|
|
105
|
-
if (fileStartIndex !== -1) {
|
|
106
|
-
const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
|
|
107
|
-
match && (e.line = match[1], e.column = match[2]);
|
|
108
|
-
}
|
|
109
|
-
throw e;
|
|
110
|
-
}
|
|
111
|
-
})();
|
|
112
|
-
import_configure.configuration.enableNativeCSS && result.code.includes("createInteropElement(") && (result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
|
|
113
|
-
${result.code}`);
|
|
114
|
-
const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);
|
|
115
|
-
if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
|
|
116
|
-
const typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
|
|
117
|
-
if (typeExportsMatch)
|
|
118
|
-
for (const typeExport of Array.from(typeExportsMatch)) {
|
|
119
|
-
const [_export, _type, name] = typeExport.split(/\s+/);
|
|
120
|
-
if (name.startsWith("{") || name.includes("<")) continue;
|
|
121
|
-
if (!new RegExp(
|
|
122
|
-
`export (const|let|class|function) ${name}\\s+`
|
|
123
|
-
).test(result.code)) {
|
|
124
|
-
const fakeExport = `export let ${name} = {};`;
|
|
125
|
-
console.info(
|
|
126
|
-
` \u26A0\uFE0F Fixing non-type-specific import in node_module, this should be fixed upstream: ${fakeExport} in ${id}`
|
|
127
|
-
), result.code += `
|
|
128
|
-
${fakeExport}
|
|
129
|
-
`;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return result && !options.production && !options.noHMR ? wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) : result;
|
|
134
|
-
}
|
|
135
|
-
function wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {
|
|
136
|
-
return options.environment === "ssr" ? result : options.environment === "client" ? wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) : wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
|
|
137
|
-
}
|
|
138
|
-
function wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {
|
|
139
|
-
const sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
140
|
-
return sourceMap && (sourceMap.mappings = ";;" + sourceMap.mappings), result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
141
|
-
|
|
142
|
-
${result.code}`, hasRefreshRuntime && (sourceMap && (sourceMap.mappings = ";;;;;;" + sourceMap.mappings), result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
143
|
-
const prevRefreshReg = window.$RefreshReg$;
|
|
144
|
-
const prevRefreshSig = window.$RefreshSig$;
|
|
145
|
-
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
|
|
146
|
-
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
147
|
-
|
|
148
|
-
${result.code}
|
|
149
|
-
|
|
150
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
151
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
152
|
-
`), result.code += `
|
|
153
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
154
|
-
RefreshRuntime.registerExportsForReactRefresh("${id}", currentExports);
|
|
155
|
-
import.meta.hot.accept((nextExports) => {
|
|
156
|
-
if (!nextExports) return;
|
|
157
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate("${id}", currentExports, nextExports);
|
|
158
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
`, { code: result.code, map: sourceMap };
|
|
162
|
-
}
|
|
163
|
-
function wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {
|
|
164
|
-
const postfixCode = `if (module.hot) {
|
|
165
|
-
if (module.hot.accept) {
|
|
166
|
-
module.hot.accept((nextExports) => {
|
|
167
|
-
RefreshRuntime.performReactRefresh()
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}`;
|
|
171
|
-
if (hasRefreshRuntime) {
|
|
172
|
-
const prefixCode = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
173
|
-
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
174
|
-
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
175
|
-
console.info("no react refresh setup!")
|
|
176
|
-
return (x) => x
|
|
177
|
-
});
|
|
178
|
-
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
179
|
-
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
180
|
-
module.url = '${id}'
|
|
181
|
-
module.hot = createHotContext(module.url)`, sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
182
|
-
if (sourceMap) {
|
|
183
|
-
const prefixLen = prefixCode.split(`
|
|
184
|
-
`).length + 1;
|
|
185
|
-
sourceMap.mappings = new Array(prefixLen).fill(";").join("") + sourceMap.mappings;
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
code: `${prefixCode}
|
|
189
|
-
${result.code}
|
|
190
|
-
|
|
191
|
-
if (module.hot) {
|
|
192
|
-
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
193
|
-
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
194
|
-
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
${postfixCode}
|
|
198
|
-
`,
|
|
199
|
-
map: sourceMap
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
return result.code += postfixCode, result;
|
|
203
|
-
}
|
|
204
|
-
const SWC_ENV = {
|
|
205
|
-
targets: {
|
|
206
|
-
node: "4"
|
|
207
|
-
},
|
|
208
|
-
// debug: true,
|
|
209
|
-
include: [],
|
|
210
|
-
// this breaks the uniswap app for any file with a ...spread
|
|
211
|
-
exclude: [
|
|
212
|
-
"transform-spread",
|
|
213
|
-
"transform-destructuring",
|
|
214
|
-
"transform-object-rest-spread",
|
|
215
|
-
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
216
|
-
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
217
|
-
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
218
|
-
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
219
|
-
"transform-async-to-generator",
|
|
220
|
-
"transform-regenerator"
|
|
221
|
-
// Similar to above
|
|
222
|
-
]
|
|
223
|
-
}, refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
224
|
-
function shouldSourceMap() {
|
|
225
|
-
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
226
|
-
}
|
|
227
|
-
function getParser(id, forceJSX = !1) {
|
|
228
|
-
if (id.endsWith("one-entry-native"))
|
|
229
|
-
return import_constants.parsers[".tsx"];
|
|
230
|
-
const extension = (0, import_node_path.extname)(id);
|
|
231
|
-
let parser = extension ? import_constants.parsers[extension] : import_constants.parsers[".js"];
|
|
232
|
-
return (extension === ".js" || extension === ".mjs") && (forceJSX && (parser = import_constants.parsers[".jsx"]), id.includes("expo-modules-core") && (parser = import_constants.parsers[".jsx"])), parser;
|
|
233
|
-
}
|
|
234
|
-
const transformSWCStripJSX = async (id, code) => {
|
|
235
|
-
const parser = getParser(id);
|
|
236
|
-
if (parser)
|
|
237
|
-
return await (0, import_core.transform)(code, {
|
|
238
|
-
filename: id,
|
|
239
|
-
swcrc: !1,
|
|
240
|
-
configFile: !1,
|
|
241
|
-
sourceMaps: shouldSourceMap(),
|
|
242
|
-
jsc: {
|
|
243
|
-
target: "es2019",
|
|
244
|
-
parser,
|
|
245
|
-
transform: {
|
|
246
|
-
useDefineForClassFields: !0,
|
|
247
|
-
react: {
|
|
248
|
-
development: !0,
|
|
249
|
-
runtime: "automatic",
|
|
250
|
-
refresh: !1
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
//# sourceMappingURL=transformSWC.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/transformSWC.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B,sBAC7B,cAMO,sBACP,sBAAsB,yBACtB,mBAA8B,wBAC9B,mBAAuE;AAGvE,MAAM,WAAW,IAAI,OAAO,iBAAiB,oBAAG,mBAAmB,oBAAG,EAAE;AAExE,eAAsB,aACpB,IACA,MACA,SACA,YACA;AAUA,MATI,SAAS,KAAK,EAAE,MAIpB,KAAK,GACF,MAAM,GAAG,EAAE,CAAC,EAEZ,QAAQ,QAAQ,IAAI,GAAG,EAAE,GAExB,OAAO;AACT;AAGF,QAAM,SAAS,UAAU,IAAI,QAAQ,QAAQ;AAE7C,MAAI,CAAC;AACH;AAGF,QAAM,UACJ,QAAQ,gBAAgB,SACxB,CAAC,QAAQ,cACT,CAAC,QAAQ,SACT,CAAC,QAAQ,YACT,CAAC,GAAG,SAAS,cAAc,GAEvB,cAAc;AAAA,IAClB;AAAA,IACA,aAAa,CAAC,QAAQ,YAAY,CAAC,QAAQ;AAAA,IAC3C,SA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types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
};
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var types_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(types_exports);
|
|
14
|
-
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
DELETED
package/dist/esm/cache.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { configuration } from "./configure";
|
|
5
|
-
const stats = { hits: 0, misses: 0, writes: 0 };
|
|
6
|
-
function getCacheDir() {
|
|
7
|
-
const cacheDir = join(process.cwd(), "node_modules", ".vxrn", "compiler-cache");
|
|
8
|
-
return existsSync(cacheDir) || mkdirSync(cacheDir, { recursive: !0 }), cacheDir;
|
|
9
|
-
}
|
|
10
|
-
function getConfigFingerprint() {
|
|
11
|
-
return createHash("sha1").update(
|
|
12
|
-
JSON.stringify({
|
|
13
|
-
compiler: configuration.enableCompiler,
|
|
14
|
-
reanimated: configuration.enableReanimated,
|
|
15
|
-
nativewind: configuration.enableNativewind,
|
|
16
|
-
nativeCSS: configuration.enableNativeCSS
|
|
17
|
-
})
|
|
18
|
-
).digest("hex").slice(0, 8);
|
|
19
|
-
}
|
|
20
|
-
function getCacheKey(filePath, environment) {
|
|
21
|
-
return createHash("sha1").update(`${environment}:${filePath}:${getConfigFingerprint()}`).digest("hex");
|
|
22
|
-
}
|
|
23
|
-
function getContentHash(code) {
|
|
24
|
-
return createHash("sha1").update(code).digest("hex").slice(0, 16);
|
|
25
|
-
}
|
|
26
|
-
function getCachedTransform(filePath, code, environment) {
|
|
27
|
-
try {
|
|
28
|
-
const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath, cacheDir = getCacheDir(), cacheKey = getCacheKey(cleanPath, environment), cachePath = join(cacheDir, `${cacheKey}.json`);
|
|
29
|
-
if (!existsSync(cachePath))
|
|
30
|
-
return stats.misses++, null;
|
|
31
|
-
const cached = JSON.parse(readFileSync(cachePath, "utf-8")), currentMtime = statSync(cleanPath).mtimeMs;
|
|
32
|
-
if (cached.mtime !== currentMtime)
|
|
33
|
-
return stats.misses++, null;
|
|
34
|
-
const currentHash = getContentHash(code);
|
|
35
|
-
return cached.hash !== currentHash ? (stats.misses++, null) : (stats.hits++, { code: cached.code, map: cached.map });
|
|
36
|
-
} catch {
|
|
37
|
-
return stats.misses++, null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function setCachedTransform(filePath, code, result, environment) {
|
|
41
|
-
try {
|
|
42
|
-
const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath, cacheDir = getCacheDir(), cacheKey = getCacheKey(cleanPath, environment), cachePath = join(cacheDir, `${cacheKey}.json`), mtime = statSync(cleanPath).mtimeMs, hash = getContentHash(code), entry = {
|
|
43
|
-
mtime,
|
|
44
|
-
hash,
|
|
45
|
-
code: result.code,
|
|
46
|
-
map: result.map
|
|
47
|
-
};
|
|
48
|
-
writeFileSync(cachePath, JSON.stringify(entry), "utf-8"), stats.writes++;
|
|
49
|
-
} catch (err) {
|
|
50
|
-
console.warn(`[cache] Failed to write cache for ${filePath}:`, err);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function getCacheStats() {
|
|
54
|
-
return { ...stats };
|
|
55
|
-
}
|
|
56
|
-
function logCacheStats() {
|
|
57
|
-
if (!process.env.DEBUG_COMPILER_PERF)
|
|
58
|
-
return;
|
|
59
|
-
const total = stats.hits + stats.misses;
|
|
60
|
-
if (total === 0) return;
|
|
61
|
-
const hitRate = (stats.hits / total * 100).toFixed(1);
|
|
62
|
-
console.info(
|
|
63
|
-
`
|
|
64
|
-
\u{1F4BE} [Cache Stats] ${stats.hits} hits / ${stats.misses} misses (${hitRate}% hit rate), ${stats.writes} writes`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
getCacheStats,
|
|
69
|
-
getCachedTransform,
|
|
70
|
-
logCacheStats,
|
|
71
|
-
setCachedTransform
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=cache.js.map
|
package/dist/esm/cache.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/cache.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAAY,WAAW,cAAc,UAAU,qBAAqB;AAC7E,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAwB9B,MAAM,QAAoB,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAAE;AAE1D,SAAS,cAAsB;AAE7B,QAAM,WAAW,KAAK,QAAQ,IAAI,GAAG,gBAAgB,SAAS,gBAAgB;AAC9E,SAAK,WAAW,QAAQ,KACtB,UAAU,UAAU,EAAE,WAAW,GAAK,CAAC,GAElC;AACT;AAGA,SAAS,uBAA+B;AACtC,SAAO,WAAW,MAAM,EACrB;AAAA,IACC,KAAK,UAAU;AAAA,MACb,UAAU,cAAc;AAAA,MACxB,YAAY,cAAc;AAAA,MAC1B,YAAY,cAAc;AAAA,MAC1B,WAAW,cAAc;AAAA,IAC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MACb,KAAK,OAAO;AAAA,IACd;AAEA,kBAAc,WAAW,KAAK,UAAU,KAAK,GAAG,OAAO,GACvD,MAAM;AAAA,EACR,SAAS,KAAK;AAEZ,YAAQ,KAAK,qCAAqC,QAAQ,KAAK,GAAG;AAAA,EACpE;AACF;AAEO,SAAS,gBAA4B;AAC1C,SAAO,EAAE,GAAG,MAAM;AACpB;AAEO,SAAS,gBAAsB;AAEpC,MAAI,CAAC,QAAQ,IAAI;AACf;AAGF,QAAM,QAAQ,MAAM,OAAO,MAAM;AACjC,MAAI,UAAU,EAAG;AAEjB,QAAM,WAAY,MAAM,OAAO,QAAS,KAAK,QAAQ,CAAC;AACtD,UAAQ;AAAA,IACN;AAAA,0BAAsB,MAAM,IAAI,WAAW,MAAM,MAAM,YAAY,OAAO,gBAAgB,MAAM,MAAM;AAAA,EACxG;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/configure.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const configuration = {
|
|
2
|
-
enableNativewind: !1,
|
|
3
|
-
enableReanimated: !1,
|
|
4
|
-
enableCompiler: !1,
|
|
5
|
-
enableNativeCSS: !1
|
|
6
|
-
};
|
|
7
|
-
function configureVXRNCompilerPlugin(_) {
|
|
8
|
-
Object.assign(configuration, _);
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
configuration,
|
|
12
|
-
configureVXRNCompilerPlugin
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=configure.js.map
|
package/dist/esm/constants.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createDebugger } from "@vxrn/utils";
|
|
2
|
-
const { debug } = createDebugger("vxrn:compiler-plugin"), runtimePublicPath = "/@react-refresh", asyncGeneratorRegex = /(async \*|async function\*|for await)/, parsers = {
|
|
3
|
-
".tsx": { syntax: "typescript", tsx: !0, decorators: !0 },
|
|
4
|
-
".ts": { syntax: "typescript", tsx: !1, decorators: !0 },
|
|
5
|
-
".jsx": {
|
|
6
|
-
syntax: "ecmascript",
|
|
7
|
-
jsx: !0,
|
|
8
|
-
importAttributes: !0,
|
|
9
|
-
explicitResourceManagement: !0
|
|
10
|
-
},
|
|
11
|
-
".js": {
|
|
12
|
-
syntax: "ecmascript",
|
|
13
|
-
importAttributes: !0,
|
|
14
|
-
explicitResourceManagement: !0
|
|
15
|
-
},
|
|
16
|
-
".mjs": {
|
|
17
|
-
syntax: "ecmascript",
|
|
18
|
-
importAttributes: !0,
|
|
19
|
-
explicitResourceManagement: !0
|
|
20
|
-
},
|
|
21
|
-
".cjs": {
|
|
22
|
-
syntax: "ecmascript",
|
|
23
|
-
importAttributes: !0,
|
|
24
|
-
explicitResourceManagement: !0
|
|
25
|
-
},
|
|
26
|
-
".mdx": {
|
|
27
|
-
syntax: "ecmascript",
|
|
28
|
-
jsx: !0,
|
|
29
|
-
importAttributes: !0,
|
|
30
|
-
explicitResourceManagement: !0
|
|
31
|
-
}
|
|
32
|
-
}, validParsers = /* @__PURE__ */ new Set([...Object.keys(parsers), ".css"]);
|
|
33
|
-
export {
|
|
34
|
-
asyncGeneratorRegex,
|
|
35
|
-
debug,
|
|
36
|
-
parsers,
|
|
37
|
-
runtimePublicPath,
|
|
38
|
-
validParsers
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/constants.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,sBAAsB;AAExB,MAAM,EAAE,MAAM,IAAI,eAAe,sBAAsB,GAEjD,oBAAoB,mBAEpB,sBAAsB,yCAGtB,UAA+B;AAAA,EAC1C,QAAQ,EAAE,QAAQ,cAAc,KAAK,IAAM,YAAY,GAAK;AAAA,EAC5D,OAAO,EAAE,QAAQ,cAAc,KAAK,IAAO,YAAY,GAAK;AAAA,EAC5D,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,kBAAkB;AAAA,IAClB,4BAA4B;AAAA,EAC9B;AAAA,EACA,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,4BAA4B;AAAA,EAC9B;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,4BAA4B;AAAA,EAC9B;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,4BAA4B;AAAA,EAC9B;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,kBAAkB;AAAA,IAClB,4BAA4B;AAAA,EAC9B;AACF,GAEa,eAAe,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|