Commit 50c2e0e
committed
fix(asyncReader): handle CJS/ESM interop and null GlobalWorkerOptions
In Vite watch mode, pdfjs-dist is served without pre-bundling when the
package is linked via file: path, causing the module to be wrapped under
.default instead of exposing named exports directly. This results in
PDFWorker being undefined at runtime.
- Add normalizePdfjs() to unwrap .default when present (CJS/ESM interop)
- Guard ensureWorkerSrc against undefined GlobalWorkerOptions
- Reset sharedWorker to null in setWorkerPath to force recreation
- Add .catch with console.warn in setWorkerPath for failed async updates
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>1 parent e50c6ef commit 50c2e0e
1 file changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | | - | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
27 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
28 | 38 | | |
29 | 39 | | |
30 | 40 | | |
| |||
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | | - | |
| 47 | + | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| |||
44 | 54 | | |
45 | 55 | | |
46 | 56 | | |
| 57 | + | |
47 | 58 | | |
48 | 59 | | |
49 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
50 | 65 | | |
51 | 66 | | |
52 | 67 | | |
| |||
0 commit comments