Skip to content

Commit c5018da

Browse files
committed
Add workaround for JSR package import path issues and update dependencies
- Document known issues with `@logan/libsql-search` and `@logan/logger` JSR packages, including incorrect relative import paths. - Implement Vite plugin `fixJSRImports()` in `astro.config.mjs` to correct paths at build time. - Update dependencies to include relevant packages: `@google/generative-ai`, `openai`, and `winston`. - Modify `CLAUDE.md` to include details about the workaround and potential permanent fixes.
1 parent d970ba5 commit c5018da

File tree

4 files changed

+262
-3
lines changed

4 files changed

+262
-3
lines changed

CLAUDE.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,20 @@ The default build uses the Node.js adapter for maximum compatibility with tradit
188188
### Deployment Requirements
189189
- **Always run** `pnpm index` (or `pnpm index:local` for testing) before deploying to ensure content is indexed
190190
- Set environment variables (`TURSO_DB_URL`, `TURSO_AUTH_TOKEN`, etc.) in your deployment platform
191-
- Both adapters support the same features; choose based on deployment target
191+
- Both adapters support the same features; choose based on deployment target
192+
193+
### Known Issues & Workarounds
194+
195+
**JSR Package Import Paths**: The JSR-published versions of `@logan/libsql-search` and `@logan/logger` have incorrect relative import paths (e.g., `./@google/generative-ai` instead of `@google/generative-ai`).
196+
197+
**Workaround in astro.config.mjs**:
198+
- Custom Vite plugin `fixJSRImports()` corrects these paths at build time (lines 19-37)
199+
- Required dependencies: `@google/generative-ai`, `openai`, `winston` (installed in package.json)
200+
201+
**Permanent Fix Needed**:
202+
Update the source packages to use correct import paths:
203+
- `libsql-search/src/embeddings.ts`: Change `./@google/generative-ai``@google/generative-ai`
204+
- `libsql-search/src/embeddings.ts`: Change `./openai``openai`
205+
- `logger/src/runtime/node.ts`: Change `./winston``winston`
206+
207+
Once fixed upstream, the Vite plugin and explicit dependencies can be removed.

astro.config.mjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,34 @@ const adapter =
1616
? cloudflare()
1717
: node({ mode: 'standalone' });
1818

19+
// Vite plugin to fix JSR package import paths
20+
function fixJSRImports() {
21+
return {
22+
name: 'fix-jsr-imports',
23+
resolveId(/** @type {string} */ source) {
24+
// Fix incorrect relative imports from JSR packages
25+
/** @type {Record<string, string>} */
26+
const fixMap = {
27+
'./@google/generative-ai': '@google/generative-ai',
28+
'./openai': 'openai',
29+
'./winston': 'winston',
30+
};
31+
32+
if (fixMap[source]) {
33+
return { id: fixMap[source], external: true };
34+
}
35+
return null;
36+
},
37+
};
38+
}
39+
1940
// https://astro.build/config
2041
export default defineConfig({
2142
output: 'server',
2243
adapter,
2344
integrations: [react()],
2445
vite: {
25-
plugins: [tailwindcss()],
46+
plugins: [tailwindcss(), fixJSRImports()],
2647
resolve: {
2748
alias: {
2849
'@': path.resolve(__dirname, './src'),

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@astrojs/cloudflare": "^12.6.10",
4444
"@astrojs/node": "^9.5.0",
4545
"@astrojs/react": "^4.4.0",
46+
"@google/generative-ai": "^0.24.1",
4647
"@libsql/client": "^0.15.15",
4748
"@logan/libsql-search": "jsr:^0.1.3",
4849
"@logan/logger": "jsr:^1.1.11",
@@ -53,10 +54,12 @@
5354
"cmdk": "^1.1.1",
5455
"lucide-react": "^0.546.0",
5556
"marked": "^16.4.0",
57+
"openai": "^6.7.0",
5658
"react": "^19.2.0",
5759
"react-dom": "^19.2.0",
5860
"tailwind-merge": "^3.3.1",
59-
"tailwindcss": "^4.1.14"
61+
"tailwindcss": "^4.1.14",
62+
"winston": "^3.18.3"
6063
},
6164
"devDependencies": {
6265
"@biomejs/biome": "^2.2.6",

0 commit comments

Comments
 (0)