Move react-pdf dynamic import

This commit is contained in:
Gregory Schier
2025-05-25 20:39:14 -07:00
parent 101582e540
commit 245054cd7d
3 changed files with 27 additions and 7 deletions

View File

@@ -7,13 +7,6 @@ import React, { useRef, useState } from 'react';
import { Document, Page } from 'react-pdf';
import { useContainerSize } from '../../hooks/useContainerQuery';
import('react-pdf').then(({ pdfjs }) => {
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url,
).toString();
});
interface Props {
bodyPath: string;
}

View File

@@ -9,6 +9,13 @@ import { initSync } from './init/sync';
import { jotaiStore } from './lib/jotai';
import { router } from './lib/router';
import('react-pdf').then(({ pdfjs }) => {
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url,
).toString();
});
// Hide decorations here because it doesn't work in Rust for some reason (bug?)
const osType = type();
if (osType !== 'macos') {