@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.
@@ -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
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var transformSWC_exports = {};
22
24
  __export(transformSWC_exports, {
@@ -24,128 +26,169 @@ __export(transformSWC_exports, {
24
26
  transformSWCStripJSX: () => transformSWCStripJSX
25
27
  });
26
28
  module.exports = __toCommonJS(transformSWC_exports);
27
- var import_node_path = require("node:path"),
28
- import_core = require("@swc/core"),
29
- import_ts_deepmerge = require("ts-deepmerge"),
30
- import_configure = require("./configure.cjs"),
31
- import_constants = require("./constants.cjs");
29
+ var import_node_path = require("node:path");
30
+ var import_core = require("@swc/core");
31
+ var import_ts_deepmerge = require("ts-deepmerge");
32
+ var import_configure = require("./configure.cjs");
33
+ var import_constants = require("./constants.cjs");
32
34
  const ignoreId = new RegExp(`node_modules\\${import_node_path.sep}(\\.vite|vite)\\${import_node_path.sep}`);
33
35
  async function transformSWC(id, code, options, swcOptions) {
34
- if (ignoreId.test(id) || (id = id.split("?")[0].replace(process.cwd(), ""), id === import_constants.runtimePublicPath)) return;
36
+ if (ignoreId.test(id)) {
37
+ return;
38
+ }
39
+ id = id.split("?")[0].replace(process.cwd(), "");
40
+ if (id === import_constants.runtimePublicPath) {
41
+ return;
42
+ }
35
43
  const parser = getParser(id, options.forceJSX);
36
- if (!parser) return;
37
- const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX && !id.includes("node_modules"),
38
- reactConfig = {
39
- refresh,
40
- development: !options.forceJSX && !options.production,
41
- runtime: "automatic",
42
- importSource: "react",
43
- ...(import_configure.configuration.enableNativewind && !id.includes("node_modules") ? {
44
- importSource: "nativewind"
45
- // pragma: 'createInteropElement',
46
- // pragmaFrag: '_InteropFragment',
47
- // swc doesnt actually change the import right
48
- // runtime: 'classic',
49
- } : {})
50
- },
51
- transformOptions = (() => {
52
- if (options.environment === "client" || options.environment === "ssr") return {
44
+ if (!parser) {
45
+ return;
46
+ }
47
+ const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX && !id.includes("node_modules");
48
+ const reactConfig = {
49
+ refresh,
50
+ development: !options.forceJSX && !options.production,
51
+ runtime: "automatic",
52
+ importSource: "react",
53
+ ...(import_configure.configuration.enableNativewind && !id.includes("node_modules") ? {
54
+ importSource: "nativewind"
55
+ // pragma: 'createInteropElement',
56
+ // pragmaFrag: '_InteropFragment',
57
+ // swc doesnt actually change the import right
58
+ // runtime: 'classic',
59
+ } : {})
60
+ };
61
+ const transformOptions = (() => {
62
+ if (options.environment === "client" || options.environment === "ssr") {
63
+ return {
53
64
  sourceMaps: shouldSourceMap(),
54
65
  jsc: {
55
66
  target: "es2020",
56
67
  parser,
57
68
  transform: {
58
- useDefineForClassFields: !0,
69
+ useDefineForClassFields: true,
59
70
  react: reactConfig
60
71
  }
61
72
  }
62
73
  };
63
- const opts = options.es5 || !process.env.VXRN_USE_BABEL_FOR_GENERATORS && import_constants.asyncGeneratorRegex.test(code) ? {
64
- jsc: {
65
- parser,
66
- target: "es5",
67
- transform: {
68
- useDefineForClassFields: !0,
69
- react: reactConfig
70
- }
74
+ }
75
+ const shouldEs5Transform = options.es5 || !process.env.VXRN_USE_BABEL_FOR_GENERATORS && import_constants.asyncGeneratorRegex.test(code);
76
+ const opts = shouldEs5Transform ? {
77
+ jsc: {
78
+ parser,
79
+ target: "es5",
80
+ transform: {
81
+ useDefineForClassFields: true,
82
+ react: reactConfig
71
83
  }
72
- } : {
73
- ...(!options.forceJSX && {
74
- env: SWC_ENV
84
+ }
85
+ } : {
86
+ ...(!options.forceJSX && {
87
+ env: SWC_ENV
88
+ }),
89
+ jsc: {
90
+ ...(options.forceJSX && {
91
+ target: "esnext"
75
92
  }),
76
- jsc: {
77
- ...(options.forceJSX && {
78
- target: "esnext"
79
- }),
80
- parser,
81
- transform: {
82
- useDefineForClassFields: !0,
83
- react: reactConfig
84
- }
93
+ parser,
94
+ transform: {
95
+ useDefineForClassFields: true,
96
+ react: reactConfig
85
97
  }
86
- };
87
- return {
88
- sourceMaps: shouldSourceMap(),
98
+ }
99
+ };
100
+ return {
101
+ sourceMaps: shouldSourceMap(),
102
+ module: {
103
+ importInterop: "none",
104
+ type: "nodenext"
105
+ },
106
+ ...(options.mode === "serve-cjs" && {
89
107
  module: {
90
108
  importInterop: "none",
91
- type: "nodenext"
92
- },
93
- ...(options.mode === "serve-cjs" && {
94
- module: {
95
- importInterop: "none",
96
- type: "commonjs",
97
- strict: !0
98
- }
99
- }),
100
- ...opts
101
- };
102
- })(),
103
- finalOptions = (0, import_ts_deepmerge.merge)({
104
- filename: id,
105
- swcrc: !1,
106
- configFile: !1,
107
- ...transformOptions
108
- }, swcOptions || {}),
109
- result = await (async () => {
110
- try {
111
- return (0, import_constants.debug)?.(`transformSWC ${id} using options:
112
- ${JSON.stringify(finalOptions, null, 2)}`), await (0, import_core.transform)(code, finalOptions);
113
- } catch (e) {
114
- const message = e.message,
115
- fileStartIndex = message.indexOf("\u256D\u2500[");
116
- if (fileStartIndex !== -1) {
117
- const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
118
- match && (e.line = match[1], e.column = match[2]);
109
+ type: "commonjs",
110
+ strict: true
111
+ }
112
+ }),
113
+ ...opts
114
+ };
115
+ })();
116
+ const finalOptions = (0, import_ts_deepmerge.merge)({
117
+ filename: id,
118
+ swcrc: false,
119
+ configFile: false,
120
+ ...transformOptions
121
+ }, swcOptions || {});
122
+ const result = await (async () => {
123
+ try {
124
+ (0, import_constants.debug)?.(`transformSWC ${id} using options:
125
+ ${JSON.stringify(finalOptions, null, 2)}`);
126
+ return await (0, import_core.transform)(code, finalOptions);
127
+ } catch (e) {
128
+ const message = e.message;
129
+ const fileStartIndex = message.indexOf("\u256D\u2500[");
130
+ if (fileStartIndex !== -1) {
131
+ const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
132
+ if (match) {
133
+ e.line = match[1];
134
+ e.column = match[2];
119
135
  }
120
- throw e;
121
136
  }
122
- })();
123
- import_configure.configuration.enableNativeCSS && result.code.includes("createInteropElement(") && (result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
124
- ${result.code}`);
137
+ throw e;
138
+ }
139
+ })();
140
+ if (import_configure.configuration.enableNativeCSS) {
141
+ if (result.code.includes(`createInteropElement(`)) {
142
+ result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
143
+ ${result.code}`;
144
+ }
145
+ }
125
146
  const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);
126
147
  if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
127
148
  const typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
128
- if (typeExportsMatch) for (const typeExport of Array.from(typeExportsMatch)) {
129
- const [_export, _type, name] = typeExport.split(/\s+/);
130
- if (name.startsWith("{") || name.includes("<")) continue;
131
- if (!new RegExp(`export (const|let|class|function) ${name}\\s+`).test(result.code)) {
132
- const fakeExport = `export let ${name} = {};`;
133
- console.info(` \u26A0\uFE0F Fixing non-type-specific import in node_module, this should be fixed upstream: ${fakeExport} in ${id}`), result.code += `
149
+ if (typeExportsMatch) {
150
+ for (const typeExport of Array.from(typeExportsMatch)) {
151
+ const [_export, _type, name] = typeExport.split(/\s+/);
152
+ if (name.startsWith("{")) continue;
153
+ if (name.includes("<")) continue;
154
+ const alreadyExported = new RegExp(`export (const|let|class|function) ${name}\\s+`).test(result.code);
155
+ if (!alreadyExported) {
156
+ const fakeExport = `export let ${name} = {};`;
157
+ console.info(` \u26A0\uFE0F Fixing non-type-specific import in node_module, this should be fixed upstream: ${fakeExport} in ${id}`);
158
+ result.code += `
134
159
  ${fakeExport}
135
160
  `;
161
+ }
136
162
  }
137
163
  }
138
164
  }
139
- return result && !options.production && !options.noHMR ? wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) : result;
165
+ if (result && !options.production && !options.noHMR) {
166
+ return wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime);
167
+ }
168
+ return result;
140
169
  }
141
170
  function wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {
142
- return options.environment === "ssr" ? result : options.environment === "client" ? wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) : wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
171
+ if (options.environment === "ssr") {
172
+ return result;
173
+ }
174
+ if (options.environment === "client") {
175
+ return wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime);
176
+ }
177
+ return wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
143
178
  }
144
179
  function wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {
145
180
  const sourceMap = result.map ? JSON.parse(result.map) : void 0;
146
- return sourceMap && (sourceMap.mappings = ";;" + sourceMap.mappings), result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
181
+ if (sourceMap) {
182
+ sourceMap.mappings = ";;" + sourceMap.mappings;
183
+ }
184
+ result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
147
185
 
148
- ${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.");
186
+ ${result.code}`;
187
+ if (hasRefreshRuntime) {
188
+ if (sourceMap) {
189
+ sourceMap.mappings = ";;;;;;" + sourceMap.mappings;
190
+ }
191
+ result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
149
192
  const prevRefreshReg = window.$RefreshReg$;
150
193
  const prevRefreshSig = window.$RefreshSig$;
151
194
  window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
@@ -155,7 +198,9 @@ ${result.code}
155
198
 
156
199
  window.$RefreshReg$ = prevRefreshReg;
157
200
  window.$RefreshSig$ = prevRefreshSig;
158
- `), result.code += `
201
+ `;
202
+ }
203
+ result.code += `
159
204
  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
160
205
  RefreshRuntime.registerExportsForReactRefresh("${id}", currentExports);
161
206
  import.meta.hot.accept((nextExports) => {
@@ -164,7 +209,8 @@ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
164
209
  if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
165
210
  });
166
211
  });
167
- `, {
212
+ `;
213
+ return {
168
214
  code: result.code,
169
215
  map: sourceMap
170
216
  };
@@ -187,11 +233,10 @@ const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
187
233
  globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
188
234
  globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
189
235
  module.url = '${id}'
190
- module.hot = createHotContext(module.url)`,
191
- sourceMap = result.map ? JSON.parse(result.map) : void 0;
236
+ module.hot = createHotContext(module.url)`;
237
+ const sourceMap = result.map ? JSON.parse(result.map) : void 0;
192
238
  if (sourceMap) {
193
- const prefixLen = prefixCode.split(`
194
- `).length + 1;
239
+ const prefixLen = prefixCode.split("\n").length + 1;
195
240
  sourceMap.mappings = new Array(prefixLen).fill(";").join("") + sourceMap.mappings;
196
241
  }
197
242
  return {
@@ -209,50 +254,62 @@ ${postfixCode}
209
254
  map: sourceMap
210
255
  };
211
256
  }
212
- return result.code += postfixCode, result;
257
+ result.code += postfixCode;
258
+ return result;
213
259
  }
214
260
  const SWC_ENV = {
215
- targets: {
216
- node: "4"
217
- },
218
- // debug: true,
219
- include: [],
220
- // this breaks the uniswap app for any file with a ...spread
221
- exclude: ["transform-spread", "transform-destructuring", "transform-object-rest-spread",
222
- // `transform-async-to-generator` is relying on `transform-destructuring`.
223
- // If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
224
- // with error: `called `Option::unwrap()` on a `None` value`.
225
- // See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
226
- "transform-async-to-generator", "transform-regenerator"
227
- // Similar to above
228
- ]
261
+ targets: {
262
+ node: "4"
229
263
  },
230
- refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
264
+ // debug: true,
265
+ include: [],
266
+ // this breaks the uniswap app for any file with a ...spread
267
+ exclude: ["transform-spread", "transform-destructuring", "transform-object-rest-spread",
268
+ // `transform-async-to-generator` is relying on `transform-destructuring`.
269
+ // If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
270
+ // with error: `called `Option::unwrap()` on a `None` value`.
271
+ // See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
272
+ "transform-async-to-generator", "transform-regenerator"
273
+ // Similar to above
274
+ ]
275
+ };
276
+ const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
231
277
  function shouldSourceMap() {
232
278
  return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
233
279
  }
234
- function getParser(id, forceJSX = !1) {
235
- if (id.endsWith("one-entry-native")) return import_constants.parsers[".tsx"];
280
+ function getParser(id, forceJSX = false) {
281
+ if (id.endsWith("one-entry-native")) {
282
+ return import_constants.parsers[".tsx"];
283
+ }
236
284
  const extension = (0, import_node_path.extname)(id);
237
- let parser = extension ? import_constants.parsers[extension] : import_constants.parsers[".js"];
238
- return (extension === ".js" || extension === ".mjs") && (forceJSX && (parser = import_constants.parsers[".jsx"]), id.includes("expo-modules-core") && (parser = import_constants.parsers[".jsx"])), parser;
285
+ let parser = !extension ? import_constants.parsers[".js"] : import_constants.parsers[extension];
286
+ if (extension === ".js" || extension === ".mjs") {
287
+ if (forceJSX) {
288
+ parser = import_constants.parsers[".jsx"];
289
+ }
290
+ if (id.includes("expo-modules-core")) {
291
+ parser = import_constants.parsers[".jsx"];
292
+ }
293
+ }
294
+ return parser;
239
295
  }
240
296
  const transformSWCStripJSX = async (id, code) => {
241
297
  const parser = getParser(id);
242
- if (parser) return await (0, import_core.transform)(code, {
298
+ if (!parser) return;
299
+ return await (0, import_core.transform)(code, {
243
300
  filename: id,
244
- swcrc: !1,
245
- configFile: !1,
301
+ swcrc: false,
302
+ configFile: false,
246
303
  sourceMaps: shouldSourceMap(),
247
304
  jsc: {
248
305
  target: "es2019",
249
306
  parser,
250
307
  transform: {
251
- useDefineForClassFields: !0,
308
+ useDefineForClassFields: true,
252
309
  react: {
253
- development: !0,
310
+ development: true,
254
311
  runtime: "automatic",
255
- refresh: !1
312
+ refresh: false
256
313
  }
257
314
  }
258
315
  }
@@ -3,14 +3,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
- get: () => from[key],
8
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
- });
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
10
12
  return to;
11
13
  };
12
14
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
- value: !0
15
+ value: true
14
16
  }), mod);
15
17
  var types_exports = {};
16
18
  module.exports = __toCommonJS(types_exports);
@@ -9,9 +9,12 @@ const stats = {
9
9
  };
10
10
  function getCacheDir() {
11
11
  const cacheDir = join(process.cwd(), "node_modules", ".vxrn", "compiler-cache");
12
- return existsSync(cacheDir) || mkdirSync(cacheDir, {
13
- recursive: !0
14
- }), cacheDir;
12
+ if (!existsSync(cacheDir)) {
13
+ mkdirSync(cacheDir, {
14
+ recursive: true
15
+ });
16
+ }
17
+ return cacheDir;
15
18
  }
16
19
  function getConfigFingerprint() {
17
20
  return createHash("sha1").update(JSON.stringify({
@@ -22,45 +25,59 @@ function getConfigFingerprint() {
22
25
  })).digest("hex").slice(0, 8);
23
26
  }
24
27
  function getCacheKey(filePath, environment) {
25
- return createHash("sha1").update(`${environment}:${filePath}:${getConfigFingerprint()}`).digest("hex");
28
+ const hash = createHash("sha1").update(`${environment}:${filePath}:${getConfigFingerprint()}`).digest("hex");
29
+ return hash;
26
30
  }
27
31
  function getContentHash(code) {
28
32
  return createHash("sha1").update(code).digest("hex").slice(0, 16);
29
33
  }
30
34
  function getCachedTransform(filePath, code, environment) {
31
35
  try {
32
- const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath,
33
- cacheDir = getCacheDir(),
34
- cacheKey = getCacheKey(cleanPath, environment),
35
- cachePath = join(cacheDir, `${cacheKey}.json`);
36
- if (!existsSync(cachePath)) return stats.misses++, null;
37
- const cached = JSON.parse(readFileSync(cachePath, "utf-8")),
38
- currentMtime = statSync(cleanPath).mtimeMs;
39
- if (cached.mtime !== currentMtime) return stats.misses++, null;
36
+ const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath;
37
+ const cacheDir = getCacheDir();
38
+ const cacheKey = getCacheKey(cleanPath, environment);
39
+ const cachePath = join(cacheDir, `${cacheKey}.json`);
40
+ if (!existsSync(cachePath)) {
41
+ stats.misses++;
42
+ return null;
43
+ }
44
+ const cached = JSON.parse(readFileSync(cachePath, "utf-8"));
45
+ const currentMtime = statSync(cleanPath).mtimeMs;
46
+ if (cached.mtime !== currentMtime) {
47
+ stats.misses++;
48
+ return null;
49
+ }
40
50
  const currentHash = getContentHash(code);
41
- return cached.hash !== currentHash ? (stats.misses++, null) : (stats.hits++, {
51
+ if (cached.hash !== currentHash) {
52
+ stats.misses++;
53
+ return null;
54
+ }
55
+ stats.hits++;
56
+ return {
42
57
  code: cached.code,
43
58
  map: cached.map
44
- });
45
- } catch {
46
- return stats.misses++, null;
59
+ };
60
+ } catch (err) {
61
+ stats.misses++;
62
+ return null;
47
63
  }
48
64
  }
49
65
  function setCachedTransform(filePath, code, result, environment) {
50
66
  try {
51
- const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath,
52
- cacheDir = getCacheDir(),
53
- cacheKey = getCacheKey(cleanPath, environment),
54
- cachePath = join(cacheDir, `${cacheKey}.json`),
55
- mtime = statSync(cleanPath).mtimeMs,
56
- hash = getContentHash(code),
57
- entry = {
58
- mtime,
59
- hash,
60
- code: result.code,
61
- map: result.map
62
- };
63
- writeFileSync(cachePath, JSON.stringify(entry), "utf-8"), stats.writes++;
67
+ const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath;
68
+ const cacheDir = getCacheDir();
69
+ const cacheKey = getCacheKey(cleanPath, environment);
70
+ const cachePath = join(cacheDir, `${cacheKey}.json`);
71
+ const mtime = statSync(cleanPath).mtimeMs;
72
+ const hash = getContentHash(code);
73
+ const entry = {
74
+ mtime,
75
+ hash,
76
+ code: result.code,
77
+ map: result.map
78
+ };
79
+ writeFileSync(cachePath, JSON.stringify(entry), "utf-8");
80
+ stats.writes++;
64
81
  } catch (err) {
65
82
  console.warn(`[cache] Failed to write cache for ${filePath}:`, err);
66
83
  }
@@ -71,7 +88,9 @@ function getCacheStats() {
71
88
  };
72
89
  }
73
90
  function logCacheStats() {
74
- if (!process.env.DEBUG_COMPILER_PERF) return;
91
+ if (!process.env.DEBUG_COMPILER_PERF) {
92
+ return;
93
+ }
75
94
  const total = stats.hits + stats.misses;
76
95
  if (total === 0) return;
77
96
  const hitRate = (stats.hits / total * 100).toFixed(1);
@@ -1 +1 @@
1
- {"version":3,"names":["createHash","existsSync","mkdirSync","readFileSync","statSync","writeFileSync","join","configuration","stats","hits","misses","writes","getCacheDir","cacheDir","process","cwd","recursive","getConfigFingerprint","update","JSON","stringify","compiler","enableCompiler","reanimated","enableReanimated","nativewind","enableNativewind","nativeCSS","enableNativeCSS","digest","slice","getCacheKey","filePath","environment","getContentHash","code","getCachedTransform","cleanPath","startsWith","cacheKey","cachePath","cached","parse","currentMtime","mtimeMs","mtime","currentHash","hash","map","setCachedTransform","result","entry","err","console","warn","getCacheStats","logCacheStats","env","DEBUG_COMPILER_PERF","total","hitRate","toFixed","info"],"sources":["../../src/cache.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,QAAkB;AAC3B,SAASC,UAAA,EAAYC,SAAA,EAAWC,YAAA,EAAcC,QAAA,EAAUC,aAAA,QAAqB;AAC7E,SAASC,IAAA,QAAY;AACrB,SAASC,aAAA,QAAqB;AAwB9B,MAAMC,KAAA,GAAoB;EAAEC,IAAA,EAAM;EAAGC,MAAA,EAAQ;EAAGC,MAAA,EAAQ;AAAE;AAE1D,SAASC,YAAA,EAAsB;EAE7B,MAAMC,QAAA,GAAWP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,GAAG,OAAO,GACvD3C,KAAA,CAAMG,MAAA;EACR,SAASyC,GAAA,EAAK;IAEZC,OAAA,CAAQC,IAAA,CAAK,qCAAqCtB,QAAQ,KAAKoB,GAAG;EACpE;AACF;AAEO,SAASG,cAAA,EAA4B;EAC1C,OAAO;IAAE,GAAG/C;EAAM;AACpB;AAEO,SAASgD,cAAA,EAAsB;EAEpC,IAAI,CAAC1C,OAAA,CAAQ2C,GAAA,CAAIC,mBAAA,EACf;EAGF,MAAMC,KAAA,GAAQnD,KAAA,CAAMC,IAAA,GAAOD,KAAA,CAAME,MAAA;EACjC,IAAIiD,KAAA,KAAU,GAAG;EAEjB,MAAMC,OAAA,IAAYpD,KAAA,CAAMC,IAAA,GAAOkD,KAAA,GAAS,KAAKE,OAAA,CAAQ,CAAC;EACtDR,OAAA,CAAQS,IAAA,CACN;AAAA,0BAAsBtD,KAAA,CAAMC,IAAI,WAAWD,KAAA,CAAME,MAAM,YAAYkD,OAAO,gBAAgBpD,KAAA,CAAMG,MAAM,SACxG;AACF","ignoreList":[]}
1
+ {"version":3,"names":["createHash","existsSync","mkdirSync","readFileSync","statSync","writeFileSync","join","configuration","stats","hits","misses","writes","getCacheDir","cacheDir","process","cwd","recursive","getConfigFingerprint","update","JSON","stringify","compiler","enableCompiler","reanimated","enableReanimated","nativewind","enableNativewind","nativeCSS","enableNativeCSS","digest","slice","getCacheKey","filePath","environment","hash","getContentHash","code","getCachedTransform","cleanPath","startsWith","cacheKey","cachePath","cached","parse","currentMtime","mtimeMs","mtime","currentHash","map","err","setCachedTransform","result","entry","console","warn","getCacheStats","logCacheStats","env","DEBUG_COMPILER_PERF","total","hitRate","toFixed","info"],"sources":["../../src/cache.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,QAAkB;AAC3B,SAASC,UAAA,EAAYC,SAAA,EAAWC,YAAA,EAAcC,QAAA,EAAUC,aAAA,QAAqB;AAC7E,SAASC,IAAA,QAAY;AACrB,SAASC,aAAA,QAAqB;A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O;IAEnD,MAAMM,KAAA,GAAQ1C,QAAA,CAASkC,SAAS,EAAEO,OAAA;IAClC,MAAMX,IAAA,GAAOC,cAAA,CAAeC,IAAI;IAEhC,MAAMgB,KAAA,GAAoB;MACxBN,KAAA;MACAZ,IAAA;MACAE,IAAA,EAAMe,MAAA,CAAOf,IAAA;MACbY,GAAA,EAAKG,MAAA,CAAOH;IACd;IAEA3C,aAAA,CAAcoC,SAAA,EAAWtB,IAAA,CAAKC,SAAA,CAAUgC,KAAK,GAAG,OAAO;IACvD5C,KAAA,CAAMG,MAAA;EACR,SAASsC,GAAA,EAAK;IAEZI,OAAA,CAAQC,IAAA,CAAK,qCAAqCtB,QAAQ,KAAKiB,GAAG;EACpE;AACF;AAEO,SAASM,cAAA,EAA4B;EAC1C,OAAO;IAAE,GAAG/C;EAAM;AACpB;AAEO,SAASgD,cAAA,EAAsB;EAEpC,IAAI,CAAC1C,OAAA,CAAQ2C,GAAA,CAAIC,mBAAA,EAAqB;IACpC;EACF;EAEA,MAAMC,KAAA,GAAQnD,KAAA,CAAMC,IAAA,GAAOD,KAAA,CAAME,MAAA;EACjC,IAAIiD,KAAA,KAAU,GAAG;EAEjB,MAAMC,OAAA,IAAYpD,KAAA,CAAMC,IAAA,GAAOkD,KAAA,GAAS,KAAKE,OAAA,CAAQ,CAAC;EACtDR,OAAA,CAAQS,IAAA,CACN;AAAA,0BAAsBtD,KAAA,CAAMC,IAAI,WAAWD,KAAA,CAAME,MAAM,YAAYkD,OAAO,gBAAgBpD,KAAA,CAAMG,MAAM,SACxG;AACF","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  const configuration = {
2
- enableNativewind: !1,
3
- enableReanimated: !1,
4
- enableCompiler: !1,
5
- enableNativeCSS: !1
2
+ enableNativewind: false,
3
+ enableReanimated: false,
4
+ enableCompiler: false,
5
+ enableNativeCSS: false
6
6
  };
7
7
  function configureVXRNCompilerPlugin(_) {
8
8
  Object.assign(configuration, _);