Skip to content

Commit 1f535d0

Browse files
committed
refactor: Update PDF.js import to legacy build and configure local worker source.
1 parent 426a4e3 commit 1f535d0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/services/ragService.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { pipeline } from '@xenova/transformers';
22
import { supabase } from '../config/supabase';
3-
import * as pdfjsLib from 'pdfjs-dist';
3+
import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf';
4+
import pdfWorkerSrc from 'pdfjs-dist/legacy/build/pdf.worker?url';
45

56
// Safe worker configuration for browser environments
6-
if (typeof window !== 'undefined') {
7-
pdfjsLib.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.js`;
7+
if (typeof window !== 'undefined' && pdfjsLib?.GlobalWorkerOptions) {
8+
pdfjsLib.GlobalWorkerOptions.workerSrc = pdfWorkerSrc;
89
}
910

1011
const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL;

0 commit comments

Comments
 (0)