vargai 0.4.0-alpha7 → 0.4.0-alpha8

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/package.json CHANGED
@@ -64,7 +64,7 @@
64
64
  "replicate": "^1.4.0",
65
65
  "zod": "^4.2.1"
66
66
  },
67
- "version": "0.4.0-alpha7",
67
+ "version": "0.4.0-alpha8",
68
68
  "exports": {
69
69
  ".": "./src/index.ts",
70
70
  "./ai": "./src/ai-sdk/index.ts",
@@ -19,21 +19,27 @@ async function loadComponent(filePath: string): Promise<VargElement> {
19
19
  source.includes("from '@vargai") ||
20
20
  source.includes('from "@vargai');
21
21
 
22
- if (hasImports) {
22
+ const hasJsxPragma =
23
+ source.includes("@jsxImportSource") || source.includes("@jsx ");
24
+
25
+ if (hasImports && hasJsxPragma) {
23
26
  const mod = await import(resolvedPath);
24
27
  return mod.default;
25
28
  }
26
29
 
27
- const tmpDir = ".cache/varg-render";
30
+ const tmpDir = `${process.cwd()}/.cache/varg-render`;
28
31
  if (!existsSync(tmpDir)) {
29
32
  mkdirSync(tmpDir, { recursive: true });
30
33
  }
31
34
 
35
+ const prepended = hasImports
36
+ ? `/** @jsxImportSource vargai */\n`
37
+ : AUTO_IMPORTS;
32
38
  const tmpFile = `${tmpDir}/${Date.now()}.tsx`;
33
- await Bun.write(tmpFile, AUTO_IMPORTS + source);
39
+ await Bun.write(tmpFile, prepended + source);
34
40
 
35
41
  try {
36
- const mod = await import(resolve(tmpFile));
42
+ const mod = await import(tmpFile);
37
43
  return mod.default;
38
44
  } finally {
39
45
  (await Bun.file(tmpFile).exists()) && (await Bun.write(tmpFile, ""));