Skip to content

Instantly share code, notes, and snippets.

@TheOnlyWayUp
Last active September 16, 2023 22:02
Show Gist options
  • Save TheOnlyWayUp/baedaee6e81ff269fe5ffc55c09428af to your computer and use it in GitHub Desktop.
Save TheOnlyWayUp/baedaee6e81ff269fe5ffc55c09428af to your computer and use it in GitHub Desktop.
Importing PDF.JS on Sveltekit

PDF.JS on Svelte(kit), Vite

mozilla/pdf.js#12389 (comment)

It seems default import doesn't work, it works with namespace import import * as pdfjs from 'pdfjs-dist';.

My deepest appreciation to the author of this comment. Thanks man 🙏

Alright, back to the grind. Hope this was helpful

🙏

  • Do not mess with optimized dependencies, breaks library importing on the client side
  • Ref wojtekmaj/react-pdf#782 (comment), or modify your package.json to copy the node_module's worker script to a static folder. First is easier, but leaks information to third-party services. Latter just takes a minute longer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment