vargai 0.4.0-alpha90 → 0.4.0-alpha92
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 +1 -1
- package/src/cli/commands/render.tsx +12 -6
package/package.json
CHANGED
|
@@ -75,7 +75,9 @@ async function loadComponent(filePath: string): Promise<VargElement> {
|
|
|
75
75
|
const hasVargaiImport =
|
|
76
76
|
source.includes("from 'vargai") ||
|
|
77
77
|
source.includes('from "vargai') ||
|
|
78
|
-
source.includes("@jsxImportSource vargai")
|
|
78
|
+
source.includes("@jsxImportSource vargai") ||
|
|
79
|
+
source.includes('from "@vargai/gateway"') ||
|
|
80
|
+
source.includes("from '@vargai/gateway'");
|
|
79
81
|
|
|
80
82
|
const hasRelativeImport =
|
|
81
83
|
source.includes("from './") || source.includes('from "./');
|
|
@@ -94,12 +96,16 @@ async function loadComponent(filePath: string): Promise<VargElement> {
|
|
|
94
96
|
|
|
95
97
|
if (hasVargaiImport) {
|
|
96
98
|
const tmpFile = `${tmpDir}/${Date.now()}.tsx`;
|
|
97
|
-
// Resolve
|
|
99
|
+
// Resolve all vargai-related imports to absolute paths so they work from
|
|
100
|
+
// the bunx cache dir (where @vargai/gateway and vargai/* aren't installed)
|
|
98
101
|
const runtimeDir = resolve(pkgDir, "src/react/runtime");
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
const aiSdkDir = resolve(pkgDir, "src/ai-sdk/index.ts");
|
|
103
|
+
const reactDir = resolve(pkgDir, "src/react/index.ts");
|
|
104
|
+
const resolvedSource = source
|
|
105
|
+
.replace(/@jsxImportSource\s+vargai/, `@jsxImportSource ${runtimeDir}`)
|
|
106
|
+
.replace(/from\s+["']@vargai\/gateway["']/g, `from "${aiSdkDir}"`)
|
|
107
|
+
.replace(/from\s+["']vargai\/ai["']/g, `from "${aiSdkDir}"`)
|
|
108
|
+
.replace(/from\s+["']vargai\/react["']/g, `from "${reactDir}"`);
|
|
103
109
|
await Bun.write(tmpFile, resolvedSource);
|
|
104
110
|
|
|
105
111
|
try {
|